#!/bin/sh # This is a program to backup stuff on OS X # create an image, burn it to CDR/RW media # 2003-09-24 Troy R. Lowe Created Initial Draft # # Variables Set Here # set the date to year.month.day date=`date +%Y.%m.%d` # where is the backup folder going to be? backupdirectory="/Users/account1/backup" # where will the image be built? imagelocation="/Users/account1/backup.dmg" # What will the new image's volume name be? volumename="Account1_Backup" # Done setting main variables # Need to create directories and such that will be expected later # If the backup folder exists, touch it to modify date to today, otherwise, create the backup folder if (test -d $backupdirectory) then touch $backupdirectory else mkdir $backupdirectory fi if (test -d $backupdirectory/$date) then touch $backupdirectory/$date else mkdir $backupdirectory/$date fi # If the volume name I want to use is already mounted, unmount it if (test -e /Volumes/$volumename) then hdiutil unmount /Volumes/$volumename fi # If the image already exists, delete it if (test -e $imagelocation) then rm -f $imagelocation fi # Done with prep work # Move the important stuff that I want backed up to the "backup" folder #Determine what you want to backup and then follow the template #cp -rp $full_path_to_source $backupdirectory/$date/ # Apple Mail.app stores mail messages here cp -rp /Users/account1/Library/Mail $backupdirectory/$date/Mail # had to dig for Mozilla's bookmark location cp -rp /Users/account1/Library/Mozilla/Profiles/default/j4p27wle.slt/bookmarks.html $backupdirectory/$date/bookmarks.html # QuickBooks File cp -rp /Users/account1/Documents/Books1 $backupdirectory/$date/ # Quicken File cp -rp /Users/account1/Documents/Money1 $backupdirectory/$date/ # Palm Desktop data cp -rp /Users/account1/Documents/Palm/Users/account1 $backupdirectory/$date/Palm # Personal Documents Directory cp -r "/Users/account1/Documents/Account1's Stuff" $backupdirectory/$date/Account1_Stuff # done moving important files to the backup directory # Figure out the size of the backup directory contents sizeofbackup=`/usr/bin/du -ks $backupdirectory | awk '{print $1}'` # I will make the image 15 Megs bigger than the stuff I have just to be safe Note: I added the k outside the actual command sizeofimage=`/bin/expr $sizeofbackup + 15000`k # time to make an image hdiutil create -fs HFS+ -volname $volumename -size $sizeofimage $imagelocation # mount the image hdiutil mount $imagelocation # sync the data in the backup folder with the new mounted image ditto -rsrc -V $backupdirectory /Volumes/$volumename # unmount the new image hdiutil unmount /Volumes/$volumename # erase the disk - I can fit a lot of these images on a CD, no need to erase it # hdiutil burn -erase # -- NOTE: If you are using the Applescript wrapper, you need to comment # out this line by adding a # in front of the line so that apple_backup_burn.sh # does this work instead -- hdiutil burn $imagelocation -noverifyburn -noeject # ----------------------------- apple_backup_burn.sh ------------------------------- # These lines are the contents of apple_backup_burn.sh if you want to use the # applescript wrapper script, save these lines to file /Users/account1/apple_backup_burn.sh # and remove the first # (and only the first #) of each of these lines. # --- first line of apple_backup_burn.sh below this line -- # ##!/bin/sh ## where will the image be built? # imagelocation="/Users/account1/backup.dmg" ## burn the image to disk !! NOTE: You will be prompted for CDR/RW media at this point !! # hdiutil burn $imagelocation -noverifyburn -noeject ## -- end of apple_backupburn.sh -- ##