Time Machine After Logout
I've been using Time Machine for a while now. And I've noticed some interesting things about its behavior. Of particular note, I've noticed that Time Machine does not back up your data when you are logged out. I found this strange until I figured out why this is the case.
I first noticed Time Machine not backing up logged-out users after setting up the staff computers here at work. Oddly, my work computer did back up when I was logged out, which I realized when I noticed a backup failure due lack of drive space. According to the Console logs this backup attempt had occurred in the middle of the night. Clearly Time Machine was able to backup when users were logged out, but it would only do so on my machine. So what was the difference?
By default, Mac OS X wisely un-mounts external volumes when a user logs out. This makes sense for a number of reasons, not the least of which is the fact that it's what users expect, and it's the least likely to break something if a user logs out and pulls their firewire plug without ejecting their disk. It's a very sane default that errs on the side of data protection. But it's not always what you want. For instance, say you have network shares, like external RAID drives, that are connected via firewire (which, in fact, we do). Or say your network backups that run in the middle of night get stored on a firewire volume (which ours do). If you want these drives constantly available you need to be able to keep them mounted even when no user is logged in. Fortunately, Apple provides a method for doing this, though it's by no means obvious.
The trick to keeping external drives mounted after a logout lies in a little .plist file. The name of this file is autodiskmount.plist, and it does not exist by default; you have to make it. In the file should be the following text:
Put this file in:
/Library/Preferences/SystemConfiguration/
And reboot. (Yes, reboot.)
Now all external drives (firewire, USB, eSATA, etc.) will stay mounted after a logout. If they're shared, they'll always be available. And they'll always be available to Time Machine.
So the difference between the staff machines and mine? My computer is set to never unmount drives at logout. Apparently, Time Machine is perfectly capable of running even when no one is logged in. But it obviously needs the Time Machine drive available to do so. Keeping firewire drives mounted post-logout will allow Time Machine to work all night long. Sweet!
And since I'm so crazy with the Installer Packages these days, I'm including one here that will install the necessary preference file to make all this happen. You know, just to make your lives a little easier.
Download KeepExternalDisksMounted
You're welcome!
UPDATE 1: A reader asked in the comments how I came to have the preference file installed on my system. I'd put it there long ago because I needed firewire drives mounted for rsync backups of staff machines. But I certainly didn't figure out how to create that file myself. Credit for that goes to this Mac OS X Hints hint. It's got all the details if you're interested.
UPDATE 2: One other thing I forgot to mention: Why is this useful? I mean, if you're logged out you're not really capable of creating any new data, so there's nothing really new to backup anyway, right? This is mostly true, indeed. But imagine your boss uses Time Machine for his hourly backups. Now imagine he creates a whole buttload of data — I don't know, emails to the CEO, photos of his kids, whatever — and he creates this data right before he leaves for the day. Then, safe in the knowledge that Time Machine's got his back, he logs out and goes home for the weekend. That weekend there's a power surge or something, and his machine is fried. "No problem," he thinks, "I have my backup." But his most recent data is gone. His photos, his draft to the CEO, gone. And guess who's to blame? Yup. The Systems Admin. Your ass is grass, and Time Machine is the lawn mower. (Uh, this is why I don't write in the mornings.)
Personally, I think it would be smart if Time Machine asked you at logout if you'd like to make a backup, or at least warned you that backups would not be performed after logout. This seems like a bit of an oversight on Apple's part.
The other time this can be useful is when you're creating your first backup. This is typically a lot of data. Here in the office we told folks to let it run overnight. But they couldn't log out. So we dropped them to the Login Window with Fast User Switching. Still, it would have been that much more intuitive if we'd just told them to log out like they always do, and that their backups would be ready in the morning.
So yeah, not earth-shattering, but still potentially useful. And interesting on an academic level to know that Time Machine will run sans login.
I have to go install that preference file on my staff machines now. Bye!
I first noticed Time Machine not backing up logged-out users after setting up the staff computers here at work. Oddly, my work computer did back up when I was logged out, which I realized when I noticed a backup failure due lack of drive space. According to the Console logs this backup attempt had occurred in the middle of the night. Clearly Time Machine was able to backup when users were logged out, but it would only do so on my machine. So what was the difference?
By default, Mac OS X wisely un-mounts external volumes when a user logs out. This makes sense for a number of reasons, not the least of which is the fact that it's what users expect, and it's the least likely to break something if a user logs out and pulls their firewire plug without ejecting their disk. It's a very sane default that errs on the side of data protection. But it's not always what you want. For instance, say you have network shares, like external RAID drives, that are connected via firewire (which, in fact, we do). Or say your network backups that run in the middle of night get stored on a firewire volume (which ours do). If you want these drives constantly available you need to be able to keep them mounted even when no user is logged in. Fortunately, Apple provides a method for doing this, though it's by no means obvious.
The trick to keeping external drives mounted after a logout lies in a little .plist file. The name of this file is autodiskmount.plist, and it does not exist by default; you have to make it. In the file should be the following text:
<?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>AutomountDisksWithoutUserLogin</key>
<true/>
</dict>
</plist>
Put this file in:
/Library/Preferences/SystemConfiguration/
And reboot. (Yes, reboot.)
Now all external drives (firewire, USB, eSATA, etc.) will stay mounted after a logout. If they're shared, they'll always be available. And they'll always be available to Time Machine.
So the difference between the staff machines and mine? My computer is set to never unmount drives at logout. Apparently, Time Machine is perfectly capable of running even when no one is logged in. But it obviously needs the Time Machine drive available to do so. Keeping firewire drives mounted post-logout will allow Time Machine to work all night long. Sweet!
And since I'm so crazy with the Installer Packages these days, I'm including one here that will install the necessary preference file to make all this happen. You know, just to make your lives a little easier.
Download KeepExternalDisksMounted
You're welcome!
UPDATE 1: A reader asked in the comments how I came to have the preference file installed on my system. I'd put it there long ago because I needed firewire drives mounted for rsync backups of staff machines. But I certainly didn't figure out how to create that file myself. Credit for that goes to this Mac OS X Hints hint. It's got all the details if you're interested.
UPDATE 2: One other thing I forgot to mention: Why is this useful? I mean, if you're logged out you're not really capable of creating any new data, so there's nothing really new to backup anyway, right? This is mostly true, indeed. But imagine your boss uses Time Machine for his hourly backups. Now imagine he creates a whole buttload of data — I don't know, emails to the CEO, photos of his kids, whatever — and he creates this data right before he leaves for the day. Then, safe in the knowledge that Time Machine's got his back, he logs out and goes home for the weekend. That weekend there's a power surge or something, and his machine is fried. "No problem," he thinks, "I have my backup." But his most recent data is gone. His photos, his draft to the CEO, gone. And guess who's to blame? Yup. The Systems Admin. Your ass is grass, and Time Machine is the lawn mower. (Uh, this is why I don't write in the mornings.)
Personally, I think it would be smart if Time Machine asked you at logout if you'd like to make a backup, or at least warned you that backups would not be performed after logout. This seems like a bit of an oversight on Apple's part.
The other time this can be useful is when you're creating your first backup. This is typically a lot of data. Here in the office we told folks to let it run overnight. But they couldn't log out. So we dropped them to the Login Window with Fast User Switching. Still, it would have been that much more intuitive if we'd just told them to log out like they always do, and that their backups would be ready in the morning.
So yeah, not earth-shattering, but still potentially useful. And interesting on an academic level to know that Time Machine will run sans login.
I have to go install that preference file on my staff machines now. Bye!
Labels: Applications, Hardware, Lab, Leopard, MacOSX
You are crazy with the P-K-G these days. Very cool. Keep 'em coming!
Time Machine is cool, but I'll stick with plain old rsync and some simple shell scripts. :)
12:09 PM
Dude, you're totally old skool.
I don't even know what that means. But I do loves me some Time Machine. Never thought I'd get such a thrill out of backups. Sometimes I recover documents I don't even want, just to enter the Time Machine interface. Sometimes I wantonly trash stuff for no good reason. Because I can! It's tha fa-shizzle.
I need a nap.
-systemsboy
8:29 PM
Hi,
Pretty cool tip!
But why your system got this preference file with the properly settings in the first place?
By the way, great blog!
11:54 AM
Thanks, Rodrigo!
And good question. I've updated the post with information on where I got the preference file and how it got on my machine.
-systemsboy
6:08 PM
Another possible route would be to look into how to make TimeMachine force a backup when you logout, as it does when you have FileVault enabled. That would catch every last file.
11:14 AM
Ryan,
That could be accomplished with a logout hook that activates an Applescript that performs the backup (or one that asks the user if he wants to do this) before logging out. Of course, Time Machine isn't Applescript-able, but I did find this little nugget, which describes how to activate Time Machine via the shell. So that would do the trick.
I've cobbled together a little Automator action that would theoretically work. The hard part might be getting the logout behavior to work properly, but I don't know as I haven't gotten that far with it, and probably won't go much farther. Not a big fan of logout hooks anyway. Kind of a bitch to set up in my experience.
Needless to say, the more I look at this solution, the more I like my way better. And ideally Apple would build this in to the logout procedure as they have with File Vault.
-systemsboy
12:03 AM
Rob it's a cool tip. When I first read it I got all excited to implement it. The thing is all my computers are laptops. Then it dawned on me why the default is the default. There's a huge huge risk of someone disconnecting the disk after log out. While were trained no to disconnect at sleep perhaps, we all expect that at log out disk are unmounted on macs and safe to unplug. And this violates that hence the default. Al lot less risk on a desktop of course.
11:57 AM
Believe it or not, until Panther (if I recall correctly) the default behavior was to NOT unmount drives after logout.
I believe the initial logic was, "You didn't expressly unmount the drive, so we'll leave it mounted. We do as we're told." The new logic is probably more like, "Many users expect a logout to unmount an external drive (as it does a network drive). If we don't unmount drives at logout, users can lose data. Let's err on the side of caution here."
I think the new way is better. But I remember it didn't used to be that way, because I needed the old behavior on certain machines (mine), and had to go looking for a fix, which is presented in this article.
Oh, and who's Rob?
-systemsboy
4:05 PM
Systems Boy:
Does this also apply to remote network volumes such as AFP NFS & SMB or just physically attached drives such as USB, Firewire, etc?
4:15 PM
That's an excellent question. I believe (in fact, I'm nearly positive — though the surest way to tell would be to try it) that most network volumes will continue to unmount after logout. The exception here is NFS mounts which stay mounted after a logout by default.
In any case, the preference file I've provided here should only affect physically mounted volumes and should have no affect on network volumes. They should behave as they always have with regards to logout.
-systemsboy
5:41 PM
Thanks Systems Boy, you saved me a lot of work.
l.
8:08 PM
Interesting tip, thanks. I searched on my Mac drive for autodiskmount just to see if I had one. I didn't, but did have an html-ized man page, wherein it is stated that this arrangement is deprecated.
*sigh*
Every neat thing I learn it seems, is deprecated.
Would fstab be a "better" approach? Can it accomplish this goal?
Thanks again: deprecated or not I think I may have to implement this. Maybe I can figure out how to make it leave mounted/automount *only* the Time Machine drive...
(Currently sobbing because TM says it has *only* a few hours to go... )
» Post a Comment