Skip to content

Instantly share code, notes, and snippets.

@cnlpete
Created September 19, 2010 18:52
Show Gist options
  • Save cnlpete/587007 to your computer and use it in GitHub Desktop.
Save cnlpete/587007 to your computer and use it in GitHub Desktop.
script for rsnapshot calls, but mount the backup device, before this si done and unmount afterwards. Thisway, we might consume less power, because this is only done oncy a day (or week!!)
#!/bin/bash
RSNAPSHOT=/usr/bin/rsnapshot
DEVICE=/dev/disk/by-label/Backup
MOUNTPNT=/media/Backup
#---------------
mounted=0
#mount
mount | grep "on ${MOUNTPNT} type" > /dev/null
if [ ! $? -eq 0 ] ; then
echo mount $DEVICE $MOUNTPNT
mount $DEVICE $MOUNTPNT
if [ $? -eq 0 ] ; then
mounted=1
fi
fi
#do snapshot with $1 as interval
echo $RSNAPSHOT $1
$RSNAPSHOT $1
#umount
if [ $mounted -eq 1 ] ; then
echo umount $DEVICE
umount $DEVICE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment