Sign inSign up

robbj/mysql-local-backup

By robbj

Updated over 6 years ago

Regularly backup a mysql database to a local drive

Image
0

471

robbj/mysql-local-backup repository overview

Local Mysql Backup

Regularly run a mysqldump of your database to a local drive using this handy docker image. Setup with robb-j/node-base.

Sample Usage

docker run -it --rm \
  -e SQL_HOST=mysql \
  -e SQL_USER="root" \
  -e SQL_PASS="secret" \
  -e SCHEDULE="* * * * *" \
  -v "/my_massive_drive:/data" \
  --link mysql \
  -p 8080:80 \
  robb-j/mysql-local-backup
or
backup:
  image: robb-j/mysql-local-backup
  restart: unless-stopped
  environment:
    SCHEDULE: 20 4 5 * *
  env_file:
    - secrets.env
  volumes:
    - ./my_massive_drive:/data
  ports:
    - 8080:80

Where secrets.env has SQL_HOST, SQL_USER & SQL_PASS in it

Variables

NameUsage
SQL_HOSTThe hostname of your mysql container
SQL_USERThe username of your mysql user
SQL_PASSThe password of your mysql user
SCHEDULEThe cron to run the backup on

Dev Commands


# Build & publish the image (from node-9:alpine)
# -> uses REGISTRY file & the npm version to tag image
npm run push-image

# Update version (builds & pushes a new docker image)
npm version ... # --help

# Lint the web & test directories
npm run lint

# Run the unit tests
npm test

# Generate coverage
npm run coverage          # outputs to coverage/
npm run coverage-summary  # outputs to terminal

# Watch code with nodemon (restarts on file changes)
npm run watch

Tag summary

Content type

Image

Digest

Size

29.6 MB

Last updated

over 8 years ago

docker pull robbj/mysql-local-backup