update scripts

This commit is contained in:
0x90.space 2023-12-07 21:55:15 +00:00
parent 3514bbb9df
commit fd02d6f704
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 #!/bin/bash
set -xeou pipefail
# setup env
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR cd $DIR
. ./.env . ./.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: # check if these variables have been set
# backup: is the remote backup server, defined in ~/.ssh/config - ends with a : echo "$BORG_REPO" > /dev/null
# repositories-borg/synthikat is the path on the remote server - ends with a :: echo "$BORG_PASSPHRASE" > /dev/null
# 'backup{now:%Y%m%d}' is the backup name, this includes today's date in the name echo "$FOLDERS_TO_BACKUP" > /dev/null
# the rest are the file paths. You can append as many as you want. echo "$POD_NAMES" > /dev/null
podman unshare borg create --stats --progress cyberbackup:repositories-borg/synthikat::'backup{now:%Y%m%d-%M}' ../wp-content ../db_data
# restart the containers borg check
podman start wordpress_wordpress_1 wordpress_db_1
# Delete all the backups which are too old, to save space in the long term. # don't fail just because the pod is not running
borg prune --keep-daily=7 --keep-weekly=4 cyberbackup:repositories-borg/synthikat 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 podman rm -f wordpress_db_1 wordpress_wordpress_1
# run db container # 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_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
-e MYSQL_DATABASE=wordpress \ -e MYSQL_DATABASE=wordpress \
-e MYSQL_USER=wordpress \ -e MYSQL_USER=wordpress \
@ -16,7 +16,7 @@ podman run --name=wordpress_db_1 --detach \
mysql:5.7 mysql:5.7
# run wordpress container # 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_HOST=78.46.128.202:${MYSQL_PORT} \
-e WORDPRESS_DB_USER=wordpress \ -e WORDPRESS_DB_USER=wordpress \
-e WORDPRESS_DB_PASSWORD=${MYSQL_PASSWORD} \ -e WORDPRESS_DB_PASSWORD=${MYSQL_PASSWORD} \