Commit bfef631c6287be13211d6b32572c3d6c4be55747

Authored by Athos
1 parent d6d3634a

Drop noosfero database before its restore task

Showing 2 changed files with 7 additions and 1 deletions   Show diff stats
@@ -93,6 +93,12 @@ task :backup => ssh_config_file do @@ -93,6 +93,12 @@ task :backup => ssh_config_file do
93 end 93 end
94 94
95 task :restore => ssh_config_file do 95 task :restore => ssh_config_file do
  96 + # setup
  97 + sh 'ssh', '-F', ssh_config_file, 'integration', 'sudo', 'rm -rf /tmp/backups'
  98 + sh 'ssh', '-F', ssh_config_file, 'social', 'sudo', 'rm -rf /tmp/backups'
  99 + sh 'ssh', '-F', ssh_config_file, 'social', 'sudo', 'systemctl stop noosfero'
  100 + sh 'ssh', '-F', ssh_config_file, 'database', 'sudo', 'sudo -u postgres dropdb noosfero 2> /dev/null'
  101 + sh 'ssh', '-F', ssh_config_file, 'database', 'sudo', 'sudo -u postgres createdb noosfero --owner noosfero 2> /dev/null'
96 #integration 102 #integration
97 sh 'scp', '-r', '-F', ssh_config_file, 'backups', 'integration:/tmp' 103 sh 'scp', '-r', '-F', ssh_config_file, 'backups', 'integration:/tmp'
98 sh 'scp', '-F', ssh_config_file, 'utils/migration/restore_integration.sh', 'integration:/tmp' 104 sh 'scp', '-F', ssh_config_file, 'utils/migration/restore_integration.sh', 'integration:/tmp'
@@ -101,6 +107,7 @@ task :restore => ssh_config_file do @@ -101,6 +107,7 @@ task :restore => ssh_config_file do
101 sh 'scp', '-r', '-F', ssh_config_file, 'backups', 'social:/tmp' 107 sh 'scp', '-r', '-F', ssh_config_file, 'backups', 'social:/tmp'
102 sh 'scp', '-F', ssh_config_file, 'utils/migration/restore_social.sh', 'social:/tmp' 108 sh 'scp', '-F', ssh_config_file, 'utils/migration/restore_social.sh', 'social:/tmp'
103 sh 'ssh', '-F', ssh_config_file, 'social', 'sudo', '/tmp/restore_social.sh' 109 sh 'ssh', '-F', ssh_config_file, 'social', 'sudo', '/tmp/restore_social.sh'
  110 + sh 'ssh', '-F', ssh_config_file, 'social', 'sudo', 'systemctl start noosfero'
104 end 111 end
105 112
106 task :bootstrap_common => 'config/local/ssh_config' 113 task :bootstrap_common => 'config/local/ssh_config'
utils/migration/restore_social.sh
@@ -4,6 +4,5 @@ echo 'Starting restore on social...' @@ -4,6 +4,5 @@ echo 'Starting restore on social...'
4 #Noosfero restore 4 #Noosfero restore
5 echo 'restoring Noosfero...' 5 echo 'restoring Noosfero...'
6 cd /usr/lib/noosfero 6 cd /usr/lib/noosfero
7 -#TODO: drop and create noosfero database  
8 yes y | RAILS_ENV=production sudo -u noosfero bundle exec rake restore BACKUP=/tmp/backups/noosfero_backup.tar.gz 1> /dev/null 2>/dev/null 7 yes y | RAILS_ENV=production sudo -u noosfero bundle exec rake restore BACKUP=/tmp/backups/noosfero_backup.tar.gz 1> /dev/null 2>/dev/null
9 echo 'done.' 8 echo 'done.'