Sign inSign up

niclaslindstedt/docker-backup

By niclaslindstedt

•Updated over 5 years ago

Backup files in your Docker containers, Docker volumes or host system folders.

Image
0

2.6K

niclaslindstedt/docker-backup repository overview

⁠Docker Backup

Docker Pulls GitHub Repo stars GitHub Issues Tests Release

Backup your Docker volumes and/or data folders and store them both short-term and long-term. Prune unwanted backups according to precise pruning settings, or when free space gets tight.

CAUTION: Do not use this for production environments. It has not been thorougly tested yet.

The tag versions might be outdated, but follow the SemVer specification and are updated on every new commit containing features or fixes to the running code.

⁠Features

  • Backup any Docker volume, container folder or host folder by mounting it.
  • Easily restore backups with one command.
  • Encrypt your backups with GnuPG for safe storage in the cloud.
  • Verify your backups' integrity with sfv checksums and gpg signatures.
  • Cron scheduling for precise backup schedules.
  • Notifications through Slack or Discord when backups are taken.
  • Pause your other Docker containers during backup/restoration to prevent invalid states
    • Note: This is only supported on the -docker tagged images.

⁠Instructions

  1. Mount all volumes you want backed up in /volumes
  2. Mount the short-term backup location in /backup
  3. Mount the long-term storage location in /lts

See the Use cases wiki page⁠ for more advanced use cases.

⁠Getting help

See the Frequently asked questions wiki page⁠ for a list of common questions.

Ask questions in the Discussions⁠ section if your question hasn't been answered in the FAQ.

⁠Environment variables

VariableDefaultDescription
ENABLE_LTStrueSet to 'false' to disable long-term storage.
ENABLE_PRUNEtrueSet to 'false' to disable purging of old backups.
CRON_BACKUP0 5 * * *Cron schedule for creating backups of all volumes.
CRON_LTS0 9 * * *Cron schedule for copying backups to the long-term storage folder.
CRON_PRUNE0 3 * * *Cron schedule for pruning backups.
LOG_LEVEL2Set to a value between 0-5, where 5 is the most verbose.
ARCHIVE_TYPEtgzUse this archive type for storage, one of: tgz zip rar 7z
ENCRYPT_ARCHIVESfalseEncrypt archives after compressing them.
ENCRYPTION_PASSPHRASESet a passphrase (symmetric key) to encrypt (and decrypt) files with.
ENCRYPTION_ALGORITHMAES256The encryption algorithm used when encrypting backups, one of: IDEA CAST5 BLOWFISH AES256 TWOFISH CAMELLIA256.
VERIFY_ENCRYPTIONfalseVerifies that the encryption was successful by decrypting and verifying the sfv checksum.
CREATE_CHECKSUMStrueSet to 'false' to disable creation of checksums (sfv).
VERIFY_CHECKSUMStrueSet to 'false' to disable checksum (sfv) verification before restoring a backup and after copying a backup to long-term storage.
CREATE_SIGNATURESfalseSet to 'true' to enable creating signatures of checksums.
VERIFY_SIGNATURESfalseSet to 'true' to enable checksum signature verification.
SIGNING_KEYsigning_key.ascThe name of the key that is either imported or generated on startup.
SIGNING_PASSPHRASEThe passphrase used to import an existing key or generate a new key on startup.
GENERATE_GPG_KEYfalseSet to 'true' to generate a GPG key (for signatures) on startup.
GPG_KEY_NAMEdocker-backupThe name used when generating a new GPG key.
GPG_KEY_EMAIL[email protected]The e-mail used when generating a new GPG key.
GPG_KEY_LENGTH2048The length of the DSA key when generating a new GPG key. Either 2048 or 4096.
VERIFY_SIGNATURESfalseSet to 'true' to enable checksum signature verification.
SKIP_PASSPHRASE_LENGTH_CHECKfalseSkips the passphrase length control on startup. Don't use this in production environments.
KEEP_BACKUPS_FOR_DAYS30Set to how many days you want to keep backups in the short-term backup folder.
KEEP_LTS_FOR_MONTHS6Set to how long you want to keep long-term storage backups.
KEEP_DAILY_AFTER_HOURS24The breakpoint (in hours) for when hourly backups turn into daily.
KEEP_WEEKLY_AFTER_DAYS14The breakpoint (in days) for when daily backups turn into weekly.
KEEP_MONTHLY_AFTER_WEEKS4The breakpoint (in weeks) for when weekly backups turn into monthly.
MINIMUM_FREE_SPACE30Set to how many gigabytes of storage you want to keep free.
LOCK_TIMEOUT600How long the scripts should wait for other scripts to finish before giving up.
PROJECT_NAMEThe name of the project folder (used for naming containers with docker-compose).
PAUSE_CONTAINERSThe names of the containers that should be stopped before backing up & restoring. Comma-separated list.
TZUTCThe timezone used for setting timestamps (and comparing times) on backups.

See the Environment variables wiki page⁠ for a full list of environment variables, and more information about them.

⁠Commands

You can use docker-compose exec backup <command> to run the following commands inside the container:

CommandDescription
backup [volume]Creates backups of all (or specific) volumes.
store [volume]Copies the latest backups to the long-term storage location.
prune [volume]Prunes old backups to save disk space.
restore [volume | backup]Restores volumes to their latest (or a specific) backup.

See the Commands wiki page⁠ for a full list of commands, and more information about them.

⁠Contributing

Submit a pull request⁠! See the Development wiki page⁠ for information on how to get started with development.

If you're not a developer, you are more than welcome to submit an issue⁠ with a feature request or bug report.

Tag summary

Content type

Image

Digest

Size

36.1 MB

Last updated

over 5 years ago

docker pull niclaslindstedt/docker-backup