image
image

Go Back   macosx.com > Mac Help Forums > HOWTO & FAQs

Reply
 
Thread Tools
  #1  
Old December 24th, 2002, 01:36 AM
~departed~
 
Join Date: Jul 2002
Location: Kansas City, MO
Posts: 457
Thanks: 0
Thanked 0 Times in 0 Posts
gatorparrots is on a distinguished road
How to backup data to a CD via the command line

Here is how to create a 100MB drive image, backup data to it, and then burn it onto a CD (directly in the commandline, with only the built-in tools). One possible application: This could be easily modified and incorporated into a script that will backup your Entourage mail databases every week, good for up to six uses (6x100MB) depending on the size of your mail data...

hdiutil create -fs HFS+ -volname Backup -size 100m ~/Desktop/backup.dmg
hdiutil mount ~/Desktop/backup.dmg
ditto -rsrc -V ~/Desktop/datatobackup /Volumes/Backup >> /Volumes/Backup/backup.log
hdiutil unmount /Volumes/Backup
hdiutil burn ~/Desktop/backup.dmg -noverifyburn -noeject


It will prompt you for a disc, insert one and it will burn your disc:
Code:
Please insert a disc: 
Starting
Initializing
Saving temporary image
Opening session
Writing track
............................................................................
Finishing writing
............................................................................
Reply With Quote
  #2  
Old December 29th, 2002, 02:42 AM
~departed~
 
Join Date: Jul 2002
Location: Kansas City, MO
Posts: 457
Thanks: 0
Thanked 0 Times in 0 Posts
gatorparrots is on a distinguished road
Backup Entourage Database script

Here is a script to backup the Entourage mail database to a CD. I have mine as a cron task that runs every Friday before I leave work.
The CD tray opens at the set time as if to say "Feed me"!
Simply insert a CD and off it goes! Ahh, the power of Mac OS X.

Please note that this script requires fileutils to be installed. The -h in du -sh is for Human readable, meaning it will return the results in megabytes.
A pre-compiled binary can be obtained here:
http://homepage.mac.com/rgriff/file.html
or fink install fileutils works for those with using the fink pagackage manager.

Code:
#!/bin/sh
#This script will backup your Entourage mail database to a CD

username=YOURSHORTUSERNAME
date=`date +%Y.%m.%d`
size=`/usr/local/bin/du -sh "/Users/$username/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 /Users/$username/Desktop/backup.dmg
/usr/bin/hdiutil mount /Users/$username/Desktop/backup.dmg
/usr/sbin/disktool -r
echo $date >> /Volumes/Backup-$date/backup.log
/usr/bin/ditto -rsrc -V "/Users/$username/Documents/Microsoft User Data/Office X Identities/Main Identity/" /Volumes/Backup-$date/ >> /Volumes/Backup-$date/backup.log
/usr/bin/hdiutil unmount /Volumes/Backup-$date
/usr/bin/hdiutil burn "/Users/$username/Desktop/backup.dmg" -noverifyburn -noeject

#Clean up and relaunch Entourage
/bin/rm "/Users/$username/Desktop/backup.dmg"
/usr/sbin/disktool -r
/usr/bin/osascript -l AppleScript -e 'launch Application "Microsoft Entourage"'
This works very well for those of us with tray-loading drives, as the opening tray is probably sufficient reminder to insert a blank disc.
Those with slot-loading drives should probably add this line before the 'burn' command:
osascript -l AppleScript -e 'tell Application "Finder" to activate & speak "Please insert a blank CD-R disc."'

Last edited by gatorparrots; January 3rd, 2003 at 12:16 AM.
Reply With Quote
  #3  
Old December 29th, 2002, 08:07 PM
Registered User
 
Join Date: Jan 2002
Location: San Jose
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
clc2112 is on a distinguished road
error...

I was able to fix some things but not familiar with the following error.

/sbin/newfs_hfs: /dev/rdisk2s2: partition is too small (minimum is 4 MB)
/usr/bin/hdiutil: detach: "disk2s1" detached successfully.
/usr/bin/hdiutil: detach: "disk2s2" detached successfully.
/usr/bin/hdiutil: detach: "disk2" detached successfully.
hdiutil: create failed - error 256

this is received after the following line in the script:

/usr/bin/hdiutil create -fs HFS+ -volname Backup-$date -size $size /Users/$username/Desktop/backup.dmg

I had to change the du command to du -sk, as "h" was an invalid option..

Thanks for any help..
Reply With Quote
  #4  
Old December 29th, 2002, 09:57 PM
~departed~
 
Join Date: Jul 2002
Location: Kansas City, MO
Posts: 457
Thanks: 0
Thanked 0 Times in 0 Posts
gatorparrots is on a distinguished road
The -h in du -sh is for Human readable, meaning it will return the results in megabytes. I should have made it clear that this requires filetutils to be installed (Sorry about that!). They can be obtained here:
http://homepage.mac.com/rgriff/file.html

If you prefer to keep the default du that comes with the OS, you can easily adapt the script by changing 2 lines in the original script. I have edited my previous post to make this distinction more clear. Hope this clears things up!

Last edited by gatorparrots; December 29th, 2002 at 10:14 PM.
Reply With Quote
  #5  
Old June 6th, 2005, 11:29 AM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
yaelony is on a distinguished road
I have my saved emails in 'mail' not entourage, with many mailboxes. how do we back up mailboxes without using entourage? I would like to backup on idisk if possible or a usb port or whatever makes sense, to back up on a regular basis.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The Authoritative Partitioning Discussion mr. k Mac OS X System & Mac Software 13 November 11th, 2003 07:26 PM
small (?) problem with plist saffron Mac OS X System & Mac Software 5 June 29th, 2003 09:32 AM
backup of large amount of data bogomips Mac OS X System & Mac Software 0 April 23rd, 2003 04:28 AM
Backup 1.2, what is the advantage over Backup 1.0 ? chevy Mac OS X System & Mac Software 2 September 6th, 2002 05:05 PM
Extreme Sys mods - how to backup? bluehz Mac OS X System & Mac Software 4 February 5th, 2002 11:40 AM


All times are GMT -5. The time now is 11:18 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.