Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos
Commits
7e8428fc
Commit
7e8428fc
authored
Nov 24, 2022
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
peertube: restore fixup
parent
f2f15bb6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
24 deletions
+36
-24
software/peertube/buildout.hash.cfg
software/peertube/buildout.hash.cfg
+1
-1
software/peertube/template-peertube-restore.sh.in
software/peertube/template-peertube-restore.sh.in
+35
-23
No files found.
software/peertube/buildout.hash.cfg
View file @
7e8428fc
...
...
@@ -54,4 +54,4 @@ md5sum = 58d1a4fe246169dea94d7d243b4bac9e
[template-peertube-restore-script]
filename = template-peertube-restore.sh.in
md5sum =
75f8ddfe15d087294dece94029417193
md5sum =
ad91e27d140d96277144e5ba83b553df
software/peertube/template-peertube-restore.sh.in
View file @
7e8428fc
...
...
@@ -11,32 +11,30 @@
# the status of the restoration (success or failure)
# 1. Check the postgresql is running
# > While the server is running, its PID is stored in the file postmaster.pid in the data directory.
# https://www.postgresql.org/docs/current/server-start.html
# which means if the postmaster.pid exist, then the postgresql is running.
pid_file=$${postgresql:pgdata-directory}/postmaster.pid
die() {
echo "$*" 1>&2
exit 1
}
if [ -e "$pid_file" ]; then
echo "Postgresql pidfile postmaster.pid exits, assuming running. Aborting."
exit 1
fi
pg_version=$${postgresql:pgdata-directory}/PG_VERSION
# 2. Restore database
$${postgresql:bin}/pg_restore -h $${postgresql:pgdata-directory} --exit-on-error -c -d peertube_prod -U peertube $${directory:srv}/backup/peertube_prod-dump.db
tpgwait=60
while ! [ -e "$pg_version" ]; do
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "PGdata directory not ready"
echo "I: PGdata directory is not ready (yet ?); will retry $tpgwait times..." 1>&2
sleep 1
done
#
3
.
#
# 2
.
echo "Starting postgresql..."
$${postgresql:bin}/p
sql -D $${postgresql:pgdata-directory}
$${postgresql:bin}/p
ostgres -D $${postgresql:pgdata-directory} &
die() {
echo "$*" 1>&2
exit 1
}
postgres_pid=$!
echo $postgres_pid
# run psql
on gitlab db
# run psql
psql() {
$${postgresql:bin}/psql \
-h $${postgresql:pgdata-directory} \
...
...
@@ -57,12 +55,26 @@ while true; do
done
echo "I: PostgreSQL ready." 1>&2
$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory}
sleep 30
# If postgresql has stopped, abort
if ! [ -d "$${postgresql:pgdata-directory}" ]; then
sleep 5
# Check the postgresql is running, if postgresql has stopped, abort
# > While the server is running, its PID is stored in the file postmaster.pid in the data directory.
# https://www.postgresql.org/docs/current/server-start.html
# which means if the postmaster.pid exist, then the postgresql is running.
pid_file=$${postgresql:pgdata-directory}/postmaster.pid
if ! [ -e "$pid_file" ]; then
echo "postgresql exited, aborting."
exit 1
fi
$${postgresql:bin}/pg_restore -h $${postgresql:pgdata-directory} -U peertube -e -c -C -d postgres $${directory:srv}/backup/peertube_prod-dump.db
pg_restore_pid=$!
echo $pg_restore_pid
wait $PID
echo 'Backup restoration successfully completed.'
# Allow slapos node instance to start the postgresql service
kill $postgres_pid
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment