RE: tar question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David,

Please look at the tar line closer:

# tar -cvf /backup.tar --exclude=home/tempuser/work /home/tempuser

/home/tempuser was not a 2nd --exclude line, but was telling tar what
directory to archive.


Just to illustrate my reasoning:

# tar -zcvf /log.tgz etc/logrotate.d --exclude=etc/logrotate.d/tux
etc/logrotate.d/
etc/logrotate.d/syslog
etc/logrotate.d/httpd
etc/logrotate.d/samba
etc/logrotate.d/cups

# tar -zcvf /log.tgz etc/logrotate.d --exclude=/etc/logrotate.d/tux
etc/logrotate.d/
etc/logrotate.d/syslog
etc/logrotate.d/httpd
etc/logrotate.d/samba
etc/logrotate.d/tux  <-- no longer excluded when using '/'
etc/logrotate.d/cups


My version of tar is 1.13.25, plus I'm also using the '=' in my exclude.
It is possible that they changed how exclude works in the newer version
of tar.


-Rob


> -----Original Message-----
> From: redhat-list-bounces@xxxxxxxxxx 
> [mailto:redhat-list-bounces@xxxxxxxxxx] On Behalf Of David 
> Tonhofer, m-plify S.A.
> Sent: Thursday, October 06, 2005 2:14 PM
> To: General Red Hat Linux discussion list
> Subject: RE: tar question
> 
> --"Dege, Robert C." <robert.dege@xxxxxxx> wrote:
> 
> >
> > Tar will only exclude patterns that match the list in the 
> archive it's 
> > creating.  So first, you need to drop the '/', since tar 
> automatically 
> > drops that.
> >
> > So your tar line should look like this:
> >
> > # tar -cvf /backup.tar --exclude=home/tempuser/work /home/tempuser
> 
> Not true ;-) ... It's not important whether you have the '/' or not.
> But you must precede every 'exclude' with the '--exclude' 
> flag. You can't list them like you did. At leas in GNU tar.
> 
> Try this (tar-1.14-4): The presence of the toplevel '/' has no effect:
> 
>    # cd /tmp
> 
>    # tar czf etc1.tgz /etc --exclude etc/sysconfig
>    # tar czf etc2.tgz /etc --exclude /etc/sysconfig
>    # tar czf etc3.tgz /etc
> 
>    # tar tzf etc1.tgz | grep sysconfig
>    etc/X11/sysconfig/
>    etc/X11/starthere/sysconfig.desktop
> 
>    # tar tzf etc2.tgz | grep sysconfig
>    etc/X11/sysconfig/
>    etc/X11/starthere/sysconfig.desktop
> 
>    # tar tzf etc3.tgz | grep sysconfig
>    etc/sysconfig/
>    etc/sysconfig/console/
>    etc/sysconfig/system-logviewer
>    etc/sysconfig/ntpd
>    ........
> 
> However:
> 
>    # tar czf etc4.tgz /etc --exclude etc/sysconfig etc/ntp
>    tar: Removing leading `/' from member names
>    tar: etc/ntp: Cannot stat: No such file or directory
>    tar: Error exit delayed from previous errors
> 
> You must do
> 
>    # tar czf etc4.tgz /etc --exclude etc/sysconfig --exclude etc/ntp
> 
> Interestingly, I put the files-to-backup before the 
> '--exclude', you put them after, which is the way to do it 
> according to the man page.
> Interesting.
> 
> 
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
> 

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux