This commit is contained in:
julien 2025-01-19 15:38:05 +01:00
parent af8d575ef7
commit 3d071c9f0a

View File

@ -15,10 +15,7 @@ if [ -d "volumes/mysql" ]; then
DB_USER=$(nerdctl exec $CONTAINER_NAME bash -c 'echo "$MYSQL_USER"')
DB_PASSWORD=$(nerdctl exec $CONTAINER_NAME bash -c 'echo "$MYSQL_PASSWORD"')
DB_NAME=$(nerdctl exec $CONTAINER_NAME bash -c 'echo "$MYSQL_DATABASE"')
DUMP_NAME=$CONTAINER_NAME_$(date +%F_%T).sql
if [ -f "volumes/*.sql" ]; then
rm volumes/*.sql
fi
DUMP_NAME=$CONTAINER_NAME.sql
nerdctl exec -e MYSQL_PWD=$DB_PASSWORD $CONTAINER_NAME mariadb-dump -u $DB_USER $DB_NAME > volumes/$DUMP_NAME
fi
@ -28,16 +25,14 @@ if [ -d "volumes/postgres" ]; then
DB_USER=$(nerdctl exec $CONTAINER_NAME bash -c 'echo "$POSTGRES_USER"')
DB_PASSWORD=$(nerdctl exec $CONTAINER_NAME bash -c 'echo "$POSTGRES_PASSWORD"')
DB_NAME=$(nerdctl exec $CONTAINER_NAME bash -c 'echo "$POSTGRES_DATABASE"')
DUMP_NAME=$CONTAINER_NAME
if [ -f "volumes/*.sql" ]; then
rm volumes/*.sql
fi
DUMP_NAME=$CONTAINER_NAME.sql
nerdctl exec -e $CONTAINER_NAME pg_dump -U $DB_USER $DB_NAME > volumes/$DUMP_NAME
fi
# Compress all volumes excerpt mysql and postgres into the storage box (pubkey needed)
BACKUP=${PWD##*/}.tar.zst
tar --zstd -cf /tmp/$BACKUP -C volumes .
rm volumes/$DUMP_NAME
TODAY=$(date +%F)
scp -r /tmp/$BACKUP u442569@u442569.your-storagebox.de:$TODAY/$BACKUP
scp -r /tmp/$BACKUP u442569@u442569.your-storagebox.de:/$TODAY/$BACKUP
rm /tmp/$BACKUP