Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got two primary computers, one Mac Pro and one MacBook Pro for when I'm on the go. I've also got a Linux sever which also acts as NAS.

Currently I backup the entire computers to an external drive with Time Machine which is rather useless and doesn't sync anything. What I really want to do is to keep my important files synced between both computers and my NAS (which is running RAID 5), that way I'm not backing up easily replaceable systemfiles and I've got all my important files in 3 places where two of them are running raid so at least 5 drives would have to crash at the same time before actual data loss occur.

Folders I want to keep synced is basically my photo, documents, development, mamp and work folders and then I want to keep the user library folder backed up but not synced. I'm thinking that I'd have to use rsync but don't know how.

Before suggesting Dropbox and similar suggestions I don't want to use them because of several reasons some of them being security (Dropbox obviously proved this), Speed (sometimes I'll sync gigabytes of data and that will be significantly faster locally and probably even through VPN as I have a Gigabit pipe), Space (space on my NAS is cheap and only practically limited by my needs), reliability (even if my internet were to go down I still need to be able to keep my files synced incase I'd need to go somewhere on the fly), price (I already have all the hardware and for the amount of gigabytes and bandwidth I'd need I doubt that there's any free or cheap service). Those are my main reason for wanting to keep it locally.

I'm sorry for any spelling or grammatical mistakes that I've might have done. I'm writing this on my smartphone from a shaky train and English isn't my mother tongue. I gratefully appreciate any answers even if only partly solving my problem.

share|improve this question

4 Answers 4

rsync can do this

My advice is that you take some time to learn how to use it, it is a very competent tool.

There is a project on sourceforge arRsync that gives you a graphical frontend that might help you get started.

share|improve this answer
    
I've linda figured outbyggd how to sync one way with rsync but I'm afraid that I'll overwrite new files with an older version when syncing the 2nd computer or that rsync will think that I've deleted the files that doesn't exist in the laptop and thus deleting them from the server, alternatively add deleted files back to the server again. –  Hultner Sep 16 '11 at 10:53
    
@Hultner - Well there is always the possibility of of using version control. Set up a git (or subversion) server on your Mac Pro, use git/svn on your laptop to sync with the server, use rsync to backup your data from the Mac Pro to the NAS. –  Nifle Sep 16 '11 at 10:59

Below is a script I use to backup w/rsync. The difference is that it makes a copy of the previous backup with hard links (which is space efficient) and rsync's to that.

rsync backups always make me nervous, because the single copy you have can be wiped out if the source gets damaged and the rsync runs. Not with this scheme, though.

#! /bin/bash

# number of days to keep backups:
maxage=120

lockfile=/tmp/sync-files
# Ensure that only one copy is running.
lockfile -r0 $lockfile || exit 1
trap 'rm -f $lockfile' EXIT

# Versioned rsync
vrsync()
{
[ -d $2 ] || mkdir $2

# remove expired directories
for dir in `find $2 -maxdepth 1 -type d -mtime +$maxage`; do
    #echo "NOTE: removing expired directory: $dir"
    rm -fr $dir
done

mostrecent=`(cd $2; /bin/ls -r) | grep '^[0-9]' | head -1`
today=`date +%Y.%m.%d-%H:%M:%S`

if [ -z "$mostrecent" ]; then
    echo No older mirror to rotate.  Starting fresh.
else
    #echo most recent is $mostrecent.  Making links.
    cp -al $2/$mostrecent $2/$today
fi

rsync -qa --delete --delete-before $1 $2/$today

# Note: rsync will set the modification time of the destination
# directory to the modification time of the source directory so we touch
# it here so that it reflects the time of the backup.
touch $2/$today

# make a `latest' link
rm -f $2/latest
ln -s $today $2/latest
}

# trailing slash on first directory is important
vrsync /home/Documents/ /mirror/backup/Documents
share|improve this answer
    
The hardlink approach can work very well; might want to check out rsnapshot; along with being heavily tested, there are extra niceties (like rsnapshot du) –  Clayton Stanley Mar 19 '12 at 1:48

I use rsync any time one-way synchronization will do. When two-way sync is required, I use Unison. I've had great results synching Gigs of data, large amounts of source files, etc. with this tool.

What I have not tried is to use Unison to sync an entire home directory. I'm not sure if OS X will crash if the entire home directory is being shared between two machines. If this is supported in OS X, I'm pretty confident that Unison can handle the load.

Just a hint when using Unison. Use sync over ssh, instead of mounting the drive with smb or nas. I've had issues with file permissions not being correctly propagated between a Mac and a Linux server, when the Linux server was remotely mounted on the Mac with smb. No issues whatsoever if that same sync is done over an ssh login.

Also, when sync over ssh is used, Unison actually runs both on the Mac and on the Linux server. Which means that most calculations to figure out what has changed are done completely in isolation for each machine (meaning very very fast).

share|improve this answer

For command line backups, locally or over the network:

  • rsync: one-way, overwrites destination so that a mistake (e.g. wrong direction) can destroy data.
  • rdiff-backup: one-way, but keeps diff to old versions so that they can be recovered. Similar to TimeMachine.

To keep multiple machines synchronized:

  • Unison: two-way synchronization. A configuration file selects which folders are to be synchronized. I don't synchronize the home folder directly, but the documents folders. Not practical for more than two computers.
  • Bittorrent sync: multi-way synchronization. Allows private synchronization using the bittorrent protocol. I use this to keep some folders synchronized between my computers and co-workers. I prefer this to dropbox because of space limitations of the latter.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.