Backup and Restore

InterDiode data to backup consists of the database and the primary file storage. Other data, such as the cache, can be lost without serious consequences, other than the possible reconstruction time on first use. For information purposes, here are the classic commands to back up the database, depending on the type of database used:

# mysql
docker compose exec -i [DATABASE_CONTAINER] mysqldump -u[USER] -p[PASS] --database [DATABASE] > interdiode-db.sql
# postgres
docker compose exec -i [DATABASE_CONTAINER] pg_dump  --clean --format=p --no-owner --if-exists --inserts -U [USER] [DATABASE] > interdiode-db.sql

You also need to back up the primary file storage, which is mounted in the MAIN_STORAGE_DIR directory of the InterDiode container or is a S3 storage.

The matching restore commands are as follows:

# mysql
docker compose exec -i [DATABASE_CONTAINER] mysql --default-character-set=utf8mb4 -u[USER] -p[PASS] [DATABASE] <interdiode-db.sql
# postgres
docker compose exec -i [DATABASE_CONTAINER] psql -U [USER] -d [DATABASE] < interdiode-db.sql

Primary file storage can be restored by copying the backup to the MAIN_STORAGE_DIR directory of the InterDiode container using the standard rsync utility.

rsync -a --delete [SRC_DIR]/ [DST_DIR]/

The Redis cache can be backed up, even if it less important than the SQL database or files, as the cache will be automatically rebuilt on first use after a restore. If the Redis database is lost, then users will have to log in again and waiting tasks will have to be restarted, but no data will be lost.

redis-cli BGSAVE