update backup part
All checks were successful
/ ls (pull_request) Successful in 32s
/ ls (push) Successful in 32s
/ ls (release) Successful in 23s

This commit is contained in:
Jonas 2024-06-30 10:53:10 +02:00
parent df072b0c19
commit c5e0d47e03
Signed by: lubiana
SSH key fingerprint: SHA256:gkqM8DUX4Blf6P52fycW8ISTd+4eAHH+Uzu9iyc8hAM
2 changed files with 8 additions and 3 deletions

View file

@ -23,6 +23,7 @@ jobs:
HOST: 'web.server.c3h'
USERNAME: 'c3h-futtern'
TARGETDIR: '/home/c3h-futtern/futtern'
HOMEDIR: '/home/c3h-futtern'
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh/
@ -35,9 +36,9 @@ jobs:
# stop services
ssh ${USERNAME}@${HOST} systemctl --user stop pod-futtern
# backup database
ssh ${USERNAME}@${HOST} cp ${TARGETDIR}/app/var/data.db ${TARGETDIR}/../backup/data.db-$(date +"%Y%m%d%H%M%S")
ssh ${USERNAME}@${HOST} "cp ${HOMEDIR}/futtern/app/var/data.db ${HOMEDIR}/backup/data.db-$(date +\"%Y%m%d%H%M%S\")"
# only keep last 10 backupts
ssh ${USERNAME}@${HOST} ls -1tr ${TARGETDIR}/../backup/ | head -n -10 | xargs -d '\n' rm -f --
ssh ${USERNAME}@${HOST} "find ${HOMEDIR}/backup/ -type f | sort | head -n -10 | xargs rm -f"
# SCP files to the remote host
rsync -avz --delete deploy/ ${USERNAME}@${HOST}:${TARGETDIR} --exclude=var
# run update script

View file

@ -1,6 +1,10 @@
#!/usr/bin/env sh
export HOMEDIR='/home/c3h-futtern/'
. ./deploy/prepare-deploy.sh
ssh leitstelle-futtern 'systemctl --user stop pod-futtern'
ssh leitstelle-futtern "cp ${HOMEDIR}/futtern/app/var/data.db ${HOMEDIR}/backup/data.db-$(date +\"%Y%m%d%H%M%S\")"
ssh leitstelle-futtern "find ${HOMEDIR}/backup/ -type f | sort | head -n -10 | xargs rm -f"
rsync -avz --delete deploy/ leitstelle-futtern:futtern --exclude=var
ssh leitstelle-futtern '/home/c3h-futtern/futtern/update.sh'