Backing up Rails projects without fancy
As you know, people are divided into those who are not yet making backups, those who are already doing, and those who are already doing and checking the possibility of recovery
Fortunately, 20 minutes ago, when the curveadmin recipe Capistrano completely demolished the directory with the loaded pictures from articles of users, I already belonged to the category of making backups. Here, at the same time and checked.
And we do backups through gem backup
We have about 20 user sites running on a cloud hosting on several servers, which we developed, plus one small but proud (and heavy) application with VoIP, RTMP, J2MEand geishaand web admin. When, a few months ago, the administrator, while updating, wiped the Asterisk PBX configs and then with a shaking chin and blue lips restored them from a running daemon, it became clear that without backups it was too dangerous further. But doing backups “on the forehead” for 20 applications, each of which used its own database in MySQL with its usernames and passwords, was too uninteresting and boring. It would be a long, long bash script, on which immediately after a successful launch they would have scored would have to spend a lot of time to maintain the relevance of this script.
This is where the backup gem came in handy.
The backup gem does this:
You just need to do three simple things:
1. Install the gem (gem install backup)
2. Write the config (by default, the gem executable looks for the config in the ~ / Backup / config.rb directory, you can change this with additional options). An example of a config for one of our sites: This config tells the gem that you need to dump the wwwkodepru_production base, dump it into a temporary directory, take the directory where the site is located, archive it all, put it through SCP to the backup server, making sure that no more than the last 14 are stored backups and send a joyful message to the admin. 3. Write the backup perform --trigger kodepru command in kroner, say at midnight. ... PROFIT !!! Naturally, we do not write this config with a harsh 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 a code and a database ...
I hope someone will be interested, but I will probably continue to write about our simple tricks.
Fortunately, 20 minutes ago, when the curve
And we do backups through gem backup
We have about 20 user sites running on a cloud hosting on several servers, which we developed, plus one small but proud (and heavy) application with VoIP, RTMP, J2ME
This is where the backup gem came in handy.
The backup gem does this:
- reads his config
- dump specified databases (different DBMSs are supported) to the temporary directory
- Tariff indicated directories in temporary directory
- shakes everything
- encrypts everything
- puts on a remote server via FTP, SCP, RSync and others
- maintains storage cycle
- writes me a letter
You just need to do three simple things:
1. Install the gem (gem install backup)
2. Write the config (by default, the gem executable looks for the config in the ~ / Backup / config.rb directory, you can change this with additional options). An example of a config for one of our sites: This config tells the gem that you need to dump the wwwkodepru_production base, dump it into a temporary directory, take the directory where the site is located, archive it all, put it through SCP to the backup server, making sure that no more than the last 14 are stored backups and send a joyful message to the admin. 3. Write the backup perform --trigger kodepru command in kroner, say at midnight. ... PROFIT !!! Naturally, we do not write this config with a harsh admin hand! There is a special socket written
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
By the way, something tells me that not only Rails applications consist of a directory with a code and a database ...
I hope someone will be interested, but I will probably continue to write about our simple tricks.