Commit 34b1948c authored by Boxiang Sun's avatar Boxiang Sun

peertube: restore fixup

parent c9ea69df
Pipeline #25027 passed with stage
in 0 seconds
......@@ -54,4 +54,4 @@ md5sum = 58d1a4fe246169dea94d7d243b4bac9e
[template-peertube-restore-script]
filename = template-peertube-restore.sh.in
md5sum = 4cc9853025c2bf45b35ca14d5182b15b
md5sum = dd4f5a5f862473efa2109315dbef3110
......@@ -10,6 +10,11 @@
# Depending on the output, it will create a file containing
# the status of the restoration (success or failure)
slapos node stop all
slapos_node_status_pid=$!
echo $slapos_node_status_pid
wait $slapos_node_status_pid
die() {
echo "$*" 1>&2
......@@ -17,6 +22,7 @@ die() {
}
pg_version=$${postgresql:pgdata-directory}/PG_VERSION
echo "Check postgresql data directory is ready"
tpgwait=60
while ! [ -e "$pg_version" ]; do
......@@ -26,6 +32,7 @@ while ! [ -e "$pg_version" ]; do
sleep 1
done
echo "Postgresql data directory is ready"
# 2. Make sure the postgresql process is not running.
# Quote from the postgresql doc:
# > While the server is running, its PID is stored in the file postmaster.pid in the data directory.
......@@ -41,6 +48,8 @@ else
echo $postgres_pid
fi
echo "Anyway, the postgresql is running..."
# run psql
psql() {
$${postgresql:bin}/psql \
......@@ -50,6 +59,8 @@ psql() {
"$@"
}
echo "Ready to check postgresql is running..."
# initial db setup
# ( first quering PG several times waiting a bit till postgresql is started and ready )
tpgwait=5
......@@ -71,14 +82,17 @@ if ! [ -e "$pid_file" ]; then
exit 1
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 $${directory:srv}/backup/peertube_prod-dump.db
echo "Postgresql restore finished"
pg_restore_pid=$!
echo $pg_restore_pid
wait $PID
wait $pg_restore_pid
echo 'Backup restoration successfully completed.'
echo "Backup restoration successfully completed."
# The database process should be stopped to allow
#"slapos node instance" to starts the real postgresql service
......@@ -86,3 +100,5 @@ if [ -e "$pid_file" ]; then
echo "Stoping postgresql..."
pkill -9 -f "$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory}"
fi
echo "Postgresql process killed"
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