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