Import last zzz_evobackup file version
This commit is contained in:
parent
c242733808
commit
9a07552731
|
@ -30,7 +30,7 @@ SERVERS="node0.backup.example.com:2XXX node1.backup.example.com:2XXX"
|
||||||
SERVERS_FALLBACK=${SERVERS_FALLBACK:-1}
|
SERVERS_FALLBACK=${SERVERS_FALLBACK:-1}
|
||||||
|
|
||||||
# timeout (in seconds) for SSH connections
|
# timeout (in seconds) for SSH connections
|
||||||
SSH_CONNECT_TIMEOUT=${SSH_CONNECT_TIMEOUT:-30}
|
SSH_CONNECT_TIMEOUT=${SSH_CONNECT_TIMEOUT:-90}
|
||||||
|
|
||||||
## We use /home/backup : feel free to use your own dir
|
## We use /home/backup : feel free to use your own dir
|
||||||
LOCAL_BACKUP_DIR="/home/backup"
|
LOCAL_BACKUP_DIR="/home/backup"
|
||||||
|
@ -83,7 +83,7 @@ test_server() {
|
||||||
else
|
else
|
||||||
# SSH connection failed
|
# SSH connection failed
|
||||||
new_error=$(printf "Failed to connect to \`%s' within %s seconds" "${item}" "${SSH_CONNECT_TIMEOUT}")
|
new_error=$(printf "Failed to connect to \`%s' within %s seconds" "${item}" "${SSH_CONNECT_TIMEOUT}")
|
||||||
SERVERS_SSH_ERRORS=$(printf "%s\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
SERVERS_SSH_ERRORS=$(printf "%s\\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -96,16 +96,16 @@ pick_server() {
|
||||||
if [ "${increment}" -ge "${list_length}" ]; then
|
if [ "${increment}" -ge "${list_length}" ]; then
|
||||||
# We've reached the end of the list
|
# We've reached the end of the list
|
||||||
new_error="No more server available"
|
new_error="No more server available"
|
||||||
SERVERS_SSH_ERRORS=$(printf "%s\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
SERVERS_SSH_ERRORS=$(printf "%s\\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
||||||
|
|
||||||
# Log errors to stderr
|
# Log errors to stderr
|
||||||
printf "%s\n" "${SERVERS_SSH_ERRORS}" >&2
|
printf "%s\\n" "${SERVERS_SSH_ERRORS}" >&2
|
||||||
# Log errors to logfile
|
# Log errors to logfile
|
||||||
printf "%s\n" "${SERVERS_SSH_ERRORS}" >> $LOGFILE
|
printf "%s\\n" "${SERVERS_SSH_ERRORS}" >> $LOGFILE
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract the day of month, without leading 0 (which would give an octal based number)
|
# Extract the day of month, without leading 0 (which would give an octal based number)
|
||||||
today=$(date +%e)
|
today=$(date +%e)
|
||||||
# A salt is useful to randomize the starting point in the list
|
# A salt is useful to randomize the starting point in the list
|
||||||
# but stay identical each time it's called for a server (based on hostname).
|
# but stay identical each time it's called for a server (based on hostname).
|
||||||
|
@ -123,14 +123,14 @@ pick_server() {
|
||||||
if [ -e "${PIDFILE}" ]; then
|
if [ -e "${PIDFILE}" ]; then
|
||||||
pid=$(cat "${PIDFILE}")
|
pid=$(cat "${PIDFILE}")
|
||||||
# Does process still exist ?
|
# Does process still exist ?
|
||||||
if kill -0 ${pid} 2> /dev/null; then
|
if kill -0 "${pid}" 2> /dev/null; then
|
||||||
# Killing the childs of evobackup.
|
# Killing the childs of evobackup.
|
||||||
for ppid in $(pgrep -P "${pid}"); do
|
for ppid in $(pgrep -P "${pid}"); do
|
||||||
kill -9 "${ppid}";
|
kill -9 "${ppid}";
|
||||||
done
|
done
|
||||||
# Then kill the main PID.
|
# Then kill the main PID.
|
||||||
kill -9 "${pid}"
|
kill -9 "${pid}"
|
||||||
printf "%s is still running (PID %s). Process has been killed" "$0" "${pid}\n" >&2
|
printf "%s is still running (PID %s). Process has been killed" "$0" "${pid}\\n" >&2
|
||||||
else
|
else
|
||||||
rm -f ${PIDFILE}
|
rm -f ${PIDFILE}
|
||||||
fi
|
fi
|
||||||
|
@ -160,29 +160,33 @@ if [ "${LOCAL_TASKS}" = "1" ]; then
|
||||||
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -P 3306 -Q --opt --events --hex-blob --skip-comments \
|
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -P 3306 -Q --opt --events --hex-blob --skip-comments \
|
||||||
# --fields-enclosed-by='\"' --fields-terminated-by=',' -T /home/mysqldump/$i $i; done
|
# --fields-enclosed-by='\"' --fields-terminated-by=',' -T /home/mysqldump/$i $i; done
|
||||||
|
|
||||||
|
## Dump all grants (requires 'percona-toolkit' package)
|
||||||
|
# mkdir -p -m 700 ${LOCAL_BACKUP_DIR}/mysql/
|
||||||
|
# pt-show-grants --flush --no-header > ${LOCAL_BACKUP_DIR}/mysql/all_grants.sql
|
||||||
|
|
||||||
## example with SQL dump (schema only, no data) for each databases
|
## example with SQL dump (schema only, no data) for each databases
|
||||||
# mkdir -p -m 700 /home/mysqldump/
|
# mkdir -p -m 700 ${LOCAL_BACKUP_DIR}/mysql/
|
||||||
# for i in $(mysql --defaults-extra-file=/etc/mysql/debian.cnf -P 3306 -e 'show databases' -s --skip-column-names \
|
# for i in $(mysql --defaults-extra-file=/etc/mysql/debian.cnf -P 3306 -e 'show databases' -s --skip-column-names \
|
||||||
# | egrep -v "^(Database|information_schema|performance_schema|sys)"); do
|
# | egrep -v "^(Database|information_schema|performance_schema|sys)"); do
|
||||||
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -P 3306 --no-data --databases $i > /home/mysqldump/${i}.schema.sql
|
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -P 3306 --no-data --databases $i > ${LOCAL_BACKUP_DIR}/mysql/${i}.schema.sql
|
||||||
# done
|
# done
|
||||||
|
|
||||||
## example with compressed SQL dump (with data) for each databases
|
## example with compressed SQL dump (with data) for each databases
|
||||||
# mkdir -p -m 700 /home/mysqldump/
|
# mkdir -p -m 700 ${LOCAL_BACKUP_DIR}/mysql/
|
||||||
# for i in $(mysql --defaults-extra-file=/etc/mysql/debian.cnf -P 3306 -e 'show databases' -s --skip-column-names \
|
# for i in $(mysql --defaults-extra-file=/etc/mysql/debian.cnf -P 3306 -e 'show databases' -s --skip-column-names \
|
||||||
# | egrep -v "^(Database|information_schema|performance_schema|sys)"); do
|
# | egrep -v "^(Database|information_schema|performance_schema|sys)"); do
|
||||||
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -P 3306 --events --hex-blob $i | gzip --best > /home/mysqldump/${i}.sql.gz
|
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -P 3306 --events --hex-blob $i | gzip --best > ${LOCAL_BACKUP_DIR}/mysql/${i}.sql.gz
|
||||||
# done
|
# done
|
||||||
|
|
||||||
## example with *one* uncompressed SQL dump for *one* database (MYBASE)
|
## example with *one* uncompressed SQL dump for *one* database (MYBASE)
|
||||||
# mkdir -p -m 700 /home/mysqldump/MYBASE
|
# mkdir -p -m 700 ${LOCAL_BACKUP_DIR}/mysql/MYBASE
|
||||||
# chown -RL mysql /home/mysqldump/
|
# chown -RL mysql ${LOCAL_BACKUP_DIR}/mysql/
|
||||||
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -Q \
|
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -Q \
|
||||||
# --opt --events --hex-blob --skip-comments -T /home/mysqldump/MYBASE MYBASE
|
# --opt --events --hex-blob --skip-comments -T ${LOCAL_BACKUP_DIR}/mysql/MYBASE MYBASE
|
||||||
|
|
||||||
## example with mysqlhotcopy
|
## example with mysqlhotcopy
|
||||||
# mkdir -p -m 700 /home/mysqlhotcopy/
|
# mkdir -p -m 700 ${LOCAL_BACKUP_DIR}/mysqlhotcopy/
|
||||||
# mysqlhotcopy BASE /home/mysqlhotcopy/
|
# mysqlhotcopy BASE ${LOCAL_BACKUP_DIR}/mysql/mysqlhotcopy/
|
||||||
|
|
||||||
## example for multiples MySQL instances
|
## example for multiples MySQL instances
|
||||||
# mysqladminpasswd=$(grep -m1 'password = .*' /root/.my.cnf|cut -d" " -f3)
|
# mysqladminpasswd=$(grep -m1 'password = .*' /root/.my.cnf|cut -d" " -f3)
|
||||||
|
@ -225,7 +229,14 @@ if [ "${LOCAL_TASKS}" = "1" ]; then
|
||||||
## Redis
|
## Redis
|
||||||
|
|
||||||
## example with copy .rdb file
|
## example with copy .rdb file
|
||||||
|
## for the default instance :
|
||||||
# cp /var/lib/redis/dump.rdb ${LOCAL_BACKUP_DIR}/
|
# cp /var/lib/redis/dump.rdb ${LOCAL_BACKUP_DIR}/
|
||||||
|
## for multiple instances :
|
||||||
|
# for instance in $(ls -d /var/lib/redis-*); do
|
||||||
|
# name=$(basename $instance)
|
||||||
|
# mkdir -p ${LOCAL_BACKUP_DIR}/${name}
|
||||||
|
# cp -a ${instance}/dump.rdb ${LOCAL_BACKUP_DIR}/${name}
|
||||||
|
# done
|
||||||
|
|
||||||
## ElasticSearch
|
## ElasticSearch
|
||||||
|
|
||||||
|
@ -295,7 +306,7 @@ if [ "${LOCAL_TASKS}" = "1" ]; then
|
||||||
|
|
||||||
## Dump findmnt(8) output
|
## Dump findmnt(8) output
|
||||||
FINDMNT_BIN=$(command -v findmnt)
|
FINDMNT_BIN=$(command -v findmnt)
|
||||||
if [ -x ${FINDMNT_BIN} ]; then
|
if [ -x "${FINDMNT_BIN}" ]; then
|
||||||
${FINDMNT_BIN} > ${LOCAL_BACKUP_DIR}/findmnt.txt
|
${FINDMNT_BIN} > ${LOCAL_BACKUP_DIR}/findmnt.txt
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -362,36 +373,49 @@ if [ "${SYNC_TASKS}" = "1" ]; then
|
||||||
# Remote shell command
|
# Remote shell command
|
||||||
RSH_COMMAND="ssh -p ${SSH_PORT} -o 'ConnectTimeout ${SSH_CONNECT_TIMEOUT}'"
|
RSH_COMMAND="ssh -p ${SSH_PORT} -o 'ConnectTimeout ${SSH_CONNECT_TIMEOUT}'"
|
||||||
|
|
||||||
rsync -avzh --stats --delete --delete-excluded --force --ignore-errors --partial \
|
# ignore check because we want it to split the different arguments to $rep
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
rsync -avzh --relative --stats --delete --delete-excluded --force --ignore-errors --partial \
|
||||||
|
--exclude "dev" \
|
||||||
--exclude "lost+found" \
|
--exclude "lost+found" \
|
||||||
--exclude ".nfs.*" \
|
--exclude ".nfs.*" \
|
||||||
--exclude "/var/log" \
|
--exclude "/usr/doc" \
|
||||||
--exclude "/var/log/evobackup*" \
|
--exclude "/usr/obj" \
|
||||||
|
--exclude "/usr/share/doc" \
|
||||||
|
--exclude "/usr/src" \
|
||||||
|
--exclude "/var/apt" \
|
||||||
|
--exclude "/var/cache" \
|
||||||
|
--exclude "/var/lib/amavis/amavisd.sock" \
|
||||||
|
--exclude "/var/lib/amavis/tmp" \
|
||||||
|
--exclude "/var/lib/clamav/*.tmp" \
|
||||||
|
--exclude "/var/lib/elasticsearch" \
|
||||||
|
--exclude "/var/lib/metche" \
|
||||||
|
--exclude "/var/lib/munin/*tmp*" \
|
||||||
--exclude "/var/lib/mysql" \
|
--exclude "/var/lib/mysql" \
|
||||||
|
--exclude "/var/lib/php5" \
|
||||||
|
--exclude "/var/lib/php/sessions" \
|
||||||
--exclude "/var/lib/postgres" \
|
--exclude "/var/lib/postgres" \
|
||||||
--exclude "/var/lib/postgresql" \
|
--exclude "/var/lib/postgresql" \
|
||||||
--exclude "/var/lib/sympa" \
|
--exclude "/var/lib/sympa" \
|
||||||
--exclude "/var/lib/metche" \
|
|
||||||
--exclude "/var/run" \
|
|
||||||
--exclude "/var/lock" \
|
--exclude "/var/lock" \
|
||||||
--exclude "/var/state" \
|
--exclude "/var/log" \
|
||||||
--exclude "/var/apt" \
|
--exclude "/var/log/evobackup*" \
|
||||||
--exclude "/var/cache" \
|
--exclude "/var/run" \
|
||||||
--exclude "/usr/src" \
|
|
||||||
--exclude "/usr/doc" \
|
|
||||||
--exclude "/usr/share/doc" \
|
|
||||||
--exclude "/usr/obj" \
|
|
||||||
--exclude "dev" \
|
|
||||||
--exclude "/var/spool/postfix" \
|
--exclude "/var/spool/postfix" \
|
||||||
--exclude "/var/lib/amavis/amavisd.sock" \
|
|
||||||
--exclude "/var/lib/munin/*tmp*" \
|
|
||||||
--exclude "/var/lib/php5" \
|
|
||||||
--exclude "/var/spool/squid" \
|
--exclude "/var/spool/squid" \
|
||||||
--exclude "/var/lib/elasticsearch" \
|
--exclude "/var/state" \
|
||||||
--exclude "/var/lib/amavis/tmp" \
|
--exclude "lxc/*/rootfs/usr/doc" \
|
||||||
--exclude "/var/lib/clamav/*.tmp" \
|
--exclude "lxc/*/rootfs/usr/obj" \
|
||||||
|
--exclude "lxc/*/rootfs/usr/share/doc" \
|
||||||
|
--exclude "lxc/*/rootfs/usr/src" \
|
||||||
|
--exclude "lxc/*/rootfs/var/apt" \
|
||||||
|
--exclude "lxc/*/rootfs/var/cache" \
|
||||||
|
--exclude "lxc/*/rootfs/var/lib/php5" \
|
||||||
|
--exclude "lxc/*/rootfs/var/lock" \
|
||||||
|
--exclude "lxc/*/rootfs/var/log" \
|
||||||
|
--exclude "lxc/*/rootfs/var/run" \
|
||||||
|
--exclude "lxc/*/rootfs/var/state" \
|
||||||
--exclude "/home/mysqltmp" \
|
--exclude "/home/mysqltmp" \
|
||||||
--exclude "/var/lib/php/sessions" \
|
|
||||||
${rep} \
|
${rep} \
|
||||||
/etc \
|
/etc \
|
||||||
/root \
|
/root \
|
||||||
|
@ -406,11 +430,11 @@ fi
|
||||||
|
|
||||||
END=$(/bin/date +"%d-%m-%Y ; %H:%M")
|
END=$(/bin/date +"%d-%m-%Y ; %H:%M")
|
||||||
|
|
||||||
printf "EvoBackup - %s - START %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\n" \
|
printf "EvoBackup - %s - START %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\\n" \
|
||||||
"${HOSTNAME}" "${BEGINNING}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
"${HOSTNAME}" "${BEGINNING}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
||||||
>> $LOGFILE
|
>> $LOGFILE
|
||||||
|
|
||||||
printf "EvoBackup - %s - STOP %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\n" \
|
printf "EvoBackup - %s - STOP %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\\n" \
|
||||||
"${HOSTNAME}" "${END}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
"${HOSTNAME}" "${END}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
||||||
>> $LOGFILE
|
>> $LOGFILE
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue