tar - How to exclude a directory?

Robert Heller heller at deepsoft.com
Wed Mar 22 13:04:04 UTC 2017


At Wed, 22 Mar 2017 13:53:30 +0100 "Ubuntu user technical support,  not for general discussions" <ubuntu-users at lists.ubuntu.com> wrote:

> 
> On Wed, 22 Mar 2017 13:45:38 +0100, Xen wrote:
> >Ralf Mardorf schreef op 22-03-2017 13:22:
> >
> >> How could I use tar's "--exclude" option to exclude the
> >> directory
> >> /media/winos7/winOS_2/ardour_ragrug-2017-mar-21-DONT_DEL_AT_IO_ERROR/cubasis  
> >
> >You can't prefix it with ./
> 
> Ok, should it work with "--exclude" ?
> 
> Should I use
> 
> winOS_2/ardour_ragrug-2017-mar-21-DONT_DEL_AT_IO_ERROR/cubasis
> 
> or
> 
> /media/winos7/winOS_2/ardour_ragrug-2017-mar-21-DONT_DEL_AT_IO_ERROR/cubasis
> 
> ?

It depends...

On *exactly* what you told tar to bundle up.

For example:

tar czf winos7.tar.gz -C /media . \
    --exclude ./winos7/winOS_2/ardour_ragrug-2017-mar-21-DONT_DEL_AT_IO_ERROR/cubasis

OR

tar czf winos7.tar.gz /media/winos7 \
    --exclude /media/winos7/winOS_2/ardour_ragrug-2017-mar-21-DONT_DEL_AT_IO_ERROR/cubasis

The --exclude needs to match the what you asked tar to back up.

> 
> 
> 

-- 
Robert Heller             -- 978-544-6933
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
heller at deepsoft.com       -- Webhosting Services
       




More information about the ubuntu-users mailing list