Du kannst nicht mehr als 25 Themen auswählen
Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
|
- #!/bin/bash
-
- # Variables
- BACKUP_ROOT_MYSQL="/backup/mysql"
- MYSQL_BIN=/usr/bin/mysql
- MYSQLDUMP_BIN=/usr/bin/mysqldump
- MYSQL_USER=backupuser
- MYSQL_PASSWORD=backuppwd
- GZIP_BIN=/bin/gzip
- BACKUP_ROOT_MYSQL_RETENTION=10
-
- # Starting backup
- echo "Starting MariaDB backup database process ..."
-
- # Create directories if not exists
- mkdir -p ${BACKUP_ROOT_MYSQL}
- HOUR=`date +%Y%m%d%H%M`
-
- # Backup with dump the structure
- DATABASES=`${MYSQL_BIN} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -e 'SHOW DATABASES' | grep -v - | grep -v Database | grep -v information_schema | grep -v performance_schema | grep -v \|`
- for DB in $DATABASES;
- do
- ${MYSQLDUMP_BIN} -u ${MYSQL_USER} -p${MYSQL_PASSWORD} ${DB} | ${GZIP_BIN} > ${BACKUP_ROOT_MYSQL}/${DB}_${HOUR}.sql.gz
- if [ $? -ne 0 ]; then
- echo "ERROR - Dump for ${DB}"
- fi
- done
-
- # Purge old backup
- echo "Starting MariaDB purge database process ..."
- find ${BACKUP_ROOT_MYSQL} -type f -mtime +${BACKUP_ROOT_MYSQL_RETENTION} -exec rm -f {} \;
|