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


Click here to return to the 'Any Other Scripts Available?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Any Other Scripts Available?
Authored by: jasenko on Mar 10, '03 04:15:26PM

Wow, I didn't know that you can create .dmg using command line. I've been thinking about the best way to make constant backups in the background and to preserve all those bloody resource forks creating dmg is the best solution.
I don't have a clue how to use applescript but I'm pretty handy scripting shells so exploring hdiutil will be my priority for the next few days. In the meantime, does anyone have any scripts for home directory backup or something like that using hdiutil and dmg?



[ Reply to This | # ]
Any Other Scripts Available?
Authored by: gatorparrots on Mar 10, '03 06:07:59PM

#!/bin/sh
#This script will back up your Entourage mail database to a CD
username="`who | grep console | awk '{print $1}'`"
if [ "$username" = "" ]; then
echo "No one logged in via GUI (console)" >&2
exit 1
fi
userhome="`eval echo ~$username`"
date=`date +%Y.%m.%d`
size=`/usr/local/bin/du -sh "$userhome/Documents/Microsoft User Data" | awk ' { print $1 } '`

#Quit Entourage and give it time to write its database to disk
/usr/bin/osascript -l AppleScript -e 'tell Application "Microsoft Entourage" to quit'
/bin/sleep 4

/usr/bin/hdiutil create -fs HFS+ -volname Backup-$date -size $size "$userhome/Desktop/backup.dmg"
/usr/bin/hdiutil mount "$username/Desktop/backup.dmg"
/usr/sbin/disktool -r
echo $date >> /Volumes/Backup-$date/backup.log
/usr/bin/ditto -rsrc -V "$userhome/Documents/Microsoft User Data/Office X Identities/Main Identity/"\
/Volumes/Backup-$date/ >> /Volumes/Backup-$date/backup.log
/usr/bin/hdiutil unmount /Volumes/Backup-$date

#a reminder for those with slot loading drives:
/usr/bin/osascript -l AppleScript -e 'tell Application "Finder" to activate & say "Please insert a blank CDR disc."'
/usr/bin/hdiutil burn "/Users/$username/Desktop/backup.dmg" -noverifyburn -noeject

#Clean up and relaunch Entourage
/bin/rm "$userhome/Desktop/backup.dmg"
/usr/sbin/disktool -r
/usr/bin/osascript -l AppleScript -e 'launch Application "Microsoft Entourage"'



[ Reply to This | # ]
Any Other Scripts Available?
Authored by: jasenko on Mar 10, '03 06:11:53PM

Thanks, this is great script, I will adapt it to better suit my needs. I don't have cd burner on my Mac so I have to transfer the dmg to PC first.



[ Reply to This | # ]
Any Other Scripts Available?
Authored by: Thomas Kaiser on Mar 11, '03 05:44:40AM
> does anyone have any scripts [...] like that using hdiutil and dmg?

I just started to write a simple skript for storing files/folders in disk
images. It's intended to work in the shell as well as in Finder (via
DropScript) with a different 'user interface'. It's a work in progress so
far:

<http://users.phg-online.de/tk/MOSXS/Create_compressed _DiskImage.dmg>

Thomas

[ Reply to This | # ]