backup config, as of 2021/03/23

This commit is contained in:
2021-03-23 18:15:28 +01:00
parent 43f89ad51f
commit bad21eed07
2 changed files with 73 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
#!/bin/bash
# br, sept 2007 - Dec 2010
SOURCEDIR=/data/ncdata # full path
SERVER=local # could also be user@hostname, or "local" if local ma$
DESTDIR=/mnt/backup1/damia-ncdata # 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'

View File

@@ -0,0 +1,59 @@
#!/bin/bash
# br, sept 2007 - Dec 2010
SOURCEDIR=/ # full path
SERVER=local # could also be user@hostname, or "local" if local ma$
DESTDIR=/mnt/backup1/damia-root # 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.
FILTERNAME=".rsync-filter-system"
FILTER=--filter="dir-merge ${FILTERNAME}"
# 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"
}