|
@@ -1,18 +1,20 @@
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
|
# set vars
|
|
# set vars
|
|
|
|
+BACKUP_ROOT_PATH=/tmp
|
|
|
|
+DATE=$(date +%Y%m%d-%H%M%S)
|
|
|
|
+BACKUP_NAME=akbk-$DATE
|
|
|
|
+BACKUP_PATH=$BACKUP_ROOT_PATH/$BACKUP_NAME
|
|
|
|
+mkdir -p $BACKUP_PATH
|
|
|
|
+chmod a+w $BACKUP_PATH
|
|
|
|
+
|
|
AKKOMA_DB=pleroma
|
|
AKKOMA_DB=pleroma
|
|
AKKOMA_USER=pleroma
|
|
AKKOMA_USER=pleroma
|
|
AKKOMA_SERVICE=pleroma
|
|
AKKOMA_SERVICE=pleroma
|
|
AKKOMA_PATH=/opt/pleroma
|
|
AKKOMA_PATH=/opt/pleroma
|
|
AKKOMA_STATIC_PATH=/var/lib/pleroma
|
|
AKKOMA_STATIC_PATH=/var/lib/pleroma
|
|
AKKOMA_CONFIG_PATH=/etc/pleroma/config.exs
|
|
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
|
|
|
|
|
|
+AKKOMA_DBCONFIG_PATH=$BACKUP_PATH/config_db.exs
|
|
|
|
|
|
# export config in database
|
|
# export config in database
|
|
cd $AKKOMA_PATH
|
|
cd $AKKOMA_PATH
|
|
@@ -24,7 +26,8 @@ systemctl stop $AKKOMA_SERVICE
|
|
|
|
|
|
# backup database/config.exs/static files
|
|
# backup database/config.exs/static files
|
|
sudo -Hu postgres pg_dump -d $AKKOMA_DB --format=custom -f $BACKUP_PATH/akkoma.pgdump
|
|
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
|
|
|
|
|
|
+tar -czpPf - $AKKOMA_STATIC_PATH $AKKOMA_CONFIG_PATH $BACKUP_PATH | gpg -e -r 0 > $BACKUP_PATH.tar.gz.gpg
|
|
|
|
+rm -r $BACKUP_PATH
|
|
|
|
|
|
# update backend
|
|
# update backend
|
|
su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl update --branch stable" && su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl migrate"
|
|
su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl update --branch stable" && su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl migrate"
|
|
@@ -32,8 +35,14 @@ su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl update --branch stable" && su $
|
|
# start akkoma
|
|
# start akkoma
|
|
systemctl start $AKKOMA_SERVICE
|
|
systemctl start $AKKOMA_SERVICE
|
|
|
|
|
|
|
|
+# wait for startup
|
|
|
|
+sleep 4s
|
|
|
|
+
|
|
# update frontend
|
|
# 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"
|
|
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"
|
|
|
|
|
|
# upload archive
|
|
# upload archive
|
|
-rclone copy /home/plbk/akbk+*.tar.gz.gpg od-1:/upload -vP
|
|
|
|
|
|
+rclone copy $BACKUP_PATH.tar.gz.gpg od-1:/upload -vP
|
|
|
|
+
|
|
|
|
+# clean up
|
|
|
|
+rm $BACKUP_PATH.tar.gz.gpg
|