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
Boxiang Sun
slapos
Commits
b8852c35
Commit
b8852c35
authored
Nov 22, 2022
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
peertube: improve the postgresql restore script
parent
4d46e1a4
Pipeline
#24952
passed with stage
in 0 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
5 deletions
+59
-5
software/peertube/buildout.hash.cfg
software/peertube/buildout.hash.cfg
+6
-2
software/peertube/instance-peertube.cfg.in
software/peertube/instance-peertube.cfg.in
+2
-3
software/peertube/instance.cfg.in
software/peertube/instance.cfg.in
+1
-0
software/peertube/software.cfg
software/peertube/software.cfg
+5
-0
software/peertube/template-peertube-restore.sh.in
software/peertube/template-peertube-restore.sh.in
+45
-0
No files found.
software/peertube/buildout.hash.cfg
View file @
b8852c35
...
...
@@ -14,11 +14,11 @@
# not need these here).
[instance-profile]
filename = instance.cfg.in
md5sum =
9eed4136d9d6f8f855b73bbfefa6397c
md5sum =
b67bad9012a8f79c66779d4c660828e2
[instance-peertube]
_update_hash_filename_ = instance-peertube.cfg.in
md5sum =
fad859bfcb485a4593a9fb5a89cd665c
md5sum =
45bc81b1659aff57ec763af7863d77db
[template-nginx-service]
filename = template-nginx-service.sh.in
...
...
@@ -51,3 +51,7 @@ md5sum = f1f82101258de19068262b7213fc478b
[template-peertube-backup-script]
filename = template-peertube-backup.sh.in
md5sum = 58d1a4fe246169dea94d7d243b4bac9e
[template-peertube-restore-script]
filename = template-peertube-restore.sh.in
md5sum = 959ed92e4b762127ad0c9955ac21d7b5
software/peertube/instance-peertube.cfg.in
View file @
b8852c35
...
...
@@ -173,9 +173,8 @@ inline = {{ "${postgresql:pgdata-directory}/**" }}
output = ${directory:srv}/exporter.exclude
[peertube-database-resiliency-after-import-script]
recipe = collective.recipe.template
input = inline: #!/bin/sh
${postgresql:bin}/pg_restore -h ${postgresql:pgdata-directory} -c -U peertube -d peertube_prod ${directory:srv}/backup/peertube_prod-dump.db
recipe = slapos.recipe.template
url = {{ tempalte_peertube_restore }}
output = ${directory:srv}/runner-import-restore
mode = 755
...
...
software/peertube/instance.cfg.in
View file @
b8852c35
...
...
@@ -20,6 +20,7 @@ context =
raw template_peertube_yaml ${template-peertube-yaml:output}
raw template_nginx_configration ${template-nginx-configuration:output}
raw tempalte_peertube_service ${template-peertube-service:output}
raw tempalte_peertube_restore ${template-peertube-restore-script:output}
raw postgresql10_location ${postgresql10:location}
raw tempalte_nginx_service ${template-nginx-service:output}
raw redis_binprefix ${redis28:location}/bin
...
...
software/peertube/software.cfg
View file @
b8852c35
...
...
@@ -131,3 +131,8 @@ output = ${buildout:directory}/${:filename}
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/${:filename}
[template-peertube-restore-script]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/${:filename}
software/peertube/template-peertube-restore.sh.in
0 → 100644
View file @
b8852c35
#!${dash-output:dash}
# DO NOT RUN THIS SCRIPT ON PRODUCTION INSTANCE
# OR POSTGRESQL DATA WILL BE ERASED.
# This script will import the dump of the postgresql database to the real
# database. It is launched by the clone (importer) instance of theia
# in the end of the import script.
# Depending on the output, it will create a file containing
# 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
if [ -e "$pid_file" ]; then
echo "Postgresql pidfile postmaster.pid exits, assuming running. Aborting."
exit 1
fi
# 2.
echo "Deleting existing database..."
find "$${postgresql:pgdata-directory}" -mindepth 1 -delete
# 3.
echo "Starting postgresql..."
$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory}
sleep 30
# If mysql has stopped, abort
if ! [ -d "$${postgresql:pgdata-directory}" ]; then
echo "postgresql exited, aborting."
exit 1
fi
# 4.
echo "Importing data..."
$${postgresql:bin}/pg_restore -h $${postgresql:pgdata-directory} -c -U peertube -d peertube_prod $${directory:srv}/backup/peertube_prod-dump.db
# Check if it failed?
echo 'Backup restoration successfully completed.'
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