[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Selecting files to back up
Sorry for the delay. Colin got married on Friday, so we were both
a bit distracted. :)
Yes, this looks like a real pain, shared with bsdtar. I've come
up with one and a half ways to do it.
1) generate it via an intermediate archive. Create one without
a/b, then a new one containing the prevous archive plus "a/b/f2".
$ tarsnap -c --exclude "a/b" -f backup-tmp a
$ tarsnap -c -f backup-real @@backup-tmp a/b/f2
$ tarsnap -d -f backup-tmp
$ tarsnap -tv -f backup-real
drwx---rwx 0 td td 0 Jun 29 12:54 a/
-rw-r--r-- 0 td td 0 Jun 29 12:54 a/f0
-rw-r--r-- 0 td td 0 Jun 29 12:54 a/b/f2
(I used `chmod 707 a` to demonstrate some unusual metadata)
((I was inspired by https://unix.stackexchange.com/a/243875))
2) Use the -s option: if a filename is replaced with the empty
string, it won't be backed up. So if we can match "a/b/* but not
a/b/f2", then it should work.
Unfortunately I'm not very familiar with non-trivial regex, so I
don't have a working example. So in pseudocode, it would be:
$ tarsnap -c --dry-run -v -s ',a/b/(.* but not f2),,' a
((I was inspired by
https://github.com/libarchive/libarchive/issues/1071#issuecomment-427807094))
I'll keep on playing with solution #2, so it's possible that I
might be able to send an update. FWIW, the regex is interpreted
with regcomp() using REG_BASIC.
Cheers,
- Graham Percival
On Thu, Jun 25, 2020 at 08:12:33PM -0700, Brian L. Matthews wrote:
> I'm just starting with tarsnap, and have it built, installed, and running on
> my iMac running Mojave, and I've been doing some dry runs to narrow down
> what I back up. Mostly things are working as I expect, but I've got one case
> that I haven't figured out a way to do. That's where I want to exclude a
> directory and its contents *except* for a smattering of files under it.
> Here's a simplified example.
>
> Say I have:
>
> $ find a -print
> a
> a/f0
> a/b
> a/b/f2
> a/b/f1
>
> Then:
>
> $ tarsnap --dry-run --no-default-config -c -v a
> a a
> a a/f0
> a a/b
> a a/b/f2
> a a/b/f1
>
> works as expected. Now, what I really want is to not archive anything in a/b
> except a/b/f2. I can do that with -T:
>
> $ cat T
> a/f0
> a/b/f2
> $ tarsnap --dry-run --no-default-config -c -v -T T
> a a/f0
> a a/b/f2
>
> but that means I lose all the directory metadata (if I include the
> directories, it backups up the directories *and* the files I include
> explicitly.) I could use nodump, but I'd have to set nodump on hundreds of
> thousands of files, and I don't know what that would interfere with (for
> example, one of my local backup methods is Time Machine and I want it to
> back up some of the files I don't want tarsnap to back up). I've tried
> include and exclude in .tarsnaprc, but nothing I've tried has worked the way
> I want. So... any thoughts?
>
> Thanks,
> Brian