The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
exclude a line big123456 Shell Programming and Scripting 3 04-24-2008 09:31 AM
du (exclude files) the_learner UNIX for Advanced & Expert Users 1 07-17-2007 11:06 AM
moving directories to new directories on multiple servers mackdaddy07 Shell Programming and Scripting 0 04-06-2007 08:30 AM
Exclude & Zip dreams5617 Shell Programming and Scripting 1 02-11-2007 05:01 PM
Pkgadd / gnutar finster UNIX for Dummies Questions & Answers 4 09-14-2003 10:01 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 04-16-2003
Registered User
 

Join Date: Jul 2002
Location: netherlands,Tilburg
Posts: 9
Unhappy GNUTAR exclude directories

Hi,

Can anyone help me with the following:
I want to make a backup from my (AIX) system.
But I don't want to backup a couple of temp-directories.
I tried it with the X-option, but that didn't work.

I hope that someone can help me.
Thanks in advance.

Corine
Forum Sponsor
  #2  
Old 04-16-2003
WIntellect's Avatar
Registered User
 

Join Date: Sep 2002
Location: United Kingdom
Posts: 170
The man page says:
Quote:
-X file
--exclude-from file Exclude files listed in file.
So what is the command you have been running that has failed?
__________________
FreeBSD - Opening computers from closed Windows
  #3  
Old 04-17-2003
Registered User
 

Join Date: Jul 2002
Location: netherlands,Tilburg
Posts: 9
Well the situation is as follows.
I've got a couple of directories containing files.
/appl/data
/appl/data/temp1
/appl/data/temp2

Now I would like to backup the directory /appl/data, but NOT the 2 temp directories.

So my command was as follows:

find /appl/data -name 'temp*' -prune -o -print | xargs tar -cvf /tmp/datadir.tar

This works but not completely because in the tar-file it is:
first everything (so also the temp-dir) and appended to the file is exactly what I want (so /appl/data and not the temp-dir). I am wondering what am I doing wrong ?
I hope someone can help me.
  #4  
Old 04-17-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,609
We seem to have several problems here....

xargs collects as many arguments as will fit on a line and then invokes the given program. A find command might find 1000's of files. So rather than, say, doing an "rm" 1000's of times, it better to use xargs. Then you may only use a few dozen rm commands, each one having a full argument list.

But this doesn't extend to "tar cvf /some/file". If you have too many arguments for one command line, you will get two command lines. The second "tar cvf /some/file" will overwrite the contents of the first. If you are not encountering this problem, you must not have very many files.

Next, when you ask tar to backup a directory, it will backup the contents of the directory as well.
So:
tar cvf /tmp/data.tar /appl/data /appl/data/somefile
is not going to backup one directory and one file. That "/appl/data" will cause tar to pick up the whole thing. The /appl/data/somefile will put a second copy of somefile in the archive. Your find command will output /appl/data as its first line. That already gets you everything.

And none of this has anything at all to do with exclude files which is where the thread started.

What you're supposed to do is to create a file and put the stuff in it that you want to exclude. So, for example, edit the file /tmp/ExcludeFile and put in the following two lines:
/appl/data/temp1
/appl/data/temp2
Then use the command:
tar cvfX /tmp/datadir.tar /tmp/ExcludeFile /appl/data
  #5  
Old 04-24-2003
Registered User
 

Join Date: Jul 2002
Location: netherlands,Tilburg
Posts: 9
I tried it, but it didn't work for me.

Now I've got a way that seemed to work.
It is:

tar -cvf /tmp/datadir.tar --exclude=temp* /appl/data

This seems to work, but it now also excludes the files temp.txt that are in /appl and that is not right.
So if anyone can help me a bit further would be nice.
  #6  
Old 04-24-2003
oombera's Avatar
Registered User
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
TheBlueLady,

What Perderabo wrote at the end of his post really should work for you.. I'd double-check and make sure you tried it exactly like he said..

I think you could also do it more the way you're saying by trying this:
cd /appl/data
tar -cvf /tmp/datadir.tar --exclude=/temp1/* --exclude=/temp2/* .

I'm not sure why you're concerned with files excluded in /appl though, since you said you only wanted to archive the subdirectory /appl/data

References:
http://www.cs.vassar.edu/SysNews/backups.html#doit
http://www.itworld.com/nl/unix_sys_a.../pf_index.html
http://www.eyetap.org/ece385/oreilly...pt/ch20_01.htm
  #7  
Old 04-25-2003
Registered User
 

Join Date: Jul 2002
Location: netherlands,Tilburg
Posts: 9
Hi oombera,

What Perderabo wrote sounds good, but really doesn't work for me, I just tried it again, the temp-directories still are in the archive. Also the way you described didn't work for me. Then the temp-directories are again in my archive.

But I've got a way that does work for me, it is not ideal, but it is working. It is the following:
tar -cvf /tmp/datadir.tar --exclude=temp1 --exclude=temp2 --exclude=temp3 /appl/data

You were also wondering why I am concerned with this. Well that is because of my daily backup of the whole system. Every day I want to make a backup on tape of the whole system, but not of the temp-directories. While the backup is being made other proces can be running changing files in the tempdirectories. Files in these directories change while in the meantime backup is trying to write them to tape, because of this the backup can crash. So that is the reason. Hope you understand me.
Anyway I am very thankful for all your help.
Google The UNIX and Linux Forums
Closed Thread

Tags
tar, tar exclude

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0