update backup part #28
2 changed files with 8 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
ssh leitstelle-futtern '/home/c3h-futtern/futtern/update.sh'
|
Loading…
Reference in a new issue