Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ Simple docker image to facilitate backup creation, encryption & upload.

| Env var | default | possible values | description |
|---------------------------| --------------------| ----------------| ----------------------|
| BACKUP_COMPRESS | true | | compress backup files |
| BACKUP_COMPRESS_FORMAT | gz | gz, bz2, zip | compression format |
| BACKUP_ENCRYPT | false | | encrypt the backup files |
| BACKUP_ENCRYPT_KEY | | | valid pgp public key |
| BACKUP_ENCRYPT_RECIPIENT | | | email address associated with the public key |
| BACKUP_DB | false | | export and backup a database |
| BACKUP_DB_DRIVER | | mysql, postgres | database engine |
| BACKUP_DB_HOST | | | db hostname |
| BACKUP_DB_USER | | | db user |
| BACKUP_DB_PASSWORD | | | db password |
| BACKUP_DB_DATABASE | | | db name |
| BACKUP_DB_EXTRA_ARGS | | | extra args to provide to pg_dump/mysqldump |
| BACKUP_DATE_FORMAT | +%Y-%m-%d-%H:%M:%S" | `date` format | format to use for dates |
| BACKUP_PREFIX | {{DATE}}-" | | prefix to use for backup files |
| BACKUP_UPLOAD | false | | upload the backups somewhere |
| BACKUP_UPLOAD_METHOD | | gs, s3 | type of destination |
| BACKUP_UPLOAD_GS_KEY_FILE | | | path to gcloud key | |
| BACKUP_UPLOAD_GS_PATH | | | destination path (gs://bucket/subfolder/) |
| BACKUP_UPLOAD_S3_SECRET_ACCESS_KEY | | | secret key for S3 |
| BACKUP_UPLOAD_S3_ACCESS_KEY_ID | | | access key for S3 |
| BACKUP_UPLOAD_S3_REGION | | | AWS region for S3 |
| BACKUP_UPLOAD_S3_PATH | | | S3 path to store the backup into |
| BACKUP_UPLOAD_S3_ENDPOINT | "" | | S3 endpoint, __ONLY__ for not AWS |
| BACKUP_COMPRESS | true | | compress backup files |
| BACKUP_COMPRESS_FORMAT | gz | gz, bz2, zip | compression format |
| BACKUP_ENCRYPT | false | | encrypt the backup files |
| BACKUP_ENCRYPT_KEY | | | valid pgp public key |
| BACKUP_ENCRYPT_RECIPIENT | | | email address associated with the public key |
| BACKUP_DB | false | | export and backup a database |
| BACKUP_DB_DRIVER | | mysql, postgres, mariadb | database engine |
| BACKUP_DB_HOST | | | db hostname |
| BACKUP_DB_USER | | | db user |
| BACKUP_DB_PASSWORD | | | db password |
| BACKUP_DB_DATABASE | | | db name |
| BACKUP_DB_EXTRA_ARGS | | | extra args to provide to pg_dump/mysqldump |
| BACKUP_DATE_FORMAT | +%Y-%m-%d-%H:%M:%S" | `date` format | format to use for dates |
| BACKUP_PREFIX | {{DATE}}-" | | prefix to use for backup files |
| BACKUP_UPLOAD | false | | upload the backups somewhere |
| BACKUP_UPLOAD_METHOD | | gs, s3 | type of destination |
| BACKUP_UPLOAD_GS_KEY_FILE | | | path to gcloud key | |
| BACKUP_UPLOAD_GS_PATH | | | destination path (gs://bucket/subfolder/) |
| BACKUP_UPLOAD_S3_SECRET_ACCESS_KEY | | | secret key for S3 |
| BACKUP_UPLOAD_S3_ACCESS_KEY_ID | | | access key for S3 |
| BACKUP_UPLOAD_S3_REGION | | | AWS region for S3 |
| BACKUP_UPLOAD_S3_PATH | | | S3 path to store the backup into |
| BACKUP_UPLOAD_S3_ENDPOINT | "" | | S3 endpoint, __ONLY__ for not AWS |

## Examples

Expand Down
14 changes: 14 additions & 0 deletions files/backup_scripts/db_backups_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ backup_db(){
backup_postgres
elif [ "$BACKUP_DB_DRIVER" == "mysql" ]; then
backup_mysql
elif [ "$BACKUP_DB_DRIVER" == "mariadb" ]; then
backup_mariadb
else
die "BACKUP_DB_DRIVER not set"
fi
Expand Down Expand Up @@ -51,3 +53,15 @@ backup_mysql(){

handle_backup_file /tmp/db-backup.sql
}

backup_mariadb(){
echo "Backuping mariadb: $BACKUP_DB_USER@$BACKUP_DB_HOST/$BACKUP_DB_DATABASE"
check_db_params
mariadb-dump -u "$BACKUP_DB_USER" \
--password="$BACKUP_DB_PASSWORD" \
-h "$BACKUP_DB_HOST" \
$BACKUP_DB_EXTRA_ARGS \
"$BACKUP_DB_DATABASE" > /tmp/db-backup.sql

handle_backup_file /tmp/db-backup.sql
}