Created
July 6, 2012 21:43
-
-
Save patbenatar/3062920 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
#!/usr/bin/env ruby | |
require 'yaml' | |
require 'fileutils' | |
YAML::ENGINE.yamler = 'psych' | |
RAILS_ENV = ENV["RAILS_ENV"] | |
path_to_database_yml = File.join("config", "database.yml") | |
config = YAML.load_file(path_to_database_yml)[RAILS_ENV] | |
system "mysqldump -u#{config["username"]} -p#{config["password"]} #{config["database"]} --lock-tables=false" |
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
#!/usr/bin/env ruby | |
# Usage: receives a mysqldump via pipe | |
require 'yaml' | |
require 'fileutils' | |
YAML::ENGINE.yamler = 'psych' | |
RAILS_ENV = ENV["RAILS_ENV"] | |
path_to_database_yml = File.join("config", "database.yml") | |
config = YAML.load_file(path_to_database_yml)[RAILS_ENV] | |
`mysql -u#{config["username"]} -p#{config["password"]} #{config["database"]}` |
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
namespace :copy do | |
task :db, roles: :app do | |
run "cd #{current_path} && ssh user@production 'cd #{current_path} && ./script/mysql_dump | gzip -c' | gunzip -c | ./script/mysql_import" | |
end | |
task :uploads, roles: :app do | |
# Copy system/uploads from prod to stg | |
path_to_system_uploads = "/home/deployer/apps/app_name/shared/system/uploads/" | |
run "(ssh user@production 'cd #{path_to_system_uploads} && tar -cf - .') | (cd #{path_to_system_uploads} && tar -xpf -)" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment