Browse Source

Add update_akkoma.sh backup_akkoma.sh

poesty 1 year ago
parent
commit
58d7bca217
2 changed files with 68 additions and 0 deletions
  1. 31 0
      backup/backup_akkoma.sh
  2. 37 0
      update/update_akkoma.sh

+ 31 - 0
backup/backup_akkoma.sh

@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# set vars
+AKKOMA_DB=pleroma
+AKKOMA_USER=pleroma
+AKKOMA_SERVICE=pleroma
+AKKOMA_PATH=/opt/pleroma
+AKKOMA_STATIC_PATH=/var/lib/pleroma
+AKKOMA_CONFIG_PATH=/etc/pleroma/config.exs
+AKKOMA_DBCONFIG_PATH=/tmp/config_db.exs
+BACKUP_PATH=/home/plbk
+
+# clean up
+rm $BACKUP_PATH/*
+rm $AKKOMA_DBCONFIG_PATH
+
+# stop akkoma
+systemctl stop $AKKOMA_SERVICE
+
+# backup database/config.exs/static files
+cd $AKKOMA_PATH
+su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl config dump" > $AKKOMA_DBCONFIG_PATH
+sed -i 's/\r//g' $AKKOMA_DBCONFIG_PATH
+sudo -Hu postgres pg_dump -d $AKKOMA_DB  --format=custom -f $BACKUP_PATH/akkoma.pgdump
+tar -czpPf - $AKKOMA_STATIC_PATH $AKKOMA_CONFIG_PATH $BACKUP_PATH/akkoma.pgdump $AKKOMA_DBCONFIG_PATH | gpg -e -r 0 > $BACKUP_PATH/akbk+$(date +%Y%m%d-%H%M%S).tar.gz.gpg
+
+# upload archive
+rclone copy /home/plbk/akbk+*.tar.gz.gpg od-1:/upload -vP
+
+# start akkoma
+systemctl start $AKKOMA_SERVICE

+ 37 - 0
update/update_akkoma.sh

@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# set vars
+AKKOMA_DB=pleroma
+AKKOMA_USER=pleroma
+AKKOMA_SERVICE=pleroma
+AKKOMA_PATH=/opt/pleroma
+AKKOMA_STATIC_PATH=/var/lib/pleroma
+AKKOMA_CONFIG_PATH=/etc/pleroma/config.exs
+AKKOMA_DBCONFIG_PATH=/tmp/config_db.exs
+BACKUP_PATH=/home/plbk
+
+# clean up
+rm $BACKUP_PATH/*
+rm $AKKOMA_DBCONFIG_PATH
+
+# stop akkoma
+systemctl stop $AKKOMA_SERVICE
+
+# backup database/config.exs/static files
+cd $AKKOMA_PATH
+su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl config dump" > $AKKOMA_DBCONFIG_PATH
+sed -i 's/\r//g' $AKKOMA_DBCONFIG_PATH
+sudo -Hu postgres pg_dump -d $AKKOMA_DB  --format=custom -f $BACKUP_PATH/akkoma.pgdump
+tar -czpPf - $AKKOMA_STATIC_PATH $AKKOMA_CONFIG_PATH $BACKUP_PATH/akkoma.pgdump $AKKOMA_DBCONFIG_PATH | gpg -e -r 0 > $BACKUP_PATH/akbk+$(date +%Y%m%d-%H%M%S).tar.gz.gpg
+
+# upload archive
+rclone copy /home/plbk/akbk+*.tar.gz.gpg od-1:/upload -vP
+
+# update backend
+su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl update --branch stable" && su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl migrate"
+
+# start akkoma
+systemctl start $AKKOMA_SERVICE
+
+# update frontend
+su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl frontend install pleroma-fe --ref stable" && su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl frontend install admin-fe --ref stable"