Backupper
Backupper is a tool to backup all your databases spread all over the world!
Installation
$ gem install backupper
Usage
$ backupper path/to/config.yml [options]
Configuration file
A common YAML config file for backupper looks like this:
mailer:
from: support@email.com # Gmail account used to send report email
to: pioz@email.com # Send report email to this address
password: Pa$$w0rD # Gmail account password
default: # options here are merged into all database configurations below
port: 22
db_username: backup
db1:
disabled: false # true to disable this backup
dump: '/home/backup/db1' # path where to save the dump of the database
extra_copy: '/mnt/backup-disk/backups/db1' # path where to save a extra copy of the dump
username: user # server ssh username
host: '1.2.3.4' # server ssh ip
port: 22 # server ssh port
password: Pa$$w0rD # server ssh password (also used as sudo password when sudo is true)
sudo: false # true to run the dump command with sudo
adapter: mysql # adapter to use to perform the backup (mysql, postgresql or mydumper)
database: db_name # database name
db_username: db_user # database username
db_password: db_Pa$$w0rD # database password
dump_options: '--single-transaction --quick' # dump command extra options (shell-style quoted or YAML array)
db2:
disabled: false
dump: '/home/backup/db2'
extra_copy: '/mnt/backup-disk/backups/db2'
username: user
host: '1.2.3.4'
port: 22
password: Pa$$w0rD
adapter: postgresql
database: db_name
db_username: db_user
db_password: db_Pa$$w0rD
After done all backups a report email is sent to you using gmail smtp service (remember to permit less secure app here).
⚠️ WARNING: the backupper configuration file contains many important passwords, so be careful to lock it and protect it with care!
To backup only specific databases you can pass the option -o db1,db3. In this way only databases under the key db1 and db3 will be backupped,
ignoring the others configuration keys.
Custom adapters
An adapter is just a module method of DumpCommand that returns the shell command used to dump the database:
def self.myadapter(database:, username: 'root', password: nil, dump_options: nil, working_dir: nil, outfile:)
return "mydump #{database} -u #{username} > #{outfile}"
end
All the values arrive already shell-escaped: interpolate them as they are, without wrapping them in quotes. dump_options is parsed as shell-style arguments, then each argument is escaped before it reaches the adapter. The command must write the dump to outfile; working_dir is an empty temporary directory you can use as scratch space (both are removed from the server after the download). If your adapter produces a file format different from .sql.bz2, add its extension to DumpCommand::EXTENSIONS.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/pioz/backupper.
Resources
- Blog post about Backupper (italian only).
License
The gem is available as open source under the terms of the MIT License.
About Uqido
Backupper is maintained and funded by Uqido. The names and logos for Uqido are trademarks of Uqido s.r.l.
The Uqido team.
