10.5: Make Time Machine work well with Entourage 2004

Jun 06, '08 07:30:02AM

Contributed by: cody121

This hint will put your Entourage 2004 database on a sparse bundle, which Time Machine knows how to use for a true incremental backup. I am using this for Entourage, but it will probably work OK with Paralells' or VMware's virtual machines, too -- I just don't know about the speed issue.

Sorry, much of this is kind of advanced, but if you don't understand what you are doing here, you are probably better off not using this method. If something goes wrong after an update, you will have a hard time figuring out what happened, and getting to your email. This is not a hint for those with only a basic knowledge of the system...

Basically this is how I made a Sparse Bundle mount to an odd mount point on system boot. I am going to use my Entourage installation as an example, and I'm not going to explain every step in the ultimate low-level of detail, so watch what you are doing.

  1. Create the Sparse Bundle in Terminal. First see how big your current database is:
     $ cd ~/Documents/Microsoft\ User\ Data/
     $ du -hs Office\ 2004\ Identities
     2.5G    Main Identity/
    My Entourage folder is 2.5GB, and when I create my Sparse Bundle, I want it to have enough room to grow. So I used Disk Utility to make an image: Hit Save, and then eject the disk.
  2. Move your current data. Quit all of your MS Office programs, and do not start them again until you're done here. Be sure that nothing is accessing your Main Identity folder, using Terminal:
     $ lsof | grep "Microsoft User Data"
    You may see your own applications in the list, but that is not a big deal. Rename your Office 2004 Identities folder:
     $ cd ~/Documents/Microsoft\ User\ Data/
     $ mv Office\ 2004\ Identities Office\ 2004\ Identities.BACKUP
     $ mkdir Office\ 2004\ Identities
     $ ls -dl Office\ 2004\ Identities*
    Be sure that the file owner, group, and permissions are the same.
  3. Make a script to mount your sparse bundle to your new directory, using Terminal:
     $ cd
     $ mkdir -p unix/scripts
     $ cd unix/scripts
     $ touch mountentourage
     $ chmod 750 mountentourage
     $ nano mountentourage
    This should be the contents of the mountentourage file:
    #!/bin/sh
    
     /usr/bin/hdiutil attach "/Users/USER/Entourage.sparsebundle" \
       -mountpoint "/Users/USER/Documents/Microsoft User Data/Office 2004 Identities" \
       -owners on -notremovable -nobrowse
    Obviously, change the USER directory to your user's home directory. If you copy and paste the above, be sure that there are no trailing spaces at the end of the lines. Exit nano, saving your changes. You should now have an executable file that mounts your disk image to your datastore:
     $ ./mountentourage
     /dev/disk2              Apple_partition_scheme
     /dev/disk2s1            Apple_partition_map
     /dev/disk2s2            Apple_HFS
    /Users/USER/Documents/Microsoft User Data/Office 2004 Identities
    And df should now show your mapping:
     $ df
     Filesystem    512-blocks      Used Available Capacity  Mounted on
     /dev/disk1s9   320144448 150973320 168659128    48%    /
     devfs                233       233         0   100%    /dev
     fdesc                  2         2         0   100%    /dev
     /dev/disk0s3   624880224 290918680 333961544    47%    /Volumes/Backup
     map -hosts             0         0         0   100%    /net
     map auto_home          0         0         0   100%    /home
     /dev/disk2s2    20971520     72480  20899040     1%    /Users/USER/Documents/Microsoft User Data/Office 2004 Identities
  4. Execute the script at startup. (Oh how I long for the days of good old simple /etc/rc). In Terminal:
     $ hdiutil detach disk2
     $ df 
     // The drive should no longer be mounted
     $ cd /Library/LaunchDaemons
     $ sudo nano user.USER.mountentourage.plist
    This should be the contents of the user.USER.mountentourage.plist file:
    <?xml version="1.0" encoding="UTF-8"?>
     <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
     <plist version="1.0">
     <dict>
         <key>Label</key>
         <string>user.USER.mountentourage</string>
         <key>ProgramArguments</key>
         <array>
             <string>/Users/USER/unix/scripts/mountentourage</string>
         </array>
         <key>RunAtLoad</key>
         <true/>
     </dict>
     </plist>
    Exit nano, saving your changes. Then execute these Terminal commands:
     $ ls -l
     -rw-r--r--  1 root  wheel  398 Jun  4 16:11 user.USER.mountentourage.plist
     $ sudo launchctl load user.USER.mountentourage.plist
     $ df
    If all went well, you will now see your entourage directory mounted. Verify that after a system restart, df shows you your mount.
  5. Test and populate your new image. One final check of the mount first:
     $ cd ~/Documents/Microsoft\ User\ Data/Office\ 2004\ Identities
     $ touch testfile
     $ ls
     testfile
     $ cd ..
     $ df | grep Microsoft
     $ hdiutil detach disk2
     $ cd Office\ 2004\ Identities
     $ ls
     // The file testfile should not be here
     $ cd ..
     $ sudo launchctl unload /Library/LaunchDaemons/user.USER.mountentourage.plist
     // (because it was loaded at startup)
     $ sudo launchctl load /Library/LaunchDaemons/user.USER.mountentourage.plist
     $ df
     $ cd Office\ 2004\ Identities
     $ ls
     testfile
     $ rm testfile
     $ cd ..
     $ cp -prv Office\ 2004\ Identities.BACKUP/* Office\ 2004\ Identities/
    At this point, your data should be loaded and ready to go. I choose to back my Office 2004 Identities.BACKUP directory just to be safe:
     $ mv Office\ 2004\ Identities.BACKUP /Volumes/Backup/
  6. Configure Time Machine. While all of the data that you have looks like it resides in ~/Documents » Microsoft User Data » Office 2004 Identities, technically, that is now another Volume. Since those are the big files that you were probably ignoring before, you still don't want to back them up directly. So go to your Time Machine options and make sure that "Entourage Database" is in the "do not backup" list.
The good news is that all of the data that resides on "Entourage Database" now resides in a sparse bundle in your home directory, and that is backed up. And with the ingenious way that Apple made a sparse bundle work, you now have incremental backups of your Entourage database at a minimal space cost.

[robg adds: I haven't tested this one...]

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080605115101581