Unable to get the supplied purge script from ZRM to play well with the DDR530, I set out to create a suitable stand-in. It's nothing fancy, but if for some reason you cannot get the supplied purge process to work, feel free to give this a spin. It will get the job done without a lot of fuss.
#!/bin/bash
##################################################
# purge-zrm-backups
#
# purges backups without file locking
#
##################################################
BACKUPDIR="/path/to/backups"
PURGELOG="/var/log/mysql-zrm/purgelog"
CURDATE=`date +%s`
TIMESTAMP="date -Iseconds"
echo "$($TIMESTAMP) -- Starting purge session" >> $PURGELOG
for buset in $BACKUPDIR/*
do
for budate in $buset/*
do
KEEP=`grep retention-policy $budate/index | awk -F= '{print$2}'`
WEEKS=${KEEP:0:1}
TICKS=$((WEEKS * 7 * 86400))
CUTOFF=$((CURDATE - TICKS))
TSTAMP=`grep backup-date-epoch $budate/index | awk -F= '{print$2}'`
if [ "$TSTAMP" -lt "$CUTOFF" ]; then
echo "$($TIMESTAMP) -- | Purging $budate" >> $PURGELOG
rm -rf $budate 2>&1 &
fi
done
done
echo "$($TIMESTAMP) -- Finished purge session" >> $PURGELOG
exit 0
No comments:
Post a Comment