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
5bbac948
Commit
5bbac948
authored
Nov 25, 2022
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
peertube: restore script improvement
parent
0f241a41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
18 deletions
+21
-18
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
+20
-17
No files found.
software/peertube/buildout.hash.cfg
View file @
5bbac948
...
@@ -54,4 +54,4 @@ md5sum = 58d1a4fe246169dea94d7d243b4bac9e
...
@@ -54,4 +54,4 @@ md5sum = 58d1a4fe246169dea94d7d243b4bac9e
[template-peertube-restore-script]
[template-peertube-restore-script]
filename = template-peertube-restore.sh.in
filename = template-peertube-restore.sh.in
md5sum =
da2564f97a74674e700880c005106720
md5sum =
4cc9853025c2bf45b35ca14d5182b15b
software/peertube/template-peertube-restore.sh.in
View file @
5bbac948
...
@@ -26,13 +26,20 @@ while ! [ -e "$pg_version" ]; do
...
@@ -26,13 +26,20 @@ while ! [ -e "$pg_version" ]; do
sleep 1
sleep 1
done
done
# # 2.
# 2. Make sure the postgresql process is not running.
echo "Starting postgresql..."
# Quote from the postgresql doc:
# > While the server is running, its PID is stored in the file postmaster.pid in the data directory.
$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory} &
# https://www.postgresql.org/docs/current/server-start.html
# which means if the postmaster.pid exist, then the postgresql is running.
postgres_pid=$!
pid_file=$${postgresql:pgdata-directory}/postmaster.pid
echo $postgres_pid
if [ -e "$pid_file" ]; then
echo "postgresql is running, continue."
else
echo "Starting postgresql..."
$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory} &
postgres_pid=$!
echo $postgres_pid
fi
# run psql
# run psql
psql() {
psql() {
...
@@ -57,17 +64,14 @@ echo "I: PostgreSQL ready." 1>&2
...
@@ -57,17 +64,14 @@ echo "I: PostgreSQL ready." 1>&2
sleep 5
sleep 5
# Check the postgresql is running, if postgresql has stopped, abort
# 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
pid_file=$${postgresql:pgdata-directory}/postmaster.pid
if ! [ -e "$pid_file" ]; then
if ! [ -e "$pid_file" ]; then
echo "postgresql exited, aborting."
echo "postgresql exited, aborting."
exit 1
exit 1
fi
fi
# 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 $${directory:srv}/backup/peertube_prod-dump.db
pg_restore_pid=$!
pg_restore_pid=$!
...
@@ -76,10 +80,9 @@ wait $PID
...
@@ -76,10 +80,9 @@ wait $PID
echo 'Backup restoration successfully completed.'
echo 'Backup restoration successfully completed.'
# Allow slapos node instance to start the postgresql service
# The database process should be stopped to allow
kill $postgres_pid
#"slapos node instance" to starts the real postgresql service
if [ -e "$pid_file" ]; then
if [ -e "$pid_file" ]; then
echo "postgresql exited, aborting."
echo "Stoping postgresql..."
rm $pid_file
pkill -9 -f "$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory}"
fi
fi
\ 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