Created
April 20, 2009 18:53
-
-
Save roblingle/98662 to your computer and use it in GitHub Desktop.
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
Dir.glob(File.join(File.dirname(__FILE__), 'recipes/*.rb')).each {|f| require f } |
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
# Save as app/manifest/recipes/mysql_backup.rb | |
# Edit moonshine.yml: | |
# | |
# - Backup database from database.yml at 3am: | |
# :mysql: | |
# :backup: true | |
# | |
# - Get fancy: | |
# :mysql: | |
# :backup: | |
# :database: | |
# - myapp_production | |
# - some_other_db | |
# :minute: 0 | |
# :hour: 0 | |
# | |
def mysql_backup | |
backup = configuration[:mysql][:backup] | |
backup_dir = configuration[:deploy_to] + "/backup" | |
file backup_dir,:ensure => :directory, :owner => backup[:user]||configuration[:user], :mode => '750' | |
(backup[:database]||database_environment[:database]).to_a.each do |db| | |
cron "mysqldump of #{db}", | |
:command => "mysqldump -uroot #{db} > #{backup_dir}/#{db}.`date +\\%m\\%d\\%H\\%M\\%S\\%Y`.sql", | |
:minute => backup[:minute]||0, | |
:hour => backup[:hour]||3, | |
:dom => backup[:dom]||'*', | |
:month => backup[:month]||'*', | |
:dow => backup[:dow]||'*', | |
:user => backup[:user],configuration[:user] | |
:require => file(backup_dir) | |
end | |
end | |
recipe :mysql_backup if configuration[:mysql] && configuration[:mysql][:backup] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment