Ledger-Home

SQL-Ledger Restore

revised: 19-Feb-2022

ensuring reliable restore and enabling possible system transfer - a two part process

In the version:3.* series, one can now simply restore the database via the menu: [System]->[Maintenance]->[Restore]
However for a comprehensive restore in the event of a server failure, one would follow the steps below particularly with regard to the application files where all the templates and users are kept.

a. Restore the Application

Assumption: There was functional SQL-System running previously on the server. This step is not necessary simply for a database restore.

Via an FTP client (eg. FileZilla), upload the application backup (eg. example.com-SQL-ledger3.2.10-200831.tar.gz) to the regular user home directory (eg. /home/sammy). Input the following commands to restore the target database eg. testdb:

sammy@imega:$ sudo mv [MyServerName]-SQL-ledger3.2.10-[date].tar.gz /usr/local
sammy@imega:$ cd /usr/local
sammy@imega:/usr/local$ sudo tar -xzvf [MyServerName]-SQL-ledger3.2.10-[date].tar.gz
sammy@imega:/usr/local$ sudo chmod -R 775 sql-ledger/  Set the correct permissions.

The application restore is then complete. For a full restore, all the related databases need to be restored first to the PostgreSQL server, then follows the restore of the SQL-Ledger application backup.

b. Restore a Database (Alternative - Manually)

Via an FTP client (eg. FileZilla), upload the database backup (eg. testdb-3.2.10-20200522.sql.gz) to the regular user home directory (eg. /home/sammy). Input the following commands to restore the target database eg. testdb:

sammy@imega:$ sudo mv testdb-3.2.10-20200522.sql.gz /usr/local
sammy@imega:$ cd /usr/local
sammy@imega:/usr/local$ sudo chown postgres:postgres testdb-3.2.10-20200522.sql.gz
sammy@imega:/usr/local$ sudo su postgres
postgres@imega:/usr/local$ dropdb testdb
postgres@imega:/usr/local$ createdb testdb
postgres@imega:/usr/local$ gunzip -c testdb-3.2.10-20200522.sql.gz | psql -Usql-ledger testdb   Note: wait for the end of its transactions. postgres@imega:/usr/local$ exit

Thereafter one should be able to login (with a user linked to the target database) to the SQL-ledger and find it restored at the time of its backup.

Ledger-Home Ledger-Extras
Ledger-Backup Ledger-Restore