diff options
Diffstat (limited to 'lib/tasks/db.rake')
| -rw-r--r-- | lib/tasks/db.rake | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake new file mode 100644 index 0000000..38fb2c5 --- /dev/null +++ b/lib/tasks/db.rake @@ -0,0 +1,17 @@ +require "yaml" + +namespace :db do + desc 'backup database (rake db:backup["prod"])' + task :backup, :env do |key, value| + environment = value[:env] || 'qa' + sh "cap #{environment} postgresql:backup" + end + + desc 'restore database to local' + task :restore, :env do |key, value| + environment = value[:env] || 'development' + all_configuration = YAML.load_file(File.join(File.dirname(__FILE__), '../../config/database.yml' )) + config = all_configuration[environment] + sh "pg_restore --verbose --clean --no-acl --no-owner -h #{config["host"]} -U #{config["username"]} -d #{config["database"]} tmp/database.dump" + end +end |
