I've written this little skript to automatically get rid of older snapshots, create new ones and fill them with data using dbcopy to get a persistent copy of the Groupwise postoffice.
The snapshots get their creation date written into their volumename. Those dates are compared before a new snapshot is created and outdated snapshots get removed before dbcopy is called:
#!/bin/sh # Source and target for dbcopy BACKUP_SOURCE=/media/nss/VMPERS/postoffice/ BACKUP_TARGET=/backup/VMPERS/ # Set LVM volume of backup to snapshot SNAPSHOT_DEVICE=/dev/si076_backup/backup # Keep snapshots that long SNAPSHOT_DAYS=2 # Size of snapshot SNAPSHOT_SIZE=50GB for snapshot in ${SNAPSHOT_DEVICE}-*; do if [ $(echo ${snapshot} |sed -e s\!${SNAPSHOT_DEVICE}-\!\!) \ -lt $(date -d "${SNAPSHOT_DAYS} days ago" +"%Y%m%d%H%M%S") ]; then echo -n "Deleting old snapshot at ${snapshot} ... " echo lvremove -f ${snapshot} if [ $? -eq 0 ]; then echo "OK" else echo "FAIL" fi fi done echo lvcreate -s -L ${SNAPSHOT_SIZE} \ -n $(basename ${SNAPSHOT_DEVICE})-$(date +"%Y%m%d%H%M%S") ${SNAPSHOT_DEVICE} /opt/novell/groupwise/agents/bin/dbcopy ${BACKUP_SOURCE} ${BACKUP_TARGET}
Add a comment