Managing Container Backups
Stateful containers on Cycle can be set to automatically be backed up. Currently, this integration relies on setting up Backblaze as a hub level integration.
After setting up container backups, using the aforementioned guide, a user can see all backups of a stateful container using the "Backups" option available in the container modal's main navigation.
Backup & Restore Commands
The command used to create the backups should write to stdout. For example: tar cf - -C /dir/change directory/to/backup
uses the -
flag to signify the intention to write to stdout. Another example is the popular command line tool mysqldump
which is packaged with most SQL database official images. Given the command: mysqldump --all-databases -uuser -ppassword
, mysqldump will write all the files to stdout.
Similar to creating backups, the command used to restore a backup should read from stdin
. For example the counterpart to the mysqldump command would be: mysql -uuser -ppassword < /dev/stdin
This pattern allows for maximum flexibility when crafting backup commands. Users should look to provided tools for the software they are running re:mysqldump
. This will provide the most reliable way to snapshot or restore files needed, while minimizing the chance of corruption as these tools were meant to be used to facilitate backups.
It is also perfectly valid to invoke a script via the command. The script needs to write to stdout or read from stdin for the respective create & restore functions. If the script is not reachable by traversing the container's path make sure to include the absolute path to the script in the command.
Container environment variables are available to use in backup commands. Double quotes allow the usage of environment variables when the script executes.
MySQL Example
Operation | Command |
---|---|
Backup | "mysqldump --all-databases -u root -p$MYSQL_ROOT_PASSWORD" |
Restore | "mysql -u root -p $MYSQL_ROOT_PASSWORD < /dev/stdin" |
PostgreSQL Example
Operation | Command |
---|---|
Backup | "PGPASSWORD=$POSTGRES_PASSWORD pg_dump -U $POSTGRES_USER --clean -Ft $POSTGRES_DB" |
Restore | "PASSWORD=$POSTGRES_PASSWORD pg_restore -U $POSTGRES_USER -Ft -d $POSTGRES_DB" |
MongoDB Example
Operation | Command |
---|---|
Backup | "mongodump --archive -u $USERNAME -p $PASSWORD" |
Restore | "mongorestore --archive -u $USERNAME -p $PASSWORD" |
Tar Example
Operation | Command |
---|---|
Backup | "tar czf /dev/stdout -C /var/lib/test backup" |
Restore | "tar xzf /dev/stdin -C /var/lib/test" |
Viewing Backups
To view a backup, navigate to the container that has been backed up and select the "Backups" option from the container modal navigation.
Selecting an individual backup will show basic information about the backup as well as a log from STDERR.
Managing Backups
Restore From Backup
To restore from a backup, click on the sync icon and select the instance.
When the backup restore attempt is made, Cycle will run the restore command.
Deleting Backups
If a container is deleted all backups created for the container will be automatically removed as well.
To remove individual backup(s) from the list of backups for a given container:
- Navigate to the Backups page.
- Mark the checkbox on the backup(s) to be removed.
- Press the Delete Backup button.
Like infrastructure, backups should always be managed through the Cycle portal or API. Trying to manage backups from the Backblaze portal means that Cycle will have no record of a file change and the state of the edited or removed backups will be broken on the Cycle side resulting in a degraded user experience.