backup.sh is executed by root

missytake 2020-06-07 16:06:16 +02:00
parent 86869d86d9
commit 9380032f7c
1 changed files with 6 additions and 4 deletions

View File

@ -1,18 +1,20 @@
#!/bin/sh
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR
. ./.env
# stop the containers to make sure the data doesn't change during backup.
podman stop wordpress_wordpress_1 wordpress_db_1
XDG_RUNTIME_DIR=/run/user/1002 su synthikat -c "podman stop wordpress_wordpress_1 wordpress_db_1"
# Example backup command:
# backup: is the remote backup server, defined in ~/.ssh/config - ends with a :
# repositories-borg/synthikat is the path on the remote server - ends with a ::
# 'backup{now:%Y%m%d}' is the backup name, this includes today's date in the name
# the rest are the file paths. You can append as many as you want.
borg create --stats --progress backup:repositories-borg/synthikat::'backup{now:%Y%m%d-%M}' wp-content db_data
borg create --stats --progress backup:repositories-borg/synthikat::'backup{now:%Y%m%d-%M}' ../wp-content ../db_data
# restart the containers
podman start wordpress_wordpress_1 wordpress_db_1
XDG_RUNTIME_DIR=/run/user/1002 su synthikat -c "podman start wordpress_wordpress_1 wordpress_db_1"
# Delete all the backups which are too old, to save space in the long term.
borg prune --keep-daily=7 --keep-weekly=4 backup:repositories-borg/synthikat