Skip to content

Docker image for running duplicity in a cron

License

Notifications You must be signed in to change notification settings

tmorin/docker-image-duplicity

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-image-duplicity

Build Images

Docker Image Version (latest semver)

Docker Image Version (latest semver)

Docker Image Version (latest semver)

Docker Image Version (latest semver)

Docker Image Version (latest semver)

The projects build several images providing services based on Duplicity.

thibaultmorin/duplicity

Docker Hub: thibaultmorin/duplicity

This image bundles the Duplicity utility without additional targets.

The duplicity utility can be used directly:

docker run --rm thibaultmorin/duplicity --help

The docker image ships also a kind of task manager which help to execute operations (backup or restore) on many resources by container instance.

A task is identified by a taskId and is composed the following steps:

1. prepare: should be used to install stuff or to create directories ...
2. extract: should be used to extract the data
3. transform: should be used to transform the extracted data
4. load: should be used to call duplicity
5.1 succeed: called when all previous steps ended successfully
5.2 failed: called when one of the previous steps failed
6. finally: always called, it should be used to release resources, cleaning ...

A backup task is marked with the environment variable TASK_<taskId>_RESTORE. On the other side, a restore task is marked with the environment variable TASK_<taskId>_RESTORE. The value is the prefix of the task's file name. So that, the execution of tasks can be ordered.

The command execute-backup executes the restore tasks.

docker run --rm thibaultmorin/duplicity execute-backup

The command execute-restore executes the restore tasks.

docker run --rm thibaultmorin/duplicity execute-restore

Each task get two customized environment variables: $SRC and $DST. They locate two directory freshly cleaned at each execution. The directories can be used to store temporary resources between task's steps.

The available environment variables :

  • TASK_<taskId>_BACKUP
  • TASK_<taskId>_RESTORE
  • TASK_<taskId>_PREPARE
  • TASK_<taskId>_EXTRACT
  • TASK_<taskId>_TRANSFORM
  • TASK_<taskId>_LOAD
  • TASK_<taskId>_SUCCEED
  • TASK_<taskId>_FAILED
  • TASK_<taskId>_FINALLY

CRON tasks

  • TASK_<taskId>_CRONTAB
  • TASK_<taskId>_PERIODICITY

The backup tasks can be managed by a CRON service. The configuration can be done with a CRONTAB expression using the environment variable TASK_<taskId>_CRONTAB. A periodicity can also be used with the environment variable TASK_<taskId>_PERIODICITY. The accepted values are: 15m, hourly, daily, weekly and monthly.

To command crond starts the cron.

docker run --rm thibaultmorin/duplicity crond

Backup and restore a database dump

The purpose of the task is to backup the dump a database in /mnt/backup/database. Moreover, on the target, only the synchronizations done past two days.

The backup task:

  • TASK_<taskId>_BACKUP=1
  • TASK_<taskId>_PREPARE=mkdir -p /mnt/backup/database
  • TASK_<taskId>_EXTRACT=mysqldump --single-transaction -h localhost -u root -proot db_name > $SRC/nextcloud.back
  • TASK_<taskId>_LOAD=duplicity full $SRC file:///mnt/backup/database
  • TASK_<taskId>_SUCCEED=duplicity remove-older-than 2D --force file:///mnt/backup/database

The restore task

  • TASK_<taskId>_RESTORE=1
  • TASK_<taskId>_EXTRACT=duplicity restore --force file:///mnt/backup/database $DST
  • TASK_<taskId>_LOAD=mysql -h localhost -u root -proot db_name < $DST/nextcloud.back

thibaultmorin/duplicity-docker

Docker Hub: thibaultmorin/duplicity-docker

The image is based on thibaultmorin/duplicity and provides a Docker environment.

thibaultmorin/duplicity-mariadb

Docker Hub: thibaultmorin/duplicity-mariadb

The image is based on thibaultmorin/duplicity and provides a MariaDB client. Therefore, the image can be used to backup regularly dumps of MariaDB databases

thibaultmorin/duplicity-mysql

Docker Hub: thibaultmorin/duplicity-mysql

The image is based on thibaultmorin/duplicity and provides a MariaDB client. Therefore, the image can be used to backup regularly dumps of MariaDB databases

thibaultmorin/duplicity-postgres

Docker Hub: thibaultmorin/duplicity-postgres

The image is based on thibaultmorin/duplicity and provides a PostgreSQL client. Therefore, the image can be used to backup regularly dumps of PostgreSQL databases

Sponsor this project

Packages

No packages published

Languages

  • Python 55.1%
  • Shell 30.6%
  • Dockerfile 14.3%