As you know, people are divided into those who still do not make backups, those who already do, and those who already do and check the possibility of recovery
Fortunately, 20 minutes ago, when Curve
admin recipe Capistrano completely demolished on the "combat" server directory with downloaded images from articles of users, I already belonged to the category of doing backups. Here, at the same time and checked.
And we make backups via gem backup
')
We have about 20 user sites on cloud hosting on several servers, which we also developed plus one small, but proud (and heavy) application with VoIP, RTMP, J2ME
and geishas and a web admin. When a few months ago, the admin, when updating, deleted the Asterisk PBX configs and then with a shaking chin and blue lips, restored them from a running demon, it became clear that it would be too dangerous without further backups. But back-ups for 20 applications, each of which used its own database in MySQL with its usernames and passwords, were too uninteresting and boring. It would be a long-long bash script, which would have been
scored immediately after a successful launch
would have had to spend a lot of time to keep this script up-to-date.
This is where the backup gem came in handy.
Heme
backup does this:
- reads your config
- dump the specified databases (different DBMS supported) to the temporary directory
- Tariff specified directories to a temporary directory
- tight all
- encrypts all
- puts on a remote server via FTP, SCP, RSync and others
- maintains cyclical storage
- writing me a letter
You just need to do three simple things:
1. Install gem (gem install backup)
2. Write the config (by default, the executable file of the gem searches for the config in the ~ / Backup / config.rb directory, you can change this with additional options). An example config for one of our sites:
Backup::Model.new(:kodepru, 'kodepru_backup') do
archive :my_archive do |archive|
archive.add '/path/to/dir/www.kodep.ru'
end
database MySQL do |db|
db.name = "wwwkodepru_production"
db.username = "user"
db.password = "password"
db.host = "mysql.local"
db.port = 3306
db.additional_options = ['--quick', '--single-transaction']
end
store_with SCP do |server|
server.username = 'backup'
server.password = 'verydifficultpassword'
server.ip = 'backup.local'
server.port = 22
server.path = '~/www.kodep.ru/'
server.keep = 14
end
compress_with Gzip do |compression|
compression.best = true
compression.fast = false
end
notify_by Mail do |mail|
mail.on_success = true
mail.on_failure = true
mail.from = 'backup@kodep.ru'
mail.to = 'sysadmin@kodep.ru'
mail.address = 'smtp.kodep.ru'
mail.port = 25
mail.domain = 'kodep.ru'
mail.user_name = 'backup@kodep.ru'
mail.password = 'password_ot_pochty'
mail.authentication = 'plain'
mail.enable_starttls_auto = true
end
end
This config tells gem that you need to take a dump of the wwwkodepru_production database, dump it into a temporary directory, take the directory where the site is located, archive all of this, put it through the SCP to the backup server, making sure that no more than 14 recent backups are stored and send a joyful message to the admin.
3. Record the start of the backup perform --trigger kodepru command at, say, midnight.
...
PROFIT !!!
Naturally, we do not write this config with a stern admin hand! There is a special socket, written
on the knee on the rails.
By the way, something tells me that not only Rails applications consist of a directory with code and a database ...
I hope someone will be interested, and I, perhaps, will continue to write about our simple tricks.