Cleaner Job Anlegen
Auf dem Master Server wird der DB Cleaner Job angelegt. Der Server führt täglich das Cleanen der Datenbank aus und löscht alle Dateien, je nach Einstellungen, siehe
Dazu einfach folgendes in die Kommandozeile als root kopieren und ausführen - <password> mit den entsprechenden Passwort ersetzen:
CONFIG_mysql_dump_username='root'
CONFIG_mysql_dump_password='<password>'
CONFIG_backup_dir='/home/jtel/shared/backup/sql'
CONFIG_mysql_dump_host='localhost'
URI="http://downloads.sourceforge.net/project/automysqlbackup/AutoMySQLBackup/AutoMySQLBackup%20VER%203.0/automysqlbackup-v3.0_rc6.tar.gz"
cd /home/jtel
mkdir -p /home/jtel/automysqlbackup
mkdir -p ${CONFIG_backup_dir}
cd /home/jtel/automysqlbackup
curl -O -L ${URI}
tar xfvz ${URI##*/}
cp automysqlbackup.conf automysqlbackup.conf.orig
cp automysqlbackup automysqlbackup.orig
# remove parameter '--password' to fall back to .my.cnf
sed -i -e 's/--password="${CONFIG_mysql_dump_password}" //' automysqlbackup
cat << EOF > /home/jtel/.my.cnf
[client]
user = ${CONFIG_mysql_dump_username}
password = ${CONFIG_mysql_dump_password}
host = ${CONFIG_mysql_dump_host}
EOF
cat /home/jtel/.my.cnf
cat << EOF > automysqlbackup.conf
CONFIG_mysql_dump_username="${CONFIG_mysql_dump_username}"
CONFIG_mysql_dump_password="${CONFIG_mysql_dump_password}"
CONFIG_mysql_dump_host="${CONFIG_mysql_dump_host}"
CONFIG_backup_dir="${CONFIG_backup_dir}"
# Include CREATE DATABASE in backup?
CONFIG_mysql_dump_create_database='yes'
# Separate backup directory and file for each DB? (yes or no)
CONFIG_mysql_dump_use_separate_dirs='no'
# List of databases for Daily/Weekly Backup e.g. ( 'DB1' 'DB2' 'DB3' ... )
# set to (), i.e. empty, if you want to backup all databases
#CONFIG_db_names=()
# List of databases for Monthly Backups.
# set to (), i.e. empty, if you want to backup all databases
#CONFIG_db_month_names=()
# List of DBNAMES to EXLUCDE if DBNAMES is empty, i.e. ().
CONFIG_db_exclude=( 'information_schema' 'performance_schema' )
# Rotation Settings
# Which day do you want monthly backups? (01 to 31)
# If the chosen day is greater than the last day of the month, it will be done
# on the last day of the month.
# Set to 0 to disable monthly backups.
#CONFIG_do_monthly="01"
# Which day do you want weekly backups? (1 to 7 where 1 is Monday)
# Set to 0 to disable weekly backups.
#CONFIG_do_weekly="5"
# Set rotation of daily backups. VALUE*24hours
# If you want to keep only today's backups, you could choose 1, i.e. everything older than 24hours will be removed.
#CONFIG_rotation_daily=6
# Set rotation for weekly backups. VALUE*24hours
#CONFIG_rotation_weekly=35
# Set rotation for monthly backups. VALUE*24hours
#CONFIG_rotation_monthly=150
EOF
/home/jtel/automysqlbackup/automysqlbackup /home/jtel/automysqlbackup/automysqlbackup.conf
cat << 'EOF' > automysqlbackup.cron
#!/bin/bash
su - jtel -c '/home/jtel/automysqlbackup/automysqlbackup /home/jtel/automysqlbackup/automysqlbackup.conf'
EOF
chmod 750 automysqlbackup.cron
sudo ln -s /home/jtel/automysqlbackup/automysqlbackup.cron /etc/cron.daily