Last active
August 29, 2015 14:06
-
-
Save aishek/d937f6f44d08b9ef91ad to your computer and use it in GitHub Desktop.
gem dump + gem whenever scheduled backup example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/backup.rake | |
task :backup => [:environment] do | |
# делаем полный дамп базы и ассетов | |
ENV['TAG'] = 'backup' | |
Rake::Task['dump'].invoke | |
# храним 30 последних таких дампов | |
ENV['TAG'] = 'backup' | |
ENV['LEAVE'] = '30' | |
Rake::Task['dump:cleanup'].invoke | |
# с помощью rsync копируем новые дампы на внешний диск, | |
# удаляем со внешнего диска старые дампы | |
system("rsync -v -r --delete --include='*@backup.*' --exclude='*' dump/ /mnt/s3/dump/") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
every 1.day, :at => '4:00 am' do | |
rake "backup" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment