Backup, encrypt and restore service for SQL DB (PostreSQL, MySQL, Gunzip, OpenSSL, 7z)
10K+
Docker alpine image for CRON SQL dumps, encryption and restore.
Database engine: PostreSQL or MySQL
Encryption type: OpenSSL + Gzip, or 7zip (recommended for Windows users)
Backups are stored in the container in "/backups". There are 3 levels of backup, each of them stored in their respective directory "L#" (e.g.: /backups/L1).
All of these backups have their own schedule using a CRON expression, and level 2 and 3 have their own maximum of backup files to keep.
For example, level 1 could be set to every half an hour, level 2 to every day with a max of 30 (1 month), and level 3 every month with a max of 36 (3 years).
File name pattern:
The L1 backup is simply called "backup" followed by the extension (or ".gz.enc" or "7z").
L2 and L3 backups begin by the date/time of the backup , then the level, "backup" and the extension (e.g.: 201801122355.l2.backup.gz.enc for a level 2 backup made the 12 January 2018 at 23:55, and encrypted using openssl)
A template for the environment variables is included in this github folder "env.template". If a CRON time for a specific level is not specified, the backup will not be executed.
Two main functionalities are available. The corresponding scripts are located in "/backncrypt" as is the work directory.
set.sh
This script will use the environment variables provided to create the cron jobs and activate them.
restore.sh
The restore script use the same settings as above: the encryption type, password, database settings should be the same.
It can be used through the host as follow:
docker exec {{container_name}} ./restore.sh {{backup_file}}
And replace {{container_name}} with the name of the backNcrypt container running, and {{backup_file}} by the path in the container of the encrypted backup you want to restore.
Add it to your docker-compose stack - you can pass the env variables in .env.
Content type
Image
Digest
Size
17.7 MB
Last updated
about 7 years ago
Requires Docker Desktop 4.37.1 or later.