mav
asked on
tar Directory Exclude
I'm writing a backup routine to .tar the contents of selected
directories. That's the easy part. Here's the problem.
I was to EXCLUDE the directory 'logs' from all the selected
directories to tar.
So say I tar recursively from my root directory using the "*"
wildcard. That would tar everything. But I want to exclude any
directories called 'logs', but sill tar recursively from the root.
Somebody suggested this so far, but it did't work, here's
my comments about it.
>find -type d -name logs -print > exclude_this
>tar cvXf exclude_this backup_filename *
I don't think this works. The first line does give
me a list of all the 'logs' directories. But the tar line doesn't seem
to work. As far as I can tell, tar doesn't have an 'exclude' option,
thus the file 'exclude_this' was ignored and everything was tar'ed
anyway.
Any Ideas? Thanks!
Chris
directories. That's the easy part. Here's the problem.
I was to EXCLUDE the directory 'logs' from all the selected
directories to tar.
So say I tar recursively from my root directory using the "*"
wildcard. That would tar everything. But I want to exclude any
directories called 'logs', but sill tar recursively from the root.
Somebody suggested this so far, but it did't work, here's
my comments about it.
>find -type d -name logs -print > exclude_this
>tar cvXf exclude_this backup_filename *
I don't think this works. The first line does give
me a list of all the 'logs' directories. But the tar line doesn't seem
to work. As far as I can tell, tar doesn't have an 'exclude' option,
thus the file 'exclude_this' was ignored and everything was tar'ed
anyway.
Any Ideas? Thanks!
Chris
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi there,
alternatively you can use zip / unzip for backup purposes. This
will compress the files while creating one big file.
To exclude the log directories you would use it like this :
zip -r <Dest_file> <Source Dirs> -x log
This will exclude all the log directories from the zip file
created. You can then use tar to put the .zip files on a tape.
The sources for zip and unzip can be found anywhere on the WEB.
Hope this will help you...
Leendert.
alternatively you can use zip / unzip for backup purposes. This
will compress the files while creating one big file.
To exclude the log directories you would use it like this :
zip -r <Dest_file> <Source Dirs> -x log
This will exclude all the log directories from the zip file
created. You can then use tar to put the .zip files on a tape.
The sources for zip and unzip can be found anywhere on the WEB.
Hope this will help you...
Leendert.
alternatively you can use zip / unzip for backup purposes. This
will compress the files while creating one big file.
To exclude the log directories you would use it like this :
zip -r <Dest_file> <Source Dirs> -x log
This will exclude all the log directories from the zip file
created. You can then use tar to put the .zip files on a tape.
Hope this will help you...
Leendert.