Container Backups

Stateful containers can be configured to run automated backups.

How Container Backups Work

Cycle takes a unique approach to backups. Given the nature of the platform is to be able to run anything that can be containerized, assuming knowledge about how something should be backed up is dangerous. Doing a basic volume snapshot could be detrimental if a database was in the middle of a write operation.

To overcome this barrier, Cycle instead puts the power in the container's hands. The container specifies WHAT command to run, and Cycle will automate running that command regularly, capturing the output, and packaging it up to an object storage integration.

With this approach, a container outputs anything it wants to stdout, and Cycle will capture it and back it up. This flexibility allows for an application to define how its backups should function. After all, a database will know far better how to back itself up (using a tool like mysqldump) far better than Cycle would guess doing blind snapshots.

Restoring Backups

Restoring backups is essentially the same process, but in reverse. The contents of the target backup are fetched from object storage and fed to a user-specified command via stdin.

Instances will not be restarted during a restoration.

Example Backup Commands

We've put together some common one-liners for popular stateful applications typically run on Cycle.

Double Quotes

It is important to copy the double quotes when using these commands - they allow the usage of environment variables when the script executes.

MySQL Example

OperationCommand
Backup"mysqldump --all-databases -u root -p$MYSQL_ROOT_PASSWORD"
Restore"mysql -u root -p $MYSQL_ROOT_PASSWORD < /dev/stdin"

PostgreSQL Example

OperationCommand
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

OperationCommand
Backup"mongodump --archive -u $USERNAME -p $PASSWORD"
Restore"mongorestore --archive -u $USERNAME -p $PASSWORD"

Tar Example

OperationCommand
Backup"tar czf /dev/stdout -C /var/lib/test backup"
Restore"tar xzf /dev/stdin -C /var/lib/test"

Enable Container Backups

To enable backups for a container on Cycle, follow this guide: