Restoring Mac OS X Server from Time Machine
If you’re running Mac OS X Server 10.5.x or higher, you may be backing it up with Time Machine. However, Time Machine has gotten a bad reputation with some admins because of what Time Machine *doesn’t* back up. That being said, since Time Machine saved my bacon this past weekend, I wanted to post a Time Machine restoration how-to that (depending on your configuration) can be a lifesaver for your Mac or XServe running Mac OS X Server.
To recover the system:
1. Connect the Time Machine backup disk to the server (should already be connected, but double-check.)
If you’re restoring your system because of a problem with the startup disk, make sure the disk has been repaired or replaced.
2. Insert your Mac OS X Server Install disk, and boot from the installer disk.
3. In the Installer, choose Utilities > Restore System from Backup.
4. In the Restore Your System dialog, click Continue.
5. Select your Time Machine backup volume.
6. Select the Time Machine backup you want to restore.
7. Follow the onscreen instructions.
YouTube video showing the recovery process: http://www.youtube.com/watch?v=ZmvwcRJ6sww
Following a Time Machine restore:
Recreate folders that are not included in the Time Machine backup as described below.
Open Terminal (in /Applications/Utilities).
Execute these commands, each on its own line, followed by Return. Note: When using these commands you will be prompted for an administrator’s password.
sudo mkdir /var/log
sudo mkdir /var/log/apache2
sudo mkdir /var/log/samba
sudo mkdir /var/log/swupd
sudo touch /var/log/daily.out
sudo touch /var/log/weekly.out
sudo touch /var/log/monthly.out
To restore the Wiki service (server), run the following commands in addition to those above:
sudo mkdir /Library/Logs/wikid
sudo chown _teamsserver:_teamsserver /Library/Logs/wikid
To restore the Mail service, execute the following command:
sudo /etc/postfix/post-install create-missing
After running these commands, restart the server.
Exceptions to the rule:
Databases – Time Machine is a file-based backup, and doesn’t handle backing up active databases that well. However, it does a good job of backing up database backup files. If you’re running a database on your server (and you are if the server is an Open Directory Master, as OD works from an LDAP database), make sure to set up an automated process that automatically backs up your database to the appropriate backup file (varies by database) on a regular basis.
Mail – On 10.5 Server (I don’t know about 10.6.x Server), Time Machine does not back up the /private/var/spool directory. As a result, nothing in /private/var/spool or the directories inside spool are backed up. This is important for those running a mail server because /private/var/spool/imap which is where IMAP users’ E-mail is stored.
If you’re using Time Machine to back up a 10.5.x server where you’re also running mail services, I recommend that you go to /System/Library/CoreServices/backupd.bundle/Contents/Resources/StdExclusions.plist and comment out the /private/var/spool exclusion using the following:
<!– /private/var/spool –>
Hi,
Very helpful article!
Just for your information:
10.6.x Server is doing a backup of /private/var/spool directory, by default!
All the best,
Bojan
Hi there,
Very helpful article indeed. Than you. It actually helped me to restore our team wiki services back to where they were before the restore.
This might be helpful for other 10.6.x Server users – it seems like Time Machine is backing up / restoring all the var/ directories you instruct to manually create after the restore. I did have to create the .out files however.
Frank
Snow Leopard Server 10.6.8:
% cd /System/Library/CoreServices/backupd.bundle/Contents/Resources
% grep imap StdExclusions.plist
%
Nothing. Looking closer inside (its a text file and not a binary .plist) there is some special treatment for /private/var/spool, says it wants to backup the directory but not the contents of a few select folders:
FileContentsExcluded
/private/var/log
/private/var/spool/cups
/private/var/spool/fax
/private/var/spool/uucp
This is a great article and very helpful
I only wish I’d found it earlier – I just did a TM restore to 10.5 server and OD and Mail are both broken.
I wonder do you know if the Cyrus reconstruct option will get my imap db back? And is there a way to re-import my OD settings from the TM backup? This is the only backup that I have…..
With hope and thanks, David
Dave,
I can’t speak for your mail services, as I haven’t hosted a mail server on 10.5 Server. Depending on your OD problem, if you still have /var/db/openldap on your server, you may be able to use the db_recover tool to fix Open Directory. For more information on that, see here:
http://www.prestonlee.com/2009/07/08/recovering-a-corrupt-openldap-database-on-osx-server/
Hi Rich, Thanks for the link, useful but didn’t help me in this instance. I ended up having to demote and then promote the OD and then it worked. Still having issues with the SSL/kerberos though.
The mailboxes were (mostly) still around in user’s “on my mac” folders which helped – although I have had to manually redeploy them back into each client Mail app!
Thanks for the reply, cheers, Dave.
I need to restore the users from a time machine backup of an iMac but I’m not looking to restore the whole system. Anyone know how to do this?
The free solution that works:
You can go for mirroring your entire Mac’s hard drive to an external FireWire drive.
You can even boot from that disk using any other Mac and have your entire system at your fingertips, no tedious software installations, System Preference setting or desktop wallpaper hunting required.
You need:
External firewire enclosure (usb might work just as well on newer macs)
The free version of SuperDuper.
Step 1. Partition Your External Drive (Optional)
Step 2. Confirm Your New Disk Partitions
Step 3. Start Up and Configure SuperDuper
Step 4. Confirm the Target Disk Erasing
Step 5. Grab a Sandwich
Step 6. In case of emergency => Boot Your Mac from the Clone in Target Disk Mode
DONE…. Do this twice a week and you get REGULAR, BOOTABLE perfect COPIES OF YOUR OS X SERVER. Did i mention you can schedule the backups… wow!