Commit 3b814b256441be6e0fc98cb1afa695c4f13d6849
1 parent
85b736c8
Exists in
master
and in
26 other branches
Fix backup task
- Adds host option to the postgres commands where necessary. - Passes -h option to tar when compressing in order to follow symlinks. Signed-off-by: Athos Ribeiro <athoscribeiro@gmail.com> Signed-off-by: Lucas Kanashiro <kanashiro.duarte@gmail.com>
Showing
1 changed file
with
6 additions
and
4 deletions
Show diff stats
lib/tasks/backup.rake
... | ... | @@ -25,9 +25,10 @@ task :backup => :check_backup_support do |
25 | 25 | dump = File.join('tmp/backup', backup_name) + '.sql' |
26 | 26 | |
27 | 27 | database = $config['production']['database'] |
28 | - sh "pg_dump #{database} > #{dump}" | |
28 | + host = $config['production']['host'] | |
29 | + sh "pg_dump -h #{host} #{database} > #{dump}" | |
29 | 30 | |
30 | - sh 'tar', 'caf', backup_file, dump, *dirs | |
31 | + sh 'tar', 'chaf', backup_file, dump, *dirs | |
31 | 32 | rm_f dump |
32 | 33 | |
33 | 34 | puts "****************************************************" |
... | ... | @@ -81,14 +82,15 @@ task :restore => :check_backup_support do |
81 | 82 | |
82 | 83 | database = $config['production']['database'] |
83 | 84 | username = $config['production']['username'] |
85 | + host = $config['production']['host'] | |
84 | 86 | |
85 | 87 | puts "WARNING: backups should be restored to an empty database, otherwise" |
86 | 88 | puts "data from the backup may not be loaded properly." |
87 | 89 | puts |
88 | 90 | puts 'You can remove the existing database and create a new one with:' |
89 | 91 | puts |
90 | - puts "$ sudo -u postgres dropdb #{database}" | |
91 | - puts "$ sudo -u postgres createdb #{database} --owner #{username}" | |
92 | + puts "$ sudo -u postgres dropdb -h #{host} #{database}" | |
93 | + puts "$ sudo -u postgres createdb -h #{host} #{database} --owner #{username}" | |
92 | 94 | puts |
93 | 95 | print "Are you sure you want to continue (y/N)? " |
94 | 96 | response = $stdin.gets.strip | ... | ... |