backup
This commit is contained in:
parent
d07f953730
commit
83c4c651d3
11
mariadb.yml
11
mariadb.yml
@ -205,13 +205,18 @@
|
|||||||
. /home/docker/_defaults/mariadb/envroot.db
|
. /home/docker/_defaults/mariadb/envroot.db
|
||||||
DAYS=7
|
DAYS=7
|
||||||
TIMESTAMP=$(date +"%Y%m%d%H%M")
|
TIMESTAMP=$(date +"%Y%m%d%H%M")
|
||||||
mariadb-dump -u root -h mariadb.{{inventory_hostname}} --ssl --ssl-verify-server-cert -P 33306 -p${MARIADB_ROOT_PASSWORD} --all-databases >${g_tmp}/dberr | gzip > $BACKUPDIR/MARIADB-$TIMESTAMP.sql.gz || g_echo_error "MariaDB Backup failed $(cat ${g_tmp}/dberr)"
|
|
||||||
|
for i in $(echo "show databases" | mariadb -u root -h mariadb.{{inventory_hostname}} --ssl --ssl-verify-server-cert -P 33306 -p${MARIADB_ROOT_PASSWORD} | grep -v "^Database$")
|
||||||
|
do
|
||||||
|
mariadb-dump -u root -h mariadb.$(hostname) --ssl --ssl-verify-server-cert -P 33306 -p${MARIADB_ROOT_PASSWORD} $i >${g_tmp}/dberr | gzip > $BACKUPDIR/MARIADB-$i-$TIMESTAMP.sql.gz || g_echo_error "MariaDB Backup failed $(cat ${g_tmp}/dberr)"
|
||||||
unset MARIADB_ROOT_PASSWORD
|
unset MARIADB_ROOT_PASSWORD
|
||||||
# dont delete last old backups!
|
# dont delete last old backups!
|
||||||
OLD_BACKUPS=$(ls -1 $BACKUPDIR/$i*.gz | wc -l)
|
OLD_BACKUPS=$(ls -1 $BACKUPDIR/$i*.gz | wc -l)
|
||||||
if [ $OLD_BACKUPS -gt $DAYS ]; then
|
if [ $OLD_BACKUPS -gt $DAYS ]
|
||||||
find $BACKUPDIR -name "$i*.gz" -daystart -mtime +$DAYS -delete
|
then
|
||||||
|
find $BACKUPDIR -name "MARIADB-$i*.gz" -daystart -mtime +$DAYS -delete
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
backup: yes
|
backup: yes
|
||||||
validate: /bin/bash -n %s
|
validate: /bin/bash -n %s
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user