Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace :db do
- desc "Run the database backup"
- task :backup do
- on roles(:db) do
- adhoc = false
- backup_dir = fetch(:backup_dir)
- release_timestamp = fetch(:release_timestamp)
- adhoc = true unless release_timestamp
- release_timestamp = env.timestamp.strftime("%Y%m%d%H%M%S") if adhoc
- dump_path = "#{backup_dir}/#{release_timestamp}"
- execute :mkdir, '-p', dump_path
- puts fetch(:db_user)
- puts fetch(:db_pass)
- puts fetch(:db_name)
- end
- end
- desc "Get the database credentials from our config file"
- task :get_creds do
- on roles(:app) do
- f = File.read("#{deploy_to}/config/#{fetch(:environment)}/config.json")
- json = JSON.parse(f)
- set(:db_user, json['db']['maintenance']['username'])
- set(:db_pass, json['db']['maintenance']['password'])
- set(:db_name, json['db']['maintenance']['database'])
- end
- end
- before 'db:backup', :get_creds
- end
Advertisement
Add Comment
Please, Sign In to add comment