Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Mount / unmount external drive for Backup use' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Mount / unmount external drive for Backup use
Authored by: tbaur on Jun 08, '07 02:41:23AM
couple minor fixes -- namely when run by cron, it's probable you won't have a path, so we'll just use full path for diskutil/rsync. cheers.
--- backup.old  2007-06-08 02:35:45.000000000 -0700
+++ backup      2007-06-08 02:36:10.000000000 -0700
@@ -28,7 +28,7 @@
 
 # ==> Backup using rsync to defined mountpoint:/path
 #     ...mount before backup, unmount when completed
-#     version 0.9, this code is not supported.
+#     version 0.9.1, this code is not supported.
 #
 # - create a .backup file on the destination (extra validation)
 # - update the applicable variables: src/dst/name/log
@@ -36,11 +36,11 @@
 # - how logging is done could be more pretty, but it's all good
 #
 # run via crontab(1) as needed:
-#     * 2 * * * /path/to/script
+#     0 2 * * * /path/to/script
 
 
-SRC=/Volumes/
-DST=/Volumes/
+SRC=
+DST=
 NAME=
 log=
 
@@ -48,7 +48,7 @@
   exit 1
 
 
-DEVICE=`diskutil list|grep $NAME|awk '{print $6}'`
+DEVICE=`/usr/sbin/diskutil list|grep $NAME|awk '{print $6}'`
 PROC=`ps auwx | grep "rsync" | grep -v grep | wc -l`
 TOP='1'
 
@@ -63,7 +63,7 @@
                        echo "=> Volume -> $NAME is already mounted" >> $log
                        if [ ! -f $DST/.backup ]; then
                                echo "=> ERROR: Volume did not mount properly (missing .backup?) - exiting" >> $log
-                               diskutil unmount /Volumes/$NAME
+                               /usr/sbin/diskutil unmount /Volumes/$NAME
                                if [ -d $DST ]; then
                                        rmdir $DST
                                fi
@@ -76,12 +76,12 @@
                                if [ -d $DST ]; then
                                        rmdir $DST
                                fi
-                               diskutil mount /dev/$DEVICE
+                               /usr/sbin/diskutil mount /dev/$DEVICE
                                if [ -f $DST/.backup ]; then
                                        echo "=> Volume -> $NAME mounted properly" >> $log
                                        else
                                        echo "=> ERROR: Volume did not mount properly (missing .backup?) - exiting" >> $log
-                                       diskutil unmount /Volumes/$NAME
+                                       /usr/sbin/diskutil unmount /Volumes/$NAME
                                        if [ -d $DST ]; then
                                                rmdir $DST
                                        fi
@@ -94,10 +94,10 @@
                fi
        fi
        echo "=> Starting rsync of $SRC to $DST" >> $log
-       rsync --delete -av $SRC/* $DST >> $log
+       /usr/bin/rsync --delete -av $SRC/* $DST >> $log
        echo "=> Rsync completed ..." >> $log
        echo "=> Unmounting -> $NAME at /dev/$DEVICE" >> $log
-       diskutil unmount /Volumes/$NAME
+       /usr/sbin/diskutil unmount /Volumes/$NAME
        if [ -d $DST ]; then
                rmdir $DST
        fi


[ Reply to This | # ]