Skip to main content
Solved

Have Time Machine backup just user folder


Forum|alt.badge.img+18
  • Esteemed Contributor
  • 831 replies

Anyone already doing this? We are experimenting with a time machine backup qnap. I'm trying to work out how to tell time machine on each computer to only backup its user folder. Didn't want to re invent the wheel.

Any ideas?

Gabe Shackney
Princeton Public Schools

Best answer by GabePPS

So here is how I got it to work for our needs...

#!/bin/bash
# Set file share path to timemachine afp (edit username and password, ip address and volume/share name)
tmutil setdestination afp://username:password@ipaddress/volumename

# Exclude all System folders
tmutil addexclusion -p /Applications
tmutil addexclusion -p /Library
tmutil addexclusion -p /System

# Exclude any other users on the computer (Edit for your specifics)
tmutil addexclusion -p /Users/localadmin
tmutil addexclusion -p /Users/Shared
tmutil addexclusion -p /Users/template
tmutil addexclusion -p /Users/teacher
tmutil addexclusion -p /Users/student

# Exclude hidden root os folders
tmutil addexclusion -p /bin
tmutil addexclusion -p /cores
tmutil addexclusion -p /etc
tmutil addexclusion -p /Network
tmutil addexclusion -p /private
tmutil addexclusion -p /sbin
tmutil addexclusion -p /tmp
tmutil addexclusion -p /usr
tmutil addexclusion -p /var

# Enable timemachine to start auto backing up
tmutil enable

exit 0

Gabe Shackney
Princeton Public Schools

View original
Did this topic help you find an answer to your question?

14 replies

Forum|alt.badge.img+15
  • Contributor
  • 589 replies
  • December 18, 2015

In TimeMachine system prefs you can click Options and 'add' items to be excluded. You can edit/view that command line (defaults read /Library/Preferences/com.apple.TimeMachine.plist). So you'd have to exclude most everything else.


Forum|alt.badge.img+18
  • Author
  • Esteemed Contributor
  • 831 replies
  • December 18, 2015

Its really too bad they don't have an "inclusion" list. Yes, I saw that, but I think I'd have to script a way to add exclusions to anything other than that specific user. Especially if the computer has multiple user accounts. Makes it hard I think.

Gabe Shackney
Princeton Public Schools


Forum|alt.badge.img+15
  • Contributor
  • 589 replies
  • December 18, 2015

Well, time machine is really just rsync with lots of wrappers. You could write an rsync to do as you want, but that may be recreating the wheel depending on what you want with versioning and stuff.


Forum|alt.badge.img+18
  • Author
  • Esteemed Contributor
  • 831 replies
  • Answer
  • December 18, 2015

So here is how I got it to work for our needs...

#!/bin/bash
# Set file share path to timemachine afp (edit username and password, ip address and volume/share name)
tmutil setdestination afp://username:password@ipaddress/volumename

# Exclude all System folders
tmutil addexclusion -p /Applications
tmutil addexclusion -p /Library
tmutil addexclusion -p /System

# Exclude any other users on the computer (Edit for your specifics)
tmutil addexclusion -p /Users/localadmin
tmutil addexclusion -p /Users/Shared
tmutil addexclusion -p /Users/template
tmutil addexclusion -p /Users/teacher
tmutil addexclusion -p /Users/student

# Exclude hidden root os folders
tmutil addexclusion -p /bin
tmutil addexclusion -p /cores
tmutil addexclusion -p /etc
tmutil addexclusion -p /Network
tmutil addexclusion -p /private
tmutil addexclusion -p /sbin
tmutil addexclusion -p /tmp
tmutil addexclusion -p /usr
tmutil addexclusion -p /var

# Enable timemachine to start auto backing up
tmutil enable

exit 0

Gabe Shackney
Princeton Public Schools


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • December 18, 2015

@gshackney Why all the sudos throughout the script? You should probably remove those from the final script if its being run by a policy. They aren't needed.


Forum|alt.badge.img+18
  • Author
  • Esteemed Contributor
  • 831 replies
  • December 18, 2015

Mostly because I copied and pasted from terminal to make sure it was all working 1st ; ) Edited the post.

Gabe Shackney
Princeton Public Schools


mpermann
Forum|alt.badge.img+22
  • Valued Contributor
  • 690 replies
  • December 18, 2015

@gshackney won't Time Machine continue to backup all the hidden folders in the root level of the hard drive? I've never tried what you are suggesting but I was just curious what is in your Time Machine backup after you've tested. You'll have to do an

ls -l

to see the invisible stuff on the root level of the hard drive.


Forum|alt.badge.img+18
  • Author
  • Esteemed Contributor
  • 831 replies
  • December 18, 2015

Good call, and you were correct. Added the hidden folders to the exclusions list.

Gabe Shackney
Princeton Public Schools


mpermann
Forum|alt.badge.img+22
  • Valued Contributor
  • 690 replies
  • December 18, 2015

@gshackney you mind updating your script above? It would save me some typing when I "borrow" it to play with it. :-)

Edit: I guess you were in the process. Thanks.


Forum|alt.badge.img+18
  • Author
  • Esteemed Contributor
  • 831 replies
  • December 18, 2015

One thing I'd like to change about this is setting the computer to use the AD user credentials to login to the TimeMachine backup qnap. So I'll have to grab this code from another script to pass the username and password from AD to the script.

Gabe Shackney
Princeton Public Schools


Forum|alt.badge.img+3
  • New Contributor
  • 14 replies
  • January 31, 2017

@gshackney Hi, were you able to get this to work? If so can you post the script with setting the computer to use the AD user credentials to login to the TimeMachine backup qnap? Thanks!


Forum|alt.badge.img+18
  • Author
  • Esteemed Contributor
  • 831 replies
  • January 31, 2017

You know, I never did finish this. But as we start backing up more users data I may need to revisit this script. Let me look at this sometime this week and see if I can get it to work.

Gabe Shackney
Princeton Public Schools


Forum|alt.badge.img+4
  • Contributor
  • 23 replies
  • May 1, 2018

Anyone ever figure out if Time Machine can be used to backup and restore network users on a Mac with forced local home directories.

We work with lots of schools who have to use things like Carbon Copy Cloner to backup the /Users folder on each Mac because students can't be relied upon to copy their data to a server.

It's easy enough to get Time Machine to do the backup using the scripts mentioned above (thanks @gshackney):

#!/bin/bash
# Set file share path to timemachine
tmutil setdestination smb://$user:$password@$servername/$sharepoint

# Exclude all System folders
tmutil addexclusion -p /Applications
tmutil addexclusion -p /Library
tmutil addexclusion -p /System

# Exclude any other users on the computer (Edit for your specifics)
tmutil addexclusion -p /Users/localadmin
tmutil addexclusion -p /Users/Shared
tmutil addexclusion -p /Users/template
tmutil addexclusion -p /Users/teacher
tmutil addexclusion -p /Users/student

# Exclude hidden root os folders
tmutil addexclusion -p /bin
tmutil addexclusion -p /cores
tmutil addexclusion -p /etc
tmutil addexclusion -p /Network
tmutil addexclusion -p /sbin
tmutil addexclusion -p /tmp
tmutil addexclusion -p /usr
tmutil addexclusion -p /var
tmutil addexclusion -p /Volumes
tmutil addexclusion -p /vm

# Enable timemachine to start auto backing up
tmutil enable

exit 0

And using that script Time Machine backs up the forced local home directories of network accounts accounts, but when you come to restore the backup network accounts aren't offered as something to restore. Its like the Time Machine assistant recognises that the UID is from a network users and presume that you won't want to restore it.


Forum|alt.badge.img+4
  • Contributor
  • 23 replies
  • May 4, 2018

Ignore my previous post. I was being dumb.

Time Machine backup won't see network accounts as users unless they're mobile accounts.

Shhhh......... nothing to see here.........


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings