Re: Backing up selective sub directories...and dir and include

Miek Gieben <[email protected]> Wed, 1 Sep 2004 14:17:00 +0200
Newsgroups gmane.comp.sysutils.backup.hdup.general
Message-ID <[email protected]>
[On 31 Aug, @ 21:28, Robert wrote in "[hdup-user] Backing up selecti ..."]
> First off, hdup is an excellent backup utility. It sems to do just about 
> everything we need it to do! My initial testing went well, where I 
> backed up a number of remote hosts to a central host. Static 
> directories, no include/excludes, works perfectly. Very simple to setup, 
> low overhead, creates tar files easily extractable.

thanks! :)

> However, during the next stage rollout, we want to be able to allow 
> users to place files in a subdirectory of their home directory to be 
> backed up, without backing up the entire contents of /home or even 
> /home/<user>.

I want that too... another thing I want is .nobackup files, in which a
user can specify what files and directories should not be backupped.
But alas tar doesn't support those features.

> An example of such a directory to back up would be /home/rhaskins/bak. 
> We want to backup only the files in /home/rhaskins/bak without having to 
> specify all users via the "dir" directive. Essentially, we want to back 
> up "/home/*/bak/". An "ls /home/*/bak" returns the proper list of files 
> to be backed up.
> 
> I have attempted several ways of doing this, but the "include" directive 
> pattern seems to require files globs, and doesn't seem to allow 
> directory globs. At least, I haven't been able to figure out how. 

this is all documented in the tar info files/manpage. Why tar still
uses file globs in stead of regexps is a mystery for me. However I
don't know what is on the TODO list for tar and if this is going to
change (or that gnu tar 1.14 already has some of this stuff, if
so... I would be worthwhile to look into this).

> Looking at the code, and the find command, it seems to wants have file 
> globs.

There is a -regex for GNU find - but the reason I didn't go this route
was to not have 2 different patterns (globbing/regexp) in one program.

I think all the stuff you mentioned could/should be fixed by using the
correct 'find' cmd line. However this would require some hacking in
hdup.

> One way we thought of doing this was by using symlinks from a directory 
> we are backing up (/var/bak) to each user's backup directory 
> (/home/rhaskins/bak). Then, tell tar to backup the actual files pointed 
> to by the symlinks, rather than symlinks (which is the tar default). 
> However, there doesn't seem to be any way to pass tar options from hdup.

You could hack setup_tarcmd() in hduptarlib.c line 553 and add your
option there. But IHMO this really sounds very ugly....

> Has anyone solved this problem? Any ideas on how to accomplish this? 
> Thanks very much for your time.

Well no... :( 
The solution is: not using the tar builtins for generating a filelist,
but using 'find' for all these things. This is however not a minor
change - and it requires two passes for each backup: find + tar...

grtz,
--Miek