A simple Docker image to periodically backup directories on my server.
Go to file
2021-05-18 22:19:11 +00:00
backup.sh initial commit 2021-05-18 21:38:52 +00:00
Dockerfile initial commit 2021-05-18 21:38:52 +00:00
entry.sh initial commit 2021-05-18 21:38:52 +00:00
README.md added link to blog post 2021-05-18 22:19:11 +00:00

Server backup

This Docker image contains a simple script and a cron job to automate backups to Backblaze B2 (or other S3-compatible storage solutions). For example, to periodically backup directories on a VPS.

The container needs to be able to mount a volume that is as least as high as the most common path ancestor amongst your target backup directories. For example, all of my directories to backup are contained inside ~/myusername and so I use that as the volume mount below.

Building the image

Once the repo has been cloned locally, simply run docker build -t backup . to build the image.

Running the image container

Pass the required environment variables to the container to run it. For example:

docker run -d --restart always \
  -v "/home/myusername:/backup" \
  -e "BUCKET=<B2 BUCKET NAME>" \
  -e "ENDPOINT=https://s3.eu-central-003.backblazeb2.com" \
  -e "AWS_ACCESS_KEY_ID=<B2 keyID>" \
  -e "AWS_SECRET_ACCESS_KEY=<B2 applicationKey>" \
  -e "BACKUP_DIRS=folder1 folder2 folder3" \
  backup:latest

More information

Please see this blog post for more information.