Using faubackup to backup and ssh + tar to restore

I’ve been using faubackup eversince deepgeek recommended it in episode 85 of Hacker Public Radio. Basically there is a directory for every backup that shows all the files for each backup. If a file is the same across the backups then hard linkes are used to save space. Faubackup takes care of the backup and the restore is up to you. As the backup is just a flat directory you can restore how you like.

I chose to restore using secure copy and recursively copy entire directories, scp -r. Fully thing was that my 80G disk filled up with only 12G of data. After some investigation I discovered that the wine application had a symlink pointing C: to the root of the file system. Every time the scp program hit this link it would re-copy the entire drive agan in the directory where the symlink was.

I found the answer here from the O’Relly book SSH, The Secure Shell: The Definitive Guide by by Daniel J. Barrett and Richard E. Silverman ISBN: 0-596-00011-1.

Although scp can copy directories, it isn’t necessarily the best method. If your directory contains hard links or soft links, they won’t be duplicated. Links are copied as plain files (the link targets), and worse, circular directory links cause scp1 to loop indefinitely. (scp2 detects symbolic links and copies their targets instead.) Other types of special files, such as named pipes, also aren’t copied correctly. A better solution is to use tar, which handles special files correctly, and send it to the remote machine to be untarred, via SSH:
$ tar cf – /usr/local/bin | ssh tar xf –

Another handy tip when trying to copy directories and you want to preserve permissions is to use:

cd /source && tar cf – * | ( cd /destination; tar xfp -)

This entry was posted in General. Bookmark the permalink.

Leave a Reply

Your email address will not be published.