Posted on 12-18-2015 06:47 AM
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
Solved! Go to Solution.
Posted on 12-18-2015 09:44 AM
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
Posted on 12-18-2015 06:53 AM
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.
Posted on 12-18-2015 06:56 AM
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
Posted on 12-18-2015 07:02 AM
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.
Posted on 12-18-2015 09:44 AM
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
Posted on 12-18-2015 09:46 AM
@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.
Posted on 12-18-2015 09:53 AM
Mostly because I copied and pasted from terminal to make sure it was all working 1st ; ) Edited the post.
Gabe Shackney
Princeton Public Schools
Posted on 12-18-2015 11:43 AM
@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.
Posted on 12-18-2015 12:08 PM
Good call, and you were correct. Added the hidden folders to the exclusions list.
Gabe Shackney
Princeton Public Schools
Posted on 12-18-2015 12:11 PM
@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.
Posted on 12-18-2015 12:43 PM
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
Posted on 01-31-2017 11:31 AM
@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!
Posted on 01-31-2017 11:48 AM
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
Posted on 05-01-2018 08:43 AM
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.
Posted on 05-04-2018 07:25 AM
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.........