Skip to content

GoodRequest/BackupBuddy

Repository files navigation

GoodRequest, s.r.o.Backup Buddy

dockeri.co

Simple Bash app for backing up your precious data made with love 🫶


Currently supported features

🤔 WHAT to backup ?

1. PostgreSQL, MongoDB, MySQL - If you choose this option, don't forget to provide connection details. Also make sure your database is reachable from within this container.

2. Filesystem directory - If you choose this option, don't forget to attach volume to this container, so Backup Buddy can access these files.

📍 WHERE to backup ?

1. AWS S3 Bucket - If you choose this option, you'll have to create custom IAM User (generate access keys) and S3 Bucket (add bucket policy).

2. Filesystem - If you choose this option don't forget to attach volume to your container, so backups are stored on physical disk and are persistent.

📊 Monitoring

If you want to make sure that backups are being correctly created, consider using monitoring tool such as Uptime Robot. You can then pass generated URL into the Backup Buddy through HEARTBEAT_URL env variable, where it will be pinged each time a non-zero size (not corrupted) backup is created. This way you can be easily alerted if backups are not being created.

🗂️ Compression

To achieve smallest size possible, Backup Buddy uses compression so your backups don't bloat out your disk.

🔧 Custom pg_dump options

If you want to pass custom options into the pg_dump command, you can easily do so by using the PG_DUMP_CUSTOM_OPTIONS env variable. Just make sure that you know what you are doing, since in this case we trust your input (no sanitization is at play here).

📝 Debug logging

If you want to make sure you container has been set-up and/or is working properly, enable debug logging. This will print logs into stdout during setup phase (installation of required packages) and into the file on path you specified in LOG_DIR during the run phase (worker runs triggered by cron rule).


A (Very) Quick Start

Deploy the app in a Docker Compose stack with environment variables satisfying your needs.

Once deployed, app will setup its worker and will start the backuping process within its next cron run.


Database Dump-Restore pairs

PostgreSQL PostgreSQL

pg_dump -U <username> -h <host> -p <port> -d <database> -f <dump file> -O -x -Fc
pg_restore -U <username> -h <host> -p <port> -d <database> <dump file> -O -c -v -x -j <number of threads>

MongoDB MongoDB

mongodump -h <host> -d <database> -u <username> -p <password> -o <destination>
mongorestore -h <host> -u <username> -p <password> --authenticationDatabase admin -d <database> <destination>/<database>

MySQL MySQL

mysqldump -h <host> -P <port> -u <username> <database> --result-file=<filename> --ssl-mode=disabled
mysql -h <host> -P <port> -u <username> <database> -p -v < <dump file>

Configuration

Configuration of tool can be done through ENV variables described in table below (there is also built in variable validator to prevent mistakes):

ENV Variable Required Description Example Default
TYPE Type of backup system (currently supported MONGO, POSTGRE, MYSQL, FILESYSTEM) MONGO
HOST URL or IP address of database (be sure you have allowed connection from container), also can be container name (if is ran in Rancher/Docker-Compose stack) postgresql.goodrequest.com
DATABASE Name of database goodrequest
USER User name for database postgres
PASSWORD User password for database UnitedLikeManchester123.
TARGET_DIR Absolute path to directory (mounted in Backup Buddy container) where backups will be stored /home/backup
FILESYSTEM_DIR Absolute path to directory (mounted in Backup Buddy container) which should be backed up /home/files
CRON_RULE Cron rule definition - when or how often will be created database backup (https://crontab.guru/) (in example each 8 hours) 0 */8 * * *
KEEP_DAYS How many days will be stored backups, older backups will be automatically removed 30
TARGET_TYPE Target for backups to be saved to (currently supported FILESYSTEM, AWS_S3) AWS_S3 FILESYSTEM
AWS_ACCESS_KEY_ID Access key ID for AWS S3 (required when TARGET_TYPE is set to AWS_S3) somerandomawsacceskey
AWS_SECRET_ACCESS_KEY Secret access key for AWS S3 (required when TARGET_TYPE is set to AWS_S3) somerandomawssecretaccesskey
AWS_REGION Region for AWS S3 (required when TARGET_TYPE is set to AWS_S3) eu-central-1
BUCKET_NAME Bucket name for AWS S3 (required when TARGET_TYPE is set to AWS_S3) test-bucket
PORT Target port of database container (Currently valid for POSTGRE only). 5432 5432
HEARTBEAT_URL URL for sending notification about successfully created backup (typically specialized monitoring tool like Uptime) https://example.com/somerandomlygeneratedpath
DEBUG_LOGGING Enables debug logging into console and log file true
LOG_DIR Directory for storing logs outputs from backup scripts /home/logs
PG_DUMP_CUSTOM_OPTIONS Custom options to pass into pg_dump command --schema-only

Additional Resources

DockerDocker documentation is available here.

BashBash documentation is available here.

PostgreSQLPostgreSQL documentation is available here.

MongoDBMongoDB documentation is available here.

MySQLMySQL documentation is available here.


License

Backup Buddy is released under the MIT license. See LICENSE.md for details.

About

Simple Bash app for backing up your database or filesystem data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published