Appearance
Backup
It's a good practice to backup your database and your preview files. Here is a quick guide to backup all the required files. You will find information too about how to restore them.
Backup Your Database
To run a backup of the Zou database, run the following command:
bash
cd /opt/zou/backups
. /etc/zou/zou.env
/opt/zou/zouenv/bin/zou dump-databaseAll data will be stored in a file in the current directory. The generated file name will follow this format: 2021-03-21-zou-db-backup.sql.gz
Database Backup Restoration
To restore the database to a new Postgres instance make sure the source and target version of the api match, otherwise the database schema may not match, if all matches run
bash
gunzip 2021-03-21-zou-db-backup.sql.gz
createdb -h localhost -p 5432 -U postgres targetdb
psql -h yourphost -p 5432 -U postgres -1 -d targetdb -f 2021-03-21-zou-db-backup.sqlyou can also just write directly to zoudb (the default database):
bash
gunzip 2021-03-21-zou-db-backup.sql.gz
psql -h yourphost -p 5432 -U postgres -1 -d zoudb -f 2021-03-21-zou-db-backup.sqlwhen writing to a previously created database, make sure to terminate all the connections to said database by using the following statement:
bash
SELECT pg_terminate_backend (pid) FROM pg_stat_activity WHERE datname = 'zoudb';you can also change the name of a database to convert it to the default db:
bash
ALTER DATABASE targetdb RENAME TO zoudb;you can also change the database being used by using an environment variable in
/etc/zou/zou.env
bash
DB_DATABASE=targetdbFile Storage Backup
If you rely on an object storage, you have to check with your provider that your data are properly replicated.
If you store your files directly on your drive, you must backup the preview folder (/opt/zou/previews by default). There are plenty of documentation and tools available on the internet to do that. We won't cover this subject here.
File Storage Backup Restoration
To restore the files you simply have to put the files from your backups the directory you want. Then make sure thate the PREVIEW_FOLDER environment variable targets it properly.
