Quick, lean and modular backup system, implemented in Bash.
Inspired by the pretty successful and famous backup gem, but disappointed by the tremendous amount of dependencies needed to install (250mb!!) I've decided it's time to create a modular backup system without all the clutter and overhead that ruby features. I present you the backup rock, in contrast to a (ruby) gem.
In addition to that - the backup rock also features a restore mode. By reversing the operations we perform to backup, we can restore things easily from a backup.
The backup rock is a simple and linear backup system, it performs a 4 step backup:
- log - Not really a step, but defines loggers that will be loaded
- backup - Actual backup, dumping of DBs, creating archive, etc.
- process - Encryption, compression
- store - Store the backup, perhaps in multiple locations
- notify - Notifies the status of the backup
When performing a restore, the steps are almost reversed:
- log - Loading loggers
- store - Find a backup we can restore from
- process - Decryption, decompression
- backup - Performs a restore, rather than a backup
- notify - Same, just notifies
Each of these steps is modular and the user is encouraged to add more plugins as he/she sees fit.
In order to perform a backup with the backup rock, you will need to write a
model file. The model file models how backup and restore should be carried out.
A simple model file to backup /etc/shadow
into /var/backups
will look like
that:
backup() {
rsync shadow /etc/shadow
}
store() {
cp /var/backups
}
Backup a MySQL and PgSQL database to /var/backups
:
backup() {
pgsql db_name localhost:5432:db_name:username:password
mysql db_name localhost:3306:db_name:username:password
}
store() {
cp /var/backups
}
Please have a look at some more examples under models.
- log
- backup
- process
- store
- notify
- email - Notify via email, using mailx
- pushover - Notify via pushover
- nagios_nsca - Notify via Nagios NSCA
- nagios_status - Writes status to file in Nagios format
Simplicty is key. To backup, run:
$ ./backup -m model_file
And to restore:
$ ./backup -r -m model_file