Install backup gem
$ gem install backup
Generate Backup files see doc for genrate's options
backup generate:model --trigger my_backup --databases="mysql" --storages='s3' --compressor='gzip' --notifiers='mail'
Architecture:
Backup
| - config.rb
- log
- models
| - my_backup.rb
Set infos in Backup/models/my_backup.rb
Model.new(:my_backup, 'Description for my_backup') do
##
# MySQL [Database]
#
database MySQL do |db|
# To dump all databases, set `db.name = :all` (or leave blank)
db.name = "name"
db.username = "name"
db.password = "*************"
db.host = "localhost"
db.port = 3306
db.socket = "/var/run/mysqld/mysqld.sock"
db.additional_options = ["--single-transaction"]
end
##
# Amazon Simple Storage Service [Storage]
#
store_with S3 do |s3|
# AWS Credentials
s3.access_key_id = "my_access_key_id"
s3.secret_access_key = "my_secret_access_key"
# Or, to use a IAM Profile:
# s3.use_iam_profile = true
s3.region = "us-east-1"
s3.bucket = "bucket-name"
s3.path = "path/to/backups"
end
##
# Gzip [Compressor]
#
compress_with Gzip
##
# Split [Splitter]
#
split_into_chunks_of 250
end
If you want to set options by default, you can in Backup/config.rb
Check backup files
$ backup check
Perform Backup
$ backup perform --trigger my_backup
Install whenever gem
$ gem install whenever
Generate files
$ mkdir config
$ wheneverize
Config tasks in Backup/config/schedule.rb
every 1.day, :at => '4:30 am' do
command "backup perform -t my_backup"
end
Update crontab
$ whenever --update-crontab