Web lists-archives.com

Re: [Samba] backup-script/backup_samba4




even better regexp (to prevent -01- match january files...)


${CMD_FIND} ${STOREDIR} -name "*.bz2" -mtime +${DAYS} -type f -print | xargs -0 | egrep -v "\-($KEEP_DAY1|$KEEP_DAY2)\-[^-].tar.bz2" | xargs ${CMD_RM} >/dev/null 2>&1


Le 13/04/2018 à 17:54, Arnaud FLORENT via samba a écrit :
Hi!

i am testing Louis van Belle backup script. it works quite well. Thank you for sharing this!

https://github.com/thctlo/samba4/blob/master/backup-script/backup_samba4

but i think there is an error in the KEEP_DAYS code as the string '\-$KEEP_DAY1\-|\-$KEEP_DAY2-' is not interpolated so the egrep does exclude anything from rm call. So no files older than $DAYS are kept...

# Remove any files over $DAYS days old from backup dir, keep the $KEEP_DAY1 and $KEEP_DAY2 of the month.
if [ ${KEEP_DAYS} = "yes" ]; then
    ${DEBUG} "Deleting any backup files over ${DAYS} days old, keeping date $KEEP_DAY1 and $KEEP_DAY2 of the month."     ${CMD_FIND} ${STOREDIR} -name "*.bz2" -mtime +${DAYS} -type f -print | xargs -0 | egrep -v '\-$KEEP_DAY1\-|\-$KEEP_DAY2-' | xargs ${CMD_RM} >/dev/null 2>&1
fi

should be

if [ ${KEEP_DAYS} = "yes" ]; then
    ${DEBUG} "Deleting any backup files over ${DAYS} days old, keeping date $KEEP_DAY1 and $KEEP_DAY2 of the month."     ${CMD_FIND} ${STOREDIR} -name "*.bz2" -mtime +${DAYS} -type f -print | xargs -0 | egrep -v "\-$KEEP_DAY1\-|\-$KEEP_DAY2\-" | xargs ${CMD_RM} >/dev/null 2>&1
fi

I hope this is the right place to report.



--
Arnaud FLORENT
IRIS Technologies

phone: (33) 03 20 65 85 80
fax: (33) 03 20 65 85 81

mailto:aflorent@xxxxxxxxxxxx


--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba