Commit 7565bcdd authored by Boxiang Sun's avatar Boxiang Sun

peertube: backup fixup

parent bfc1cf0d
Pipeline #25148 passed with stage
in 0 seconds
...@@ -18,7 +18,7 @@ md5sum = 35690065ba18dc49d0108fc1f0a07b9e ...@@ -18,7 +18,7 @@ md5sum = 35690065ba18dc49d0108fc1f0a07b9e
[instance-peertube] [instance-peertube]
_update_hash_filename_ = instance-peertube.cfg.in _update_hash_filename_ = instance-peertube.cfg.in
md5sum = dedf43efb45743e6401cebec57fc2e8e md5sum = db076bb9b8e5392ec560b15236c8f1d0
[template-nginx-service] [template-nginx-service]
filename = template-nginx-service.sh.in filename = template-nginx-service.sh.in
...@@ -50,8 +50,8 @@ md5sum = f1f82101258de19068262b7213fc478b ...@@ -50,8 +50,8 @@ md5sum = f1f82101258de19068262b7213fc478b
[template-peertube-backup-script] [template-peertube-backup-script]
filename = template-peertube-backup.sh.in filename = template-peertube-backup.sh.in
md5sum = 58d1a4fe246169dea94d7d243b4bac9e md5sum = e50daa16a2c1866997933981bed45271
[template-peertube-restore-script] [template-peertube-restore-script]
filename = template-peertube-restore.sh.in filename = template-peertube-restore.sh.in
md5sum = 0e8e0380887083b0dbb81ffa4016b431 md5sum = 0b35d69cd3cc3602c9b66f1e1baaf719
...@@ -195,7 +195,8 @@ logfile = ${directory:log}/crond.log ...@@ -195,7 +195,8 @@ logfile = ${directory:log}/crond.log
[peertube-backup-script] [peertube-backup-script]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = {{ template_peertube_backup }} url = {{ template_peertube_backup }}
output = ${directory:etc}/${:_buildout_section_name_} backup-file = ${directory:srv}/backup/peertube_prod-dump.db
output = ${directory:bin}/${:_buildout_section_name_}
mode = 0744 mode = 0744
[peertube-backup-cron] [peertube-backup-cron]
......
#!${dash-output:dash} #!${dash-output:dash}
# Dump the databse # Dump the databse
$${postgresql:bin}/pg_dump -h $${postgresql:pgdata-directory} -U $${postgresql:superuser} -Fc peertube_prod > $${directory:srv}/backup/peertube_prod-dump.db $${postgresql:bin}/pg_dump -h $${postgresql:pgdata-directory} -U $${postgresql:superuser} -Fc peertube_prod > $${peertube-backup-script:backup-file}
...@@ -93,10 +93,10 @@ fi ...@@ -93,10 +93,10 @@ fi
echo "Postgresql is running, ready to restore" echo "Postgresql is running, ready to restore"
# Restore the database # Restore the database
$${postgresql:bin}/pg_restore -h $${postgresql:pgdata-directory} -U peertube -e -c -C -d postgres $${directory:srv}/backup/peertube_prod-dump.db || { $${postgresql:bin}/pg_restore -h $${postgresql:pgdata-directory} -U peertube -e -c -C -d postgres $${peertube-backup-script:backup-file} || {
RESTORE_EXIT_CODE=$? RESTORE_EXIT_CODE=$?
echo 'Backup restoration failed.' echo 'Backup restoration failed.'
exit $RESTORE_EXIT_CODE exit $RESTORE_EXIT_CODE
} }
echo "Postgresql restore finished" echo "Postgresql restore finished"
\ No newline at end of file
...@@ -245,28 +245,6 @@ class TestTheiaResiliencePeertube(test_resiliency.TestTheiaResilience): ...@@ -245,28 +245,6 @@ class TestTheiaResiliencePeertube(test_resiliency.TestTheiaResilience):
_connexion_parameters_regex = re.compile(r"{.*}", re.DOTALL) _connexion_parameters_regex = re.compile(r"{.*}", re.DOTALL)
_test_software_url = peertube_software_release_url _test_software_url = peertube_software_release_url
def _waitTakeoverReady(self, takeover_url, start, maxtries, interval):
export_exitfile = self.getExportExitfile()
export_errorfile = self.getExportErrorfile()
tries = self._waitScriptDone(
'Export', start, export_exitfile, export_errorfile, maxtries, interval)
import_exitfile = self.getImportExitfile()
import_errorfile = self.getImportErrorfile()
tries = self._waitScriptDone(
'Import', start, import_exitfile, import_errorfile, tries, interval)
print('tries after Import is: ' + str(tries))
for _ in range(40):
info = self._getTakeoverPage(takeover_url)
if "No backup downloaded yet, takeover should not happen now." in info:
print('Takeover page still reports export script in progress')
elif "<b>Importer script(s) of backup in progress:</b> True" in info:
print('Takeover page still reports import script in progress')
else:
return
time.sleep(interval)
return
self.fail('Takeover page failed to report readiness')
def _getPeertubeConnexionParameters(self, instance_type='export'): def _getPeertubeConnexionParameters(self, instance_type='export'):
out = self.captureSlapos( out = self.captureSlapos(
'request', 'test_instance', self._test_software_url, 'request', 'test_instance', self._test_software_url,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment