Commit 12d046950b8577db431ab112183cfe0ed51ffc6f

Authored by Antonio Terceiro
2 parents 85b736c8 3b814b25

Merge branch 'fix_backup_task' into 'master'

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>

See merge request !567
Showing 1 changed file with 6 additions and 4 deletions   Show diff stats
lib/tasks/backup.rake
@@ -25,9 +25,10 @@ task :backup =&gt; :check_backup_support do @@ -25,9 +25,10 @@ task :backup =&gt; :check_backup_support do
25 dump = File.join('tmp/backup', backup_name) + '.sql' 25 dump = File.join('tmp/backup', backup_name) + '.sql'
26 26
27 database = $config['production']['database'] 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 rm_f dump 32 rm_f dump
32 33
33 puts "****************************************************" 34 puts "****************************************************"
@@ -81,14 +82,15 @@ task :restore =&gt; :check_backup_support do @@ -81,14 +82,15 @@ task :restore =&gt; :check_backup_support do
81 82
82 database = $config['production']['database'] 83 database = $config['production']['database']
83 username = $config['production']['username'] 84 username = $config['production']['username']
  85 + host = $config['production']['host']
84 86
85 puts "WARNING: backups should be restored to an empty database, otherwise" 87 puts "WARNING: backups should be restored to an empty database, otherwise"
86 puts "data from the backup may not be loaded properly." 88 puts "data from the backup may not be loaded properly."
87 puts 89 puts
88 puts 'You can remove the existing database and create a new one with:' 90 puts 'You can remove the existing database and create a new one with:'
89 puts 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 puts 94 puts
93 print "Are you sure you want to continue (y/N)? " 95 print "Are you sure you want to continue (y/N)? "
94 response = $stdin.gets.strip 96 response = $stdin.gets.strip