On Tue, Jun 16, 2015 at 02:29:55PM +0200, Paul de Weerd wrote: | --- /etc/lnbackup.conf ----------------------------------------------- | DATESTRING="%Y%m%d" | STOREPREFIX="/backup/HISTORY/daily" | BACKUPPREFIX="/backup/machines" | KEEPCOPIES=190 | KEEPCOPIES=120 | #!/bin/sh | # lnbackup: create historic backups of the backup directories | ###################################################################### <---SNIP--->
Something went wrong here. I included two files, the script and its configuration file. Looks like the mailinglist mangled my mail somehow (the mail is correct in my sent-folder, and hopefully also arrived correctly for Bernd). Cheers, Paul 'WEiRD' de Weerd The configuration file: --- /etc/lnbackup.conf ----------------------------------------------- DATESTRING="%Y%m%d" STOREPREFIX="/backup/HISTORY/daily" BACKUPPREFIX="/backup/machines" KEEPCOPIES=190 KEEPCOPIES=120 ---------------------------------------------------------------------- The script: --- /usr/local/libexec/cronjobs/lnbackup ----------------------------- #!/bin/sh # lnbackup: backup users' homedirs with rsync ###################################################################### PATH=/bin:/usr/bin:/usr/local/bin CONFIG="/etc/lnbackup.conf" if [ -f ${CONFIG} ] then . ${CONFIG} else echo Configuration file \(${CONFIG}\) not found >&2 exit 1 fi NOW=$(date +${DATESTRING}) COUNT=0 if [ ! -r ${USERSFILE} ] then echo Users file not found \(${USERSFILE}\) >&2 exit 2 fi if [ -f ${STOREPREFIX}/.RUNNING ] then PID=$(cat ${STOREPREFIX}/.RUNNING) echo Previous instance still running \(${PID}\) >&2 exit 3 fi echo ${$} > ${STOREPREFIX}/.RUNNING if [ -f ${STOREPREFIX}/PREVIOUS ] then PREVIOUS=$(cat ${STOREPREFIX}/PREVIOUS) else PREVIOUS='0' fi if [ ${NOW} = ${PREVIOUS} ] then echo Backup runs too soon \(${PREVIOUS}\) >&2 exit 4 fi for USER in $(cat ${USERSFILE}) do SRC=${BACKUPPREFIX}/${USER}/ if [ ! -d ${SRC} ] then echo Source not found \(${SRC}\) >&2 exit 5 fi DST=${STOREPREFIX}/${NOW}/${USER} mkdir -p ${DST} PREVDIR=${STOREPREFIX}/${PREVIOUS}/${USER} if [ -d ${PREVDIR} ] then rsync -aHx --link-dest=${PREVDIR} ${SRC} ${DST} else rsync -aHx ${SRC} ${DST} fi done echo ${NOW} > ${STOREPREFIX}/PREVIOUS rm ${STOREPREFIX}/.RUNNING for BACKUP in $(ls ${STOREPREFIX} | grep -v PREVIOUS | tail -r) do SB=${STOREPREFIX}/${BACKUP} YRLY=${STOREPREFIX}/../yearly MNLY=${STOREPREFIX}/../monthly COUNT=$((COUNT + 1)) if [ ${KEEPCOPIES} -lt ${COUNT} ] then if [ ${BACKUP##????} = '0101' ] then mv ${SB} ${YRLY} continue fi if [ ${BACKUP##??????} = '01' ] then mv ${SB} ${MNLY} rm -rf ${MNLY}/$((BACKUP-10000)) continue fi rm -rf ${SB} fi done ---------------------------------------------------------------------- -- >++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+ +++++++++++>-]<.>++[<------------>-]<+.--------------.[-] http://www.weirdnet.nl/