Most users of Apple computers use Time Machine (TM), a built-in Mac OS X backup solution for their data. However, I belong to a minority that does not use the “time machine”.
The fact is that I need backup over the network, and via the network, Time Machine can copy data either to Time Capsule or to a shared folder shared on a computer running Mac OS X Leopard (and higher). I am not going to buy a time capsule, because it does not inspire confidence in me, and there is no other poppy in the house. There are various hacks with which you can force TM to write backups to any network folder, but all these hacks have side effects that you don’t feel like fighting with. Therefore - rsync, rsync and rsync again. However, Apple would not have been Apple if, in the spirit of caring for the user, had not laid a rake along the way, with which we will fight now :)
The rake is that Mac OS X comes with a very
strange version of rsync. Let's take a closer look at it with the rsync --version command:
')
rsync version 2.6.9 protocol version 29
Capabilities: 64-bit files, socketpairs, hard links, symlinks, batchfiles,
inplace, IPv6, 64-bit system inums, 64-bit internal inums
Firstly, it is very old (the current version, 3.0.7, has an improved file comparison algorithm and is faster). Secondly, Apple's rsync is built with the support of the HFS + file system metadata and supports the special -E key to save these same metadata ... but at the same time there should be the same "modified" version of rsync at the other end. That is, the “recipient” of the backup copy again can only be a computer with Mac OS X (Tiger or higher).
It does not matter, this problem is mostly solved. First, we will compile the latest version of rsync on a Mac (you should have Xcode installed).
Download the source code:
cd ~/Desktop
curl -O rsync.samba.org/ftp/rsync/src/rsync-3.0.7.tar.gz
tar -xzvf rsync-3.0.7.tar.gz
rm rsync-3.0.6.tar.gz
curl -O rsync.samba.org/ftp/rsync/src/rsync-patches-3.0.7.tar.gz
tar -xzvf rsync-patches-3.0.7.tar.gz
rm rsync-patches-3.0.7.tar.gz
cd rsync-3.0.7
Apply the relevant patches:
patch -p1 <patches/fileflags.diff
patch -p1 <patches/crtimes.diff
Now we collect:
./prepare-source
./configure
make
sudo make install
Checking what we did:
melchior:~ pavel$ /usr/local/bin/rsync --version
rsync version 3.0.7 protocol version 30
Copyright (C) 1996-2009 by Andrew Tridgell, Wayne Davison, and others.
Web site: rsync.samba.org
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, no iconv, symtimes, file-flags
Now you need to compile rsync on a Linux machine that will be used for backup, using the patch fileflags, but
WITHOUT the crtimes patch ! In Ubuntu 9.10, for this you must first install the "means of production":
sudo apt-get install build-essential
sudo apt-get build-dep rsync
Making a test run:
/usr/local/bin/rsync -aHAXxzv --protect-args --fake-super --rsync-path="/usr/local/bin/rsync" ~/Documents/ pavel@192.168.1.5:/home/pavel/backup
There is only one problem left: when trying to backup to an ext3 partition, rsync scolds that the extended attributes of the files do not fit in the space allocated for them. To solve this problem, I formatted the backup disk on XFS.
The main disadvantage of this method is that it does not save the attributes of the time of creation and modification of the file. However, for me it is uncritical, because I need a remote backup not to create a bootable copy of the system disk, but to ensure the safety of documents dear to my heart.
rsync is good because you can write a script and run it regularly with cron. In this case, the backup will be carried out without your intervention. But this is a topic for a separate entry ...