Thanassis Tsiodras writes:
What would you do if you had to automatically backup a remote Linux box (e.g. your web server), and all you had locally was Windows machines? How about this:
- automatically expanding local storage space
- transmissions of differences only
- automatic scheduling
- local storage of differences only
- secure and compressed transfer of remote data and
- instant filesystem navigation inside daily snapshot images
I covered all these requirements using open source tools, and I now locally backup our 3GB remote server in less than 2min!
We’ve all used Samba and rsync before, but Thanassis has really put all the pieces together into a complete backup system that’s superior to a lot of commercial products I’ve seen.
The really impressive bit is how he’s easily doing snapshot images using filesystem hardlinks. You can save several days worth of snapshots at very little cost because additional space is only taken up by files that have changed. Using hardlinks, identical files from different snapshots all point to the same inode.
root# mount /dev/loop0 /mnt/backup root# cd /mnt/backup root# rm -rf OneBeforeLast root# cp -al LastBackup OneBeforeLast root# cd LastBackup root# rsync -avz --delete firstname.lastname@example.org.US:/ ./
The “cp -al” creates a zero-cost copy of the data (using hardlinks, the only price paid is the one of the directory entries, and ReiserFS is well known for its ability to store these extremely efficiently). Then, rsync is executed with the –delete option: meaning that it must remove from our local mirror all the files that were removed on the server – and thus creating an accurate image of the current state.
And here’s the icing on the cake: The data inside these files are not lost! They are still accessible from the OneBeforeLast/ directory, since hard links (the old directory entries) are pointing to them!
In plain terms, simple navigation inside OneBeforeLast can be used to examine the exact contents of the server as they were BEFORE the last mirroring.
Just imagine the data recovery headaches you could solve by adapting that to a cron job that shuffles a months worth of nightly backups.
Optimal remote Linux backups with rsync over Samba – Link