Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #198864 > unrolled thread

Re: How to exclude Some but not All dot files?

Started byGreg Wooledge <wooledg@eeg.ccf.org>
First post2018-08-16 16:50 +0200
Last post2018-08-16 19:00 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.debian.user

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to exclude Some but not All dot files? Greg Wooledge <wooledg@eeg.ccf.org> - 2018-08-16 16:50 +0200
    Re: How to exclude Some but not All dot files? cyaiplexys <cyaiplexys@sitesplace.net> - 2018-08-16 17:20 +0200
      Re: How to exclude Some but not All dot files? Greg Wooledge <wooledg@eeg.ccf.org> - 2018-08-16 17:30 +0200
        Re: How to exclude Some but not All dot files? cyaiplexys <cyaiplexys@sitesplace.net> - 2018-08-16 17:40 +0200
        Re: How to exclude Some but not All dot files? cyaiplexys <cyaiplexys@sitesplace.net> - 2018-08-16 18:50 +0200
          Re: How to exclude Some but not All dot files? Gene Heskett <gheskett@shentel.net> - 2018-08-16 19:00 +0200

#198864 — Re: How to exclude Some but not All dot files?

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2018-08-16 16:50 +0200
SubjectRe: How to exclude Some but not All dot files?
Message-ID<wnrL3-4VA-3@gated-at.bofh.it>
On Thu, Aug 16, 2018 at 10:40:14AM -0400, cyaiplexys wrote:
> tar -czf archive.tgz /home/me/dirToARchive/.
> --exclude=/home/me/dirToARchive/.mysetuptemp
> --exclude=/home/me/dirToARchive/.myotherdotfile
> --exclude=/home/me/dirToARchive/.anotherdotfile
> 
> I found it doesn't matter if I put the --excludes before the -czf or after
> everything, I still end up with EVERY dot file in the directory instead of
> ONLY the ones that are NOT on the list.

wooledg:/tmp/x$ touch .good .bad1 .bad2
wooledg:/tmp/x$ tar czf ../foo.tgz --exclude ./.bad1 --exclude ./.bad2 .
wooledg:/tmp/x$ tar tzvf ../foo.tgz
drwxr-xr-x wooledg/voice     0 2018-08-16 10:43 ./
-rw-r--r-- wooledg/voice     0 2018-08-16 10:43 ./.good

I think your primary problem is that you are passing absolute paths
to tar.  This is evil.  You wouldn't want absolute paths in your tarball,
and in fact, GNU tar will chastise you for doing so, and then will strip
the leading slashes for you.  (Unix tar is not so forgiving.  It will
gleefully do exactly what you said, creating a tarball with absolute
paths in it, which means it cannot safely be extracted.)

Perhaps there is some kind of collision between the auto-stripping of
the leading slashes, and your --exclude patterns which still have those
leading slashes on them.

[toc] | [next] | [standalone]


#198869

Fromcyaiplexys <cyaiplexys@sitesplace.net>
Date2018-08-16 17:20 +0200
Message-ID<wnse5-5k3-5@gated-at.bofh.it>
In reply to#198864
On 08/16/2018 10:45 AM, Greg Wooledge wrote:
> On Thu, Aug 16, 2018 at 10:40:14AM -0400, cyaiplexys wrote:
>> tar -czf archive.tgz /home/me/dirToARchive/.
>> --exclude=/home/me/dirToARchive/.mysetuptemp
>> --exclude=/home/me/dirToARchive/.myotherdotfile
>> --exclude=/home/me/dirToARchive/.anotherdotfile
>>
>> I found it doesn't matter if I put the --excludes before the -czf or after
>> everything, I still end up with EVERY dot file in the directory instead of
>> ONLY the ones that are NOT on the list.
> 
> wooledg:/tmp/x$ touch .good .bad1 .bad2
> wooledg:/tmp/x$ tar czf ../foo.tgz --exclude ./.bad1 --exclude ./.bad2 .
> wooledg:/tmp/x$ tar tzvf ../foo.tgz
> drwxr-xr-x wooledg/voice     0 2018-08-16 10:43 ./
> -rw-r--r-- wooledg/voice     0 2018-08-16 10:43 ./.good
> 
> I think your primary problem is that you are passing absolute paths
> to tar.  This is evil.  You wouldn't want absolute paths in your tarball,
> and in fact, GNU tar will chastise you for doing so, and then will strip
> the leading slashes for you.  (Unix tar is not so forgiving.  It will
> gleefully do exactly what you said, creating a tarball with absolute
> paths in it, which means it cannot safely be extracted.)
> 
> Perhaps there is some kind of collision between the auto-stripping of
> the leading slashes, and your --exclude patterns which still have those
> leading slashes on them.

I actually have several accounts which I want to back up but not include 
all the dot files. It would be too much to go into each account and run 
a script. I would like to do it from one account.

[toc] | [prev] | [next] | [standalone]


#198870

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2018-08-16 17:30 +0200
Message-ID<wnsnM-5n9-7@gated-at.bofh.it>
In reply to#198869
On Thu, Aug 16, 2018 at 11:19:29AM -0400, cyaiplexys wrote:
> I actually have several accounts which I want to back up but not include all
> the dot files. It would be too much to go into each account and run a
> script. I would like to do it from one account.

Then do it from /home.

Or do it from / and use "home" as the starting point.  Rather than "/home".

[toc] | [prev] | [next] | [standalone]


#198871

Fromcyaiplexys <cyaiplexys@sitesplace.net>
Date2018-08-16 17:40 +0200
Message-ID<wnsxr-5q6-9@gated-at.bofh.it>
In reply to#198870
On 08/16/2018 11:21 AM, Greg Wooledge wrote:
> On Thu, Aug 16, 2018 at 11:19:29AM -0400, cyaiplexys wrote:
>> I actually have several accounts which I want to back up but not include all
>> the dot files. It would be too much to go into each account and run a
>> script. I would like to do it from one account.
> 
> Then do it from /home.
> 
> Or do it from / and use "home" as the starting point.  Rather than "/home".

That's something I never thought of, oddly. Good idea!

[toc] | [prev] | [next] | [standalone]


#198876

Fromcyaiplexys <cyaiplexys@sitesplace.net>
Date2018-08-16 18:50 +0200
Message-ID<wntDb-60K-3@gated-at.bofh.it>
In reply to#198870
On 08/16/2018 11:21 AM, Greg Wooledge wrote:
> On Thu, Aug 16, 2018 at 11:19:29AM -0400, cyaiplexys wrote:
>> I actually have several accounts which I want to back up but not include all
>> the dot files. It would be too much to go into each account and run a
>> script. I would like to do it from one account.
> 
> Then do it from /home.
> 
> Or do it from / and use "home" as the starting point.  Rather than "/home".

Thank you. This worked like a charm and I didn't have to deal with those 
warning messages in tar. Learned something new. :)

[toc] | [prev] | [next] | [standalone]


#198877

FromGene Heskett <gheskett@shentel.net>
Date2018-08-16 19:00 +0200
Message-ID<wntMR-63E-3@gated-at.bofh.it>
In reply to#198876
On Thursday 16 August 2018 12:46:30 cyaiplexys wrote:

> On 08/16/2018 11:21 AM, Greg Wooledge wrote:
> > On Thu, Aug 16, 2018 at 11:19:29AM -0400, cyaiplexys wrote:
> >> I actually have several accounts which I want to back up but not
> >> include all the dot files. It would be too much to go into each
> >> account and run a script. I would like to do it from one account.
> >
> > Then do it from /home.
> >
> > Or do it from / and use "home" as the starting point.  Rather than
> > "/home".
>
> Thank you. This worked like a charm and I didn't have to deal with
> those warning messages in tar. Learned something new. :)

Excludes in amanda, which uses tar, are anchored to the directory they 
are in, so the exludes file looks like:
./name
./.name should also work for the "dot" files


-- 
Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web