changed to mariadb commands

This commit is contained in:
Jonas Forsberg 2023-08-22 09:15:31 +02:00
parent c31f42d34d
commit 238dbfbe67

View File

@ -3,13 +3,13 @@
{%- if pillar['pods']['mariadb'] is defined %} {%- if pillar['pods']['mariadb'] is defined %}
umask 0077 umask 0077
BACKUP_DIR={{ pillar.pods.mariadb.containers.main.backup_dir }} BACKUP_DIR={{ pillar.pods.mariadb.containers.main.backup_dir }}
databases=$(podman exec -it mariadb-main mysql -B -u root -p{{ pillar.pods.mariadb.containers.main.env.MYSQL_ROOT_PASSWORD }} -e "SHOW DATABASES;" | tr -d "| " | grep -v Database) databases=$(podman exec -it mariadb-main mariadb -B -u root -p{{ pillar.pods.mariadb.containers.main.env.MYSQL_ROOT_PASSWORD }} -e "SHOW DATABASES;" | tr -d "| " | grep -v Database)
for db in ${databases[@]}; do for db in ${databases[@]}; do
db=${db::-1} db=${db::-1}
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] && [[ "$db" != "sys" ]]; then if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] && [[ "$db" != "sys" ]]; then
echo "Dumping database: $db" echo "Dumping database: $db"
podman exec -it mariadb-main mysqldump -u root -p{{ pillar.pods.mariadb.containers.main.env.MYSQL_ROOT_PASSWORD }} --databases $db | gzip > ${BACKUP_DIR}/$(date +"%Y-%m-%d_%H-%M-%S")_$db-sql.gz podman exec -it mariadb-main mariadb-dump -u root -p{{ pillar.pods.mariadb.containers.main.env.MYSQL_ROOT_PASSWORD }} --databases $db | gzip > ${BACKUP_DIR}/$(date +"%Y-%m-%d_%H-%M-%S")_$db-sql.gz
fi fi
done done
# Delete the files older than 3 days # Delete the files older than 3 days