From 93f8e23a461f76cf802c8f882d08acb91fc60cd2 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Thu, 23 Jan 2020 23:03:36 +0100
Subject: [PATCH] Plemora migration scripts.

---
 buster/setup_scripts/backup_pleroma.sh  | 15 +++++++++++++++
 buster/setup_scripts/restore_pleroma.sh | 12 ++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100755 buster/setup_scripts/backup_pleroma.sh
 create mode 100755 buster/setup_scripts/restore_pleroma.sh

diff --git a/buster/setup_scripts/backup_pleroma.sh b/buster/setup_scripts/backup_pleroma.sh
new file mode 100755
index 0000000..ae1e6bd
--- /dev/null
+++ b/buster/setup_scripts/backup_pleroma.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+set -e
+# Heavily inspired by <https://docs.pleroma.social/backup.html>
+
+service pleroma stop
+su postgres -lc 'pg_dump -d pleroma --format=custom -f /tmp/pleroma.pgdump'
+cd /tmp
+mkdir pleroma_backup
+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
+chown plom:plom pleroma_backup.tar
+mv pleroma_backup.tar /home/plom/
+service pleroma start
diff --git a/buster/setup_scripts/restore_pleroma.sh b/buster/setup_scripts/restore_pleroma.sh
new file mode 100755
index 0000000..4f4d05b
--- /dev/null
+++ b/buster/setup_scripts/restore_pleroma.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+set -e
+# Heavily inspired by <https://docs.pleroma.social/backup.html>
+
+service pleroma stop
+mv /home/plom/pleroma_backup.tar /tmp/
+cd /tmp
+tar xf pleroma_backup.tar
+cp -a pleroma_backup/uploads/* /var/lib/pleroma/uploads/
+cp -a pleroma_backup/etc_files/* /etc/pleroma/
+su postgres -lc 'pg_restore --clean -d pleroma -v -1 /tmp/pleroma_backup/pleroma.pgdump'
+service pleroma start
-- 
2.30.2