diff options
Diffstat (limited to 'lib/tasks/db.rake')
| -rw-r--r-- | lib/tasks/db.rake | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake new file mode 100644 index 0000000..20e7782 --- /dev/null +++ b/lib/tasks/db.rake @@ -0,0 +1,16 @@ +require "yaml" + +namespace :db do + desc 'backup database (rake db:backup["production"]' + task :backup, :env do |key, value| + environment = value[:env] || 'development' + sh "cap #{environment} postgresql:backup" + end + + 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 |
