home · contact · privacy
Add PeerTube migration scripts.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 12 Feb 2020 22:39:44 +0000 (23:39 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 12 Feb 2020 22:39:44 +0000 (23:39 +0100)
buster/setup_scripts/backup_peertube.sh [new file with mode: 0644]
buster/setup_scripts/backup_pleroma.sh
buster/setup_scripts/migrate_peertube.sh [new file with mode: 0644]
buster/setup_scripts/restore_peertube.sh [new file with mode: 0644]
buster/setup_scripts/setup_peertube.sh

diff --git a/buster/setup_scripts/backup_peertube.sh b/buster/setup_scripts/backup_peertube.sh
new file mode 100644 (file)
index 0000000..c787c75
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -e
+
+service peertube stop
+cd /tmp
+mkdir -p peertube_backup
+su peertube -c 'pg_dump -Fc peertube_prod' > peertube_backup/peertube_prod-dump.db
+cp -a /var/www/peertube/storage peertube_backup/storage
+cp -a /var/www/peertube/config peertube_backup/config
+tar cf peertube_backup.tar peertube_backup
+chown plom:plom peertube_backup.tar
+mv peertube_backup.tar /home/plom/
+service peertube start
index fadbb5f62597e2ba4e274586c3c19325a9e2e600..31b2718c3d4cae77bd7e00d33fed070d78e42224 100755 (executable)
@@ -11,6 +11,7 @@ mv pleroma.pgdump pleroma_backup
 cp -a /var/lib/pleroma/uploads pleroma_backup/uploads
 cp -a /etc/pleroma pleroma_backup/etc_files
 tar cf pleroma_backup.tar pleroma_backup
+rm -rf pleroma_backup
 chown plom:plom pleroma_backup.tar
 mv pleroma_backup.tar /home/plom/
 service pleroma start
diff --git a/buster/setup_scripts/migrate_peertube.sh b/buster/setup_scripts/migrate_peertube.sh
new file mode 100644 (file)
index 0000000..604920a
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -e
+
+# Heavily inspired by <https://docs.pleroma.social/backup.html>
+
+if [ "$#" -ne 1 ]; then
+    echo 'Need server IP as argument.'
+    false
+fi
+server_ip="$1"
+
+config_tree_prefix="${HOME}/config/buster"
+setup_scripts_dir="${config_tree_prefix}/setup_scripts"
+
+cd "${setup_scripts_dir}"
+./prepare_to_meet_server.sh "${server_ip}"
+read -p'Hit Enter when you are done.' ignore
+eval $(ssh-agent) && ssh-add
+echo 'Enter password for root on target server next.'
+ssh plom@"${server_ip}" 'su -lc "cd config/buster/setup_scripts && git pull && ./backup_peertube.sh"'
+scp plom@"${server_ip}":~/peertube_backup.tar /home/plom/peertube_backup.tar
+./restore_peertube.sh
+
diff --git a/buster/setup_scripts/restore_peertube.sh b/buster/setup_scripts/restore_peertube.sh
new file mode 100644 (file)
index 0000000..dad8649
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+set -e
+
+service peertube stop
+mv /home/plom/peertube_backup.tar /tmp/
+cd /tmp
+tar xf peertube_backup.tar
+cp -a peertube_backup/storage/* /var/www/peertube/storage/
+cp -a peertube_backup/config/* /var/www/peertube/config/
+su postgres -c 'pg_restore -c -C -d postgres peertube_backup/peertube_prod-dump.db'
+
+db_pw=$(cat /var/www/peertube/config/production.yaml | grep password | head -1 | sed "s/[ ]*password\: *//g" | sed "s/'//g")
+su postgres -lc "psql -c \"ALTER USER peertube WITH PASSWORD '${db_pw}';\""
+
+service peertube start
index f57ec40b9b02b9d30ae274511c70a772424c8d1d..2465cfe8ba427cb85dc19de3403bdeea3fcf1607 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 set -e
-set -x
+
 # Heavily inspired by
 # <https://github.com/Chocobozzz/PeerTube/blob/develop/support/doc/production.md>
 # and