update_akkoma.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # set vars
  3. AKKOMA_DB=pleroma
  4. AKKOMA_USER=pleroma
  5. AKKOMA_SERVICE=pleroma
  6. AKKOMA_PATH=/opt/pleroma
  7. AKKOMA_STATIC_PATH=/var/lib/pleroma
  8. AKKOMA_CONFIG_PATH=/etc/pleroma/config.exs
  9. AKKOMA_DBCONFIG_PATH=/tmp/config_db.exs
  10. BACKUP_PATH=/home/plbk
  11. # clean up
  12. rm $BACKUP_PATH/*
  13. rm $AKKOMA_DBCONFIG_PATH
  14. # stop akkoma
  15. systemctl stop $AKKOMA_SERVICE
  16. # backup database/config.exs/static files
  17. cd $AKKOMA_PATH
  18. su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl config dump" > $AKKOMA_DBCONFIG_PATH
  19. sed -i 's/\r//g' $AKKOMA_DBCONFIG_PATH
  20. sudo -Hu postgres pg_dump -d $AKKOMA_DB --format=custom -f $BACKUP_PATH/akkoma.pgdump
  21. 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
  22. # update backend
  23. su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl update --branch stable" && su $AKKOMA_USER -s $SHELL -lc "./bin/pleroma_ctl migrate"
  24. # start akkoma
  25. systemctl start $AKKOMA_SERVICE
  26. # update frontend
  27. 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"
  28. # upload archive
  29. rclone copy /home/plbk/akbk+*.tar.gz.gpg od-1:/upload -vP