From baf81e0e8de4efdae353b9e89d5f6b7c34ac36ed Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Tue, 23 Mar 2021 18:19:10 +0100 Subject: [PATCH] complete /mnt-mountpoint backup. --- damia/root/data/config-mountpoint.data | 56 ++++++++++++++++++++++++++ damia/root/data/config-partition.data | 31 +------------- 2 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 damia/root/data/config-mountpoint.data diff --git a/damia/root/data/config-mountpoint.data b/damia/root/data/config-mountpoint.data new file mode 100644 index 0000000..b236d50 --- /dev/null +++ b/damia/root/data/config-mountpoint.data @@ -0,0 +1,56 @@ +#!/bin/bash +# br, sept 2007 - Dec 2010 + +SOURCEDIR=/mnt/my-mountpoint # full path +SERVER=local # could also be user@hostname, or "local" if local ma$ +DESTDIR=/mnt/backup1/damia-mountpoint # full path, or relative to home dir$ + +NYEARS=3 +NMONTHS=12 +NWEEKS=4 +NDAYS=7 + +# filter: can be used in every directory within the "source" dir. +FILTER=--filter='dir-merge .filter-rule' + +# other rsync options +RSYNCOPTS="" + +# functions run just before and after the rsync. Could be useful to create +# database dumps, etc... +function beforesync() { + # next line may be removed if you do something. bash does not like empty + # functions + log -s -t "calling user beforesync: mysql databases dumps..." + + datadir=$(mysql -sN -u root -p'@Fa1952%' -e 'select @@datadir') + # log "mysql datadir=${datadir}" + rm -f "{datadir}/${FILTERNAME}" + + databases=($(mysql -sN -u root -p'@Fa1952%' -e "SHOW DATABASES;")) + + for db in "${databases[@]}" + do + # do not backup database contents itself + echo "- /${db}/*" >> "${datadir}/${FILTERNAME}" + log -n "${db}... " + case "$db" in + information_schema|performance_schema) + log "skipped." + ;; + *) + log -n "dumping to ${datadir}${db}.sql... " + mysqldump --user=root --routines "$db" > "$datadir/$db.sql" + log -n "compressing... " + gzip -f "${datadir}/${db}.sql" + log "done." + esac + done + # log "filtername contains:" + # cat ${datadir}/${FILTERNAME} +} + +function aftersync() { + # we may remove the dump here... + log -s -t "calling user aftersync" +} diff --git a/damia/root/data/config-partition.data b/damia/root/data/config-partition.data index 6d93407..300c954 100644 --- a/damia/root/data/config-partition.data +++ b/damia/root/data/config-partition.data @@ -23,37 +23,10 @@ RSYNCOPTS="" function beforesync() { # next line may be removed if you do something. bash does not like empty # functions - log -s -t "calling user beforesync: mysql databases dumps..." - - datadir=$(mysql -sN -u root -p'@Fa1952%' -e 'select @@datadir') - # log "mysql datadir=${datadir}" - rm -f ${datadir}/${FILTERNAME} - - databases=($(mysql -sN -u root -p'@Fa1952%' -e "SHOW DATABASES;")) - - for db in "${databases[@]}" - do - # do not backup database contents itself - echo "- /${db}/*" >> ${datadir}/${FILTERNAME} - log -n "${db}... " - case "$db" in - information_schema|performance_schema) - log "skipped." - ;; - *) - log -n "dumping to ${datadir}${db}.sql... " - mysqldump --user=root --routines ${db} > ${datadir}/${db}.sql - log -n "compressing... " - gzip -f ${datadir}/${db}.sql - log "done." - esac - done - # log "filtername contains:" - # cat ${datadir}/${FILTERNAME} + : } function aftersync() { # we may remove the dump here... - log -s -t "calling user aftersync" + : } -