Commit afdfd53c authored by Boxiang Sun's avatar Boxiang Sun

peertube: backup fixup

parent ffacc1a7
Pipeline #25183 passed with stage
in 0 seconds
......@@ -54,4 +54,4 @@ md5sum = e50daa16a2c1866997933981bed45271
[template-peertube-restore-script]
filename = template-peertube-restore.sh.in
md5sum = 04e1c0abe3d3c626e2f6e513d7e0d646
md5sum = 656b170ed264b749415f1d31a8c770b1
......@@ -43,25 +43,32 @@ $${postgresql:bin}/postgres -D $${postgresql:pgdata-directory} &
postgresql_pid=$!
trap "kill $postgresql_pid" EXIT TERM INT
# If postgres has stopped, abort
if ! [ -d /proc/$postgresql_pid ]; then
echo "postgresql exited, aborting."
exit 1
fi
echo "Parsing postgresql conf..."
postgresql_conf_file=$${postgresql:pgdata-directory}/postgresql.conf
tpgwait=60
while ! [ -e "$pid_file" ]; do
while ! [ -e "$postgresql_conf_file" ]; do
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "Can not create pid_file"
echo "pid_file not exist; will retry $tpgwait times..." 1>&2
test $tpgwait = 0 && die "Postgresql conf file does not exist."
echo "Postgresql conf file does not exist; will retry $tpgwait times..." 1>&2
sleep 1
done
# If postgres has stopped, abort
if ! [ -d /proc/$postgresql_pid ]; then
echo "postgresql exited, aborting."
exit 1
fi
echo "Get the postgresql port number..."
port=$(awk '/^port/{print $3}' $postgresql_conf_file)
echo $port
# run psql
psql() {
$${postgresql:bin}/psql \
-h $${postgresql:pgdata-directory} \
-p $port \
-U $${postgresql:superuser} \
-d $${postgresql:dbname} \
"$@"
......@@ -98,7 +105,7 @@ fi
echo "Postgresql is running, ready to restore"
# Restore the database
$${postgresql:bin}/pg_restore -h $${postgresql:pgdata-directory} -U peertube -e -c -C -d postgres $${peertube-backup-script:backup-file} || {
$${postgresql:bin}/pg_restore -h $${postgresql:pgdata-directory} -U peertube -p $port -e -c -C -d postgres $${peertube-backup-script:backup-file} || {
RESTORE_EXIT_CODE=$?
echo 'Backup restoration failed.'
exit $RESTORE_EXIT_CODE
......
......@@ -245,15 +245,6 @@ class TestTheiaResiliencePeertube(test_resiliency.TestTheiaResilience):
_connexion_parameters_regex = re.compile(r"{.*}", re.DOTALL)
_test_software_url = peertube_software_release_url
@classmethod
def setUpClass(cls):
super(TestTheiaResiliencePeertube, cls).setUpClass()
cls.computer_partition_root_path = cls.getPartitionPath('import')
cls._save_instance_file_pattern_list += (
'*/srv/postgresql/*',
'*/srv/backup/peertube_prod-dump.db',
)
def _getPeertubeConnexionParameters(self, instance_type='export'):
out = self.captureSlapos(
'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