Skip to main content

Database backup utility

Project description


Github Status

Tool to backup databases.


pip install --upgrade backups


$ backups --help
Backups mysql databases

  backups env
  backups ls                    [--file FILE] [--verbose]
  backups show JOB              [--file FILE] [--verbose]
  backups databases JOB         [--file FILE] [--verbose]
  backups run JOB               [--file FILE] [--verbose] [--dryrun]
  backups run JOB [DATABASE]    [--file FILE] [--verbose] [--dryrun]

  env         Show the current environment
  ls          Prints the backup job names
  show        Prints the configuration for a job
  databases   Lists all databases on a backup job server
  run         Runs the backup for a job

  -f --file FILE    The backups config file (default /etc/backups/backups.yaml)
  -d --dryrun       Just prints the commands but doesn't execute them
  -v --verbose      Adds verbosity
  -h --help         Prints this help
     --version      Prints the current version

Environment variables:
  BACKUPS_FILE          The backups file (default /etc/backups/backups.yaml)
  BACKUPS_DUMPS_DIR     The dumps directory (default /tmp/backups)
  BACKUPS_MYSQLDUMP     The mysqldump binary (default picked from $PATH)
  BACKUPS_STDERR        The stderr log file (default /tmp/backups.err)

Check for more info


Create a backups.yaml file with content similar to:

        type:     mysql
        host:     !Env ${}
        username: !Env ${BACKUPS_DB_USERNAME:backup}
        password: !Env ${BACKUPS_DB_PASSWORD}
        # Dumps the entire server into a single file (this is the default)
        server: true
        # By default it will create a single dump file for each database found
        # Uncomment to only backups specific databases (one on each file)
        # databases:
        # - main_db
        # - other_db
      - type:     zip
        pasword:  !Env ${BACKUPS_ZIP_PASSWORD}
      - type:     s3
        bucket:   acme-backups
        prefix:   databases
        enabled:  true
      - type:     slack
        channel:  "#backups"
        webhook:  !Env ${BACKUPS_SLACK_WEBHOOK:}

Notice the use of the environment variables, like BACKUPS_DB_HOST, used in combination with the !Env yaml resolver. If they exist they get resolved to their values. Use the format ${VAR_NAME:default_value} to use default_value if $VAR_NAME is not defined.

Now run it with

backups run acme --file backups.yaml

You can use the BACKUPS_FILE env var instead:

export BACKUPS_FILE=backups.yaml
backups run acme

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for backups, version 0.3.7
Filename, size File type Python version Upload date Hashes
Filename, size backups-0.3.7.tar.gz (9.9 kB) File type Source Python version None Upload date Hashes View
Filename, size backups-0.3.7-py2.py3-none-any.whl (11.9 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page