|
If you managed to be able to get RsyncX working for backup of your OS X desktops to an OS X Server using my other script on this site, you are probably wondering how to recover a system from such a backup. I've worked out a way to do that from a network boot. Assuming you have already put into place a NetBoot server that will allow you to boot your Macs from a server to an OS X desktop (a good tutorial is found on bombich.com), all you need to go is get RsyncX onto that image and put the script below on the image as well. Then, when you need to do a full system restore to a new disk, you'll boot from the NetBoot server, use Disk Utility to partition and format the drives, then the script below to finish the job. When you partition and format the drives, be sure to use exactly the same names for the drives that you used before. This is how the script will know what files to put on what drives! If it can't find a matching name, it won't restore the disk. The script below will connect to your RsyncX server (provided you modify it with the ID and password information you used to do the backup server), pull down the backup data for a given machine and drive based on parameters you specify, and place it on the appropriate drive. If the drive is bootable, it will issue the relevant commands to make the disk bootable (or at least it will try to).
#/bin/csh # # Automates the restoration of a MacOS X backup # # Syntax: # csh restore.command "thismac" "MacOS X HD" # # where "thismac" is the name of the Mac you're restoring, # and "MacOS X HD" is the name of the drive you're restoring. # The quotes are necessary if either the Mac name or the drive # name contains spaces. # # ------------------------------------------------------------ # Last Updated: 04/04/2005 # By: Mike Salsbury # ------------------------------------------------------------ # # Pick up the Mac and drive name from the command line. # echo " " # # Deal with potential error of user not supplying Mac name and drive # name to restore. # if ( $#argv == 0 ) then echo "Need to specify macname and drivename. For example:" echo " " echo "csh restore.command 'thismac' 'MacOS X HD'" echo "but with double-quotes where the single-quote appears above." exit endif # # Deal with the user supplying too many command-line arguments, # or forgetting to put quotes where you need them. # if ( $#argv > 2 ) then echo "You supplied too many arguments. This probably means you" echo "didn't put double-quotes around a Mac name or drive name" echo "that contains a space." echo " " echo "For example, if you were going to restore a drive with the" echo "name 'MacOS X HD' you should have entered:" echo " " echo "csh restore.command "thismac" "MacOS X HD"" exit endif echo "Restoring a Mac drive from the backup." echo " " set macname = "$1" set drivename = "$2" # # Make sure that the user specifies a Mac name. # if ( "" == "$macname" ) then echo "Please specify a Macintosh name." exit else echo "The Mac to be restored is named: $macname" endif # # Make sure the user specifies a Volume name. # if ( "" == "$drivename" ) then echo "Please specify a drive to be restored." exit else echo "The drive to be restored is named: '$drivename'" endif # # Call RsyncX to restore the selected drive # if ( -d "/Volumes/$drivename" ) then echo " " echo "Located the drive to be restored (/Volumes/$drivename)." else clear echo " " echo "*** ERROR! ***" echo " " echo "Can't locate the drive '$drivename' that you've asked to restore." echo "This probably means that you either haven't used Disk Utility to" echo "partition and format the drive properly, or you have not named it" echo "correctly, or you entered it incorrectly above." echo " " echo "The available disk volumes on this system are:" echo " " ls -lag /Volumes echo " " echo "*** SCRIPT TERMINATED ***" exit endif # # Call RsyncX to restore the drive # echo " " echo "Restoring the drive '$drivename' from the backup..." /usr/local/bin/rsync -rlHpogDtSP --eahfs --password-file="/Library/Admin/rspw.txt" "rsync://backupid@backupserver/backup/$macname/$drivename/" "/Volumes/$drivename" # # Clear screen and let user know we've completed the restore. # clear echo " " echo "Restoration completed." echo " " # # If we can detect a MacOS 9 System Folder, bless it now. # If we can't, tell the user we can't find it. # if ( -d "/Volumes/$drivename/System Folder" ) then echo "Found OS 9 System Folder. Blessing it now." # bless of OS 9 cd "/Volumes/$drivename" bless -folder9 "/Volumes/$drivename/System Folder/" -bootBlocks else echo "OS9 System Folder not found" endif # # If we can detect an OS X System Folder, bless it and repair the # UNIX permissions so it can boot. If we can't, let the user know # we can't find an OS X system folder. # if ( -d "/Volumes/$drivename/System/Library/CoreServices" ) then echo "Detected OS X System directory. Blessing it now." cd "/Volumes/$drivename" bless -folder "/Volumes/$drivename/System/Library/CoreServices" -bootinfo ./usr/standalone/ppc/bootx.bootinfo -setBoot # run disk utility to repair permissions echo "Repairing permissions on $drivename..." diskutil repairPermissions "/Volumes/$drivename" else echo "OSX Core Services folder doesn't exist" endif # # Let the user know we're finished. # echo " " echo "*** RESTORATION COMPLETE ***"
Related Blogs:
Related Links:
|