Skip to content

abiddiscombe/ctrs-backup-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ctrs-backup-script

A script for backing-up persistent Docker container data.

This script is written for use with Docker on Ubuntu Server hosts. Containers should store permanent data on disk via system bind mounts. The script:

  1. Stops all active containers.
  2. Creates a backup of the data directories.
  3. Restarts all previously stopped containers.
  4. Calls to a machine-specific rclone config to create an offsite backup. I recommend an S3 provider wrapped in the crypt utility.

To protect data integrity all containers are stopped and then restarted. This results in a short outage period and so it is best to schedule this script to run during a quieter time period.

Note
When working with databases, it is generally more reliable to use a purpose-built backup tool (e.g. pgdump for PostgreSQL) to perform data backups.

Filesystem Structure

This script expects the following file structure on disk. The /var/ctrs* directories should belong to the Docker service user (which is usually root).

The backup.sh script and a sample backup.env file are provided in this repository.

/var/ctrs/
    backup.sh
    backup.env
    /mounts/
        container_name/
            bind_mount_a/
            bind_mount_b/
    stacks/
        container_name/
            .env
            compose.yaml
    dockge/ (only if using)
/var/ctrs-backup/
    ctrs-YYMMDD-hhmm.tar.gz (illustrative)

About

A script for backing-up persistent Docker container data.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages