One-way syncing/backup with Unison
Solution 1:
A better tool for the job might be rsync (you'll need to install it on both computers). I use it to keep my laptop music folder in sync with a home file server, which is pretty similar to your situation. rsync specializes in keeping a mirror copy up-to-date.
A command line like this might be useful (assuming you run it from Ubuntu):
rsync -a --delete-before myMacMachineName:/MyMusic/ /mymusic/
It is pretty easy to switch the above line around if you want to run it from your Mac and push to the Ubuntu computer instead of pulling.
Solution 2:
Use unison -force
:
Manual:
Including the preference
-force root
causes Unison to resolve all differences (even non-conflicting changes) in favor of root. This effectively changes Unison from a synchronizer into a mirroring utility. You can also specify-force newer
(or-force older
) to force Unison to choose the file with the later (earlier) modtime. In this case, the-times
preference must also be enabled. This preference is overridden by theforcepartial
preference. This preference should be used only if you are sure you know what you are doing!
E.g. (using socket mode). Start up unison listener in the directory that you want to be a mirror of something else. Target that socket in the unison client call. Force causes changes to be all ONE WAY from the given root.
cd /target/mirror/directory
unison -socket 123456 &
Elsewhere or on the same host:
unison -silent -force /home/test/thing2 /home/test/thing2 socket://somehost:123456/
Solution 3:
Whilst the answer by TheToasterThatCould will 'work', please note that it will not correctly backup Mac file system "Resource Forks"
Whilst the Mac OSX version of rsync is resource-fork aware, linux versions of rsync are not (and likely will never be, because the Apple version of rsync is OSX-specific and does not present those resource forks to rsync on the other end in a way that a non-OSX version of rsync can handle). The result of this is that resource forks will not be rsync'd between Mac and linux machines.
Certain Mac apps utilise resource forks to store data related to the particular file. If you are certain that your files you are syncing don't need or use resource forks, then it should be OK to use rsync.
If you want to sync resource forks, then unison will be the better approach because (according to unison docs) it can sync resource forks.