Created
March 7, 2010 02:00
-
-
Save mrtazz/324095 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# script to backup to a mounted sparseimage | |
# | |
# tests if the image is mounted and if not, | |
# tries to mount it. After backup, the image | |
# is detached again | |
# | |
SOURCE=~/ | |
DEST="/Path/To/Backup_folder" | |
SPARSEIMAGE="/Path/To/Backup_image.sparsebundle" | |
EXCLUDE_FILE="/Path/To/Excludefile" | |
TIME=`date "+%Y-%m-%d %H:%M"` | |
backup () { | |
if [ ! -d $DEST ] | |
then | |
if [ -d $SPARSEIMAGE ] | |
then | |
hdiutil attach $SPARSEIMAGE -quiet | |
echo "Backup image attached." | |
backup | |
else | |
echo "No backup image present. Aborting." | |
exit -1 | |
fi | |
elif [ -d $DEST ] | |
then | |
rsync --recursive -z -a \ | |
--exclude-from=$EXCLUDE_FILE --delete $SOURCE $DEST | |
echo "Backup done." | |
MOUNT=`hdiutil info | grep $DEST | grep disk \ | |
| awk '{print $1}'` | |
hdiutil detach $MOUNT -quiet | |
echo "Backup image detached." | |
exit 0 | |
fi | |
return | |
} | |
echo $TIME | |
backup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>KeepAlive</key> | |
<false/> | |
<key>Label</key> | |
<string>FILELABEL</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/Path/To/backup.sh</string> | |
</array> | |
<key>StartInterval</key> | |
<integer>3600</integer> | |
<key>RunAtLoad</key> | |
<true /> | |
<key>StandardErrorPath</key> | |
<string>/dev/null</string> | |
<key>StandardOutPath</key> | |
<string>/Path/To/Logfile</string> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment