Sign inSign up

swexbe/bagop

By swexbe

Updated over 4 years ago

Docker database backup utility

Image
2

470

swexbe/bagop repository overview

bagop

Go Report Card License: AGPL v3 Docker Cloud Build Status Docker Image Version (latest by date)

Tool to make automatic backups of any number of docker database containers to AWS Glacier

Getting Started

Example run command:

docker run -e BAGOP_VAULT_NAME=myvaultname
    -e AWS_DEFAULT_REGION=myregion
    -e AWS_SECRET_ACCESS_KEY=mysecretaccesskey
    -e AWS_ACCESS_KEY_ID=myaccesskeyid
    -e CRON="0 4 * * 7"
    -e BAGOP_TTL=90
    -v /var/run/docker.sock:/var/run/docker.sock
    -d swexbe/bagop:latest
  • NOTE: CRON must be a valid cron time/date field
  • Set the labels bagop.enable=true and bagop.name=dbname for any dn containers you wish to automatically backup

Configuration

How to configure bagop.

Environment Variables for bagop Container

The application is configured through environment variables.

KeyRequiredDescriptionExample
AWS_REGIONyesThe AWS region in which your vault is locatedus-east-1
AWS_SECRET_ACCESS_KEYyesYour AWS secret access keysecret
AWS_ACCESS_KEY_IDyesYour AWS access key idsecret
CRONyesHow often to run regular backups, accepts any valid CRON expression.0 4 * * *
LT_CRONnoHow often to run long-term backups, accepts any valid CRON expression. If not set, no long-term backups will be made.0 4 * * 7
BAGOP_VAULT_NAMEyesThe name of your AWS Glacier Vaulttestvault
BAGOP_TTLnoTime to Live for regular backups (in days). If not set, backups will never expire.90
BAGOP_LT_TTLnoTime to Live for long-term backups (in days) If not set, backups will never expire.365
BAGOP_VERBOSEnoRun i verbose mode. Defaults to false.false
BAGOP_COLORnoRun with color output. Defaults to true.true

With the above example values set, backups will be made every day at 04:00. A long-term backup will be made every sunday at 04:00. Regular backups will be deleted the next time bagop runs after 90 days. Long-term backups will be deleted after 365 days.

Additional environment variables for configuring the connection to AWS and Docker are also available. Documentation for these can be found in Docker Go SDK docs and AWS for Go docs.

Labels for Database Containers

To configure backups for an individual container, the following docker labels can be set:

KeyRequiredDescription
bagop.enableyesEnable bagop for this container if set to true
bagop.namenoThe name of the resulting .sql file for this container, will use docker id if not set
bagop.vendornocan be set to postgres or mysql. Overrides vendor detection and forces bagop to treat the container as the given vendor
Volumes

The following directories can be mounted on the filesystem:

DirectoryDescription
/extraAnything mounted in this directory will be added to each backup
/var/bagopPersistent data will be stored in this directory, i.e. Glacier archive IDs and their expiration
Input Parameters

Manual backups can be run using docker exec or interactive shell. The following input parameters are available:

FlagDescription
-vVerbose mode
-bMake a backup
-cDelete expired containers from Glacier
-lList all non-expired containers
-ttl=Time to Live for backup in days. If not set, backup will never expire.
-versionDisplay version
-force-colorForce color output

Retrieving An Archive

  1. Run bagop -l inside the container and pick out an archive to retrieve. This can be done using docker exec my_bagop_container "bagop -l".
  2. Follow the AWS Glacier CLI Documentation for retrieving an archive starting from step 1b.

Contributions

Would be appreciated

Tag summary

Content type

Image

Digest

Size

12.5 MB

Last updated

over 4 years ago

docker pull swexbe/bagop