Backup and Restore
Backup
Everything of value is stored in the MariaDB database
Modify/run this on the host server to trigger a backup, which will dump the databases in a .sql.gz to the BACKUP_FILE location
#!/bin/bash
MARIADB_CONTAINER='mariadb'
BACKUP_FILE='/tmp/synclias.sql.gz'
docker exec ${MARIADB_CONTAINER} mariadb-dump --user ${MARIADB_USER} --password=${MARIADB_PASSWORD} ${MARIADB_DATABASE} | gzip > ${BACKUP_FILE}
Restore
Very similar as above:
- Stop the web/worker/beat containers
- Modify the following as appropriate
MARIADB_CONTAINER='mariadb'
BACKUP_FILE='/tmp/synclias.sql.gz'
docker exec ${MARIADB_CONTAINER} mariadb --user ${MARIADB_USER} --password=${MARIADB_PASSWORD} ${MARIADB_DATABASE} < zcat ${BACKUP_FILE}
- Start web/worker/beat containers
Selective Restores
In general, this isn’t recommended, but if you’ve lost your Encryption Key, you can restore most data apart from the “Routers” and “Nameservers” tables, where data is stored encrypted
- Make a copy of the .sql.gz file
- gunzip the sql.gz file
- Edit the .sql file and remove the sections for the Nameservers and Routers table
- Stop the web/worker/beat containers
- Run the restore command with the edited sql file (but change zcat to cat)
- Start the web/worker/app containers, with a new encryption key etc
- Log back in, default tables will be auto-generated and you’ll need to supply router/nameservers again
Notes on other data:
Other data is pretty transient and not really worth backing up:
Redis - this is task schedules and temporary task history (Anything needed from the result of a task is store in MariaDB, e.g. Sync History)
ASN DB A “launch” copy is held in /locker in the container, and deployed to /shared when needed.
If you need to restore a newer version, you can use pyasn to download it (most package maintainers include the pyasn_util* scripts, and you can upload “asn_db” and “asn_names” with a “docker cp” command.