db_backup.rb
- backup one or more MySQL databases
db_backup.rb
database_name
db_backup.rb
-u username
-p password
database_name
db_backup.rb
-i
|--iteration
database_name
db_backup.rb is a simple command-line tool for backing up a MySQL database. It does so safely and quietly, using a sensible name for the backup files, so it's perfect for use with cron as a daily backup.
It also has knowledge of our development process, so you can indicate that
a backup is the canonical reference for an interation with the --iteration
flag. This will allow you to easily keep one backup per iteration, easily
identifying it, and differentiate it from daily backups.
By default, db_backup.rb
will use your database credentials
in ~/.my.cnf
, however, you can override either the username
or password (or both) via the -u
and -p
flags, respectively.
Finally, db_backup.rb
will add a sanity check on your username, to
make sure it fits with our corporate standard format of first.last
.
Since this command ultimately calls mysqldump
, if you omit
the username or password options, ~/.my.cnf
will be used
for credentials. When running from cron, this is most
likely not what you want to happen.
-i
, --iteration
-u USER
~/my.cnf
is not correct-p PASSWORD
~/my.cnf
is not correctBackup the database "big_client"
$ db_backup.rb big_client
Backup the database "small_client", for which different credentials are required:
$ db_backup.rb -u dave -p d4v3 small_client
Make an iteration backup of the "big_client" database:
$ db_backup.rb -i big_client