update scripts

This commit is contained in:
Tamara 2022-09-25 01:06:00 +02:00
parent 6aeb2b87c7
commit ec14ed4f28
Signed by: tamtaram
GPG key ID: C2613AC6B3FA4686
3 changed files with 34 additions and 14 deletions

14
.env Normal file
View file

@ -0,0 +1,14 @@
WORDPRESS_VERSION=5.9.3
MYSQL_ROOT_PASSWORD=""
MYSQL_PASSWORD=""
MYSQL_PORT=13306
NGINX_PORT=1312
export BORG_PASSPHRASE=''
export BORG_REPO='cyberbackup:repositories-borg/synthikat'
export BORG_RSH='ssh -F /home/synthikat/.ssh/config -o "StrictHostKeyChecking=no"'
export POD_NAMES='wordpress_wordpress_1 wordpress_db_1'
export FOLDERS_TO_BACKUP='/home/synthikat/wp-content /home/synthikat/db_data /home/synthikat/wordpress'

View file

@ -1,20 +1,26 @@
#!/bin/bash
set -xeou pipefail
# setup env
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
# 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.
podman unshare borg create --stats --progress cyberbackup:repositories-borg/synthikat::'backup{now:%Y%m%d-%M}' ../wp-content ../db_data
# check if these variables have been set
echo "$BORG_REPO" > /dev/null
echo "$BORG_PASSPHRASE" > /dev/null
echo "$FOLDERS_TO_BACKUP" > /dev/null
echo "$POD_NAMES" > /dev/null
# restart the containers
podman start wordpress_wordpress_1 wordpress_db_1
borg check
# Delete all the backups which are too old, to save space in the long term.
borg prune --keep-daily=7 --keep-weekly=4 cyberbackup:repositories-borg/synthikat
# don't fail just because the pod is not running
set +e
podman stop ${POD_NAMES}
set -e
podman unshare borg create --stats ::'backup{now:%Y%m%d-%M}' ${FOLDERS_TO_BACKUP}
borg list
podman start ${POD_NAMES}

View file

@ -6,7 +6,7 @@
podman rm -f wordpress_db_1 wordpress_wordpress_1
# run db container
podman run --name=wordpress_db_1 --detach \
podman run --name=wordpress_db_1 --detach --pull always \
-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
-e MYSQL_DATABASE=wordpress \
-e MYSQL_USER=wordpress \
@ -16,7 +16,7 @@ podman run --name=wordpress_db_1 --detach \
mysql:5.7
# run wordpress container
podman run --name=wordpress_wordpress_1 --detach \
podman run --name=wordpress_wordpress_1 --detach --pull always \
-e WORDPRESS_DB_HOST=78.46.128.202:${MYSQL_PORT} \
-e WORDPRESS_DB_USER=wordpress \
-e WORDPRESS_DB_PASSWORD=${MYSQL_PASSWORD} \