Skip to content

Latest commit

 

History

History
105 lines (88 loc) · 3.56 KB

README.md

File metadata and controls

105 lines (88 loc) · 3.56 KB

backup rock

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.

High Level Design

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.

Backup Models

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.

Plugins

  • log
    • logfile - Simple log file logging
    • syslog - Logging to syslog via '/bin/logger'
  • backup
    • execute - Execute any shell command
    • mysql - MySQL database backup
    • pgsql - PostgreSQL database backup
    • rsync - Pull files using rsync
    • tar - Create tar archives
  • process
    • gpg - GPG encryption
    • bzip2 - bzip2 compression
    • gzip - gzip compression
    • xz - xz compression
    • split - Splitting files into smaller ones
  • store
    • cp - Store backup locally with cp
    • mv - Store backup locally with mv (faster than cp)
    • scp - Store backup remotely using scp
    • cycle - Used to cycle backups
    • s3 - Store backups on Amazon S3
    • s3_cycle - Used to cycle backups on Amazon S3
  • notify

Usage

Simplicty is key. To backup, run:

$ ./backup -m model_file

And to restore:

$ ./backup -r -m model_file