Git Product home page Git Product logo

docker-mysql-backup-cron's Introduction

This Image

A cron job runs every 8 hours. Override this by setting cron job spec's in the CRON_D_BACKUP environment variable.

It backups all databases, unless DBS is specified as a space separated list of DB's to backup, using mysqldump.
The file are gziped and uploaded to S3 via s3cmd.

The DB will be connected to as root and requires $MYSQL_ROOT_PASSWORD be set from the linked DB container.

You must specify an AWS access key and secret key as well as the S3 bucket and optionally the prefix to store the backups in.

You must specify the bucket (and prefix) with the s3: scheme and trailing slash; e.g. s3://some-bucket/ or s3://some-bucket/some-prefix/.

By default, the S3 region used is us-east-1. You can override it with the REGION environment variable. See the official amazon region names for more informations.

See docker-compose.yml for an example of configuration.

Usage

Use docker exec <container> /backup.sh to take an immediate backup.

Use docker exec <container> /restore.sh to list available backups to restore from. Then docker exec /restore.sh <filename of backup> to restore it.

docker-mysql-backup-cron's People

Contributors

clescot avatar nickbreen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

docker-mysql-backup-cron's Issues

DockerFile is not complete

Hi,
it seems backup.sh and restore.sh are not part of the DockerFile, nor the crontab is in place.

can you update your project?

best regards,

Charles.

backup.sh and restore.sh are not consistent about S3 bucket name

Hi,
/backup.sh works like a charm.
but when i want to list available backups via the /restore.sh command,
an error occurs :

ERROR: Bucket 's3:' does not exist
ERROR: S3 error: 404 (NoSuchBucket): The specified bucket does not exist

according to this line https://github.com/nickbreen/docker-mysql-backup-cron/blob/master/restore.sh#L14 , BUCKET should not start with 's3://' prefix, but this is required by the backup.sh command.
When i remove from the BUCKET variable the s3:// prefix, it lists available backups successfully, but further backups fail.
best regards,
Charles.

please add license information

I forked your project in order to modify it for my purpose. Can you please add license information so that I can show it on my project?

restoring database fails

Hi,
restoring database fails.

now sudo docker exec <docker_container_id> /backup.sh and sudo docker exec <docker_container_id> /restore.sh works, but
sudo docker exec <docker_container_id> /restore.sh <filename> returns
ERROR: S3 error: 400 (Bad Request)
i've tried with or without the 's3://' prefix, but error is the same.

best regards,

Charles.

Next version: simplify down and use .s3cfg

It's easier to just use .s3cfg rather than fiddling with all the env vars.

E.g. this actually works!

  environment:
    S3_CFG: |
      [default]
      access_key = XXXX
      secret_key = XXXX
      bucket_location = ap-southeast-2
      default_mime_type = application/x-gzip
    CRON_D_BACKUP: |
      @reboot root ln -s /etc/container_environment/S3_CFG /root/.s3cfg

      @daily root (tar cz --verbose /var/www/wp-content/uploads | /usr/local/bin/s3cmd --verbose put - $$(cat /etc/container_environment/BUCKET)uploads.tar.gz) 2>&1 | logger --tag uploads

      @daily root (/usr/bin/mysqldump -uwordpress -pwordpress -hdb -B wordpress | gzip | /usr/local/bin/s3cmd --verbose put - $$(cat /etc/container_environment/BUCKET)db.tar.gz) 2>&1 | logger --tag db

There's a @reboot job that sets up the user's .s3cfg file, which all the other jobs use.

This allows for far simpler cron job spec's and permits trivial specification of arbitrary jobs and arguments.

cron expression does not seems to work

Hi,
i've tried to override the cron expression CRON_D_BACKUP with this expression :
CRON_D_BACKUP: "* * * * * root /backup.sh | logger",
but it does not seems to work....
I don't see any reference of CRON_D_BACKUP on the project, except in the Dockerfile.
How does the cron expression is set to the system?

best regards,

Charles.

s3cmd doesn't actually work.

The packaged version is 1.1 and 1.6 is the current version - with the required command line parameters to specify the access key and secret

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.