diff options
| author | mo khan <mo@mokhan.ca> | 2013-08-09 14:05:30 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-08-09 14:05:30 -0600 |
| commit | fc961ccd9c2d3d78eb0ac8b13c0bb3bd29bd95f4 (patch) | |
| tree | d7edf4aaec2c720366269c42a55e9bca06d8b120 /lib/tasks | |
| parent | 84ee59c6137ebe0e870aa47351bc06708b1260a8 (diff) | |
use a .dump file for db backups and create rake task
Diffstat (limited to 'lib/tasks')
| -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 |
