LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tar all but these... (https://www.linuxquestions.org/questions/linux-newbie-8/tar-all-but-these-34102/)

lhoff 10-29-2002 06:23 AM

tar all but these...
 
I want to tar a directory, except for 2 subdirectories within that directory.

What are the options for tar that will let me do that?

0x0001 10-29-2002 07:09 AM

i wonder, do you know man? In case you don't: type
man man
to get an explanation.
In case you know man, do you know that you can search in man pages by typing / and the word you search for?

try for example:
man tar
and in the program type
/exclude
and tada you have what you where looking for.

offence meant!


short:
tar cf <whatever.tar> --exclude=<file you do not want to include>

lhoff 10-29-2002 07:15 AM

Quote:

Originally posted by 0x0001
i wonder, do you know man?

offence meant!


None taken.

trickykid 10-29-2002 07:21 AM

Quote:

Originally posted by 0x0001
i wonder, do you know man? In case you don't: type
man man
to get an explanation.
In case you know man, do you know that you can search in man pages by typing / and the word you search for?

try for example:
man tar
and in the program type
/exclude
and tada you have what you where looking for.

offence meant!


short:
tar cf <whatever.tar> --exclude=<file you do not want to include>

As this is very helpful reply, lighten up with the attitude. Its one thing to tell someone to go RTFM, but you don't have to say it the way you did with anything extra. If you can't be polite in your posts, then don't post at all and the next member along would have answered his question most likely in a polite and professional manner.

lhoff 10-29-2002 08:27 AM

Anyway, I don't make a habit of asking a question here unless I have first looked in man and found the information sparse or unhelpful. To wit: the description of --exclude simply states that FILE will be excluded. It doesn't give any additional information, such as how I can specify multiple files in the --exclude argument or if I can specify directories. I assumed that I could specify directories and that I would write a tar command, excluding 3 directories (My Documents, Program Files, and the windows directory) from my Windows partition along these lines:

tar -czvf todaysarchive.tar.gz /mnt/win_c --exclude My\ Documents Program\ Files windows

But, that didn't work: one of the first things tar did was to write mnt/win_c/windows/* to the archive. (At which point, I killed the job.)

If anyone can help, consider me thankful!

0x0001 10-29-2002 09:16 AM

Well sorry for my rudeness.

you need the = after --exclude, and you have to give --exclude for every exclusion iirc.
try:

tar -czvf todaysarchive.tar.gz /mnt/win_c --exclude=My\ Documents --exclude=Program\ Files --exclude=windows

if that doesn't work try to quote the exclusion directories,e.g.:

tar -czvf todaysarchive.tar.gz /mnt/win_c --exclude="My Documents" --exclude="Program Files" --exclude="windows"

lhoff 10-29-2002 09:22 AM

Merci, gracias, thanks, or what you will.

0x0001 10-29-2002 12:14 PM

hehe stupid me:)

I forgot that you have to give the path. The above might work, but if it does not try the following:

tar -czvf todaysarchive.tar.gz /mnt/win_c --exclude="/mnt/win_c/My Documents" --exclude="mnt/win_c/Program Files" --exclude="mnt/win_c/windows"

seems that not only my temper but also my memory has suffered a bit today, well well well.

lhoff 10-29-2002 12:35 PM

If nobody else ever ranted first and thought later, then I'd be forever "persona non-grata" in forums. I'm just glad the thread turned productive.

And the first method worked, though I will note the necessity of including the full path for future reference.

murshed 12-03-2002 05:05 AM

unfortunately,
all these didn't work with me ... i'm really looking for something similar

i have a huge folder with one huge subfolder that i wish to exclude from taring it ...
any tested commands?

0x0001 12-03-2002 05:10 AM

Error messages if any? What command did you use, and was the file created?

murshed 12-03-2002 06:07 AM

no error msgs, every command i used ( well all are listed above) they just tar everything .. i had to kill the process everytime
i want to exclude a folder .. not a file
thanks

0x0001 12-03-2002 06:59 AM

Yeah well thats not much input.

Do you have a link to the directory you exclude somewhere in the included directoris? That would be the only thing I can think of right now.

murshed 12-03-2002 07:22 AM

ok i will give u exactly what i do:

i have a site on a server .. and now am in the root folder of that site.. fine?

there are many subfolders in the root folder ... one of them is the httpdocs folder that contains the site's files
i have temp folder that i do some testing in it ..and it contains huge files that i don't want to include when i do a full back up for the httpdocs folder ..
the command i used was:
tar -cvf backup.tar httpdocs/ --exclude httpdocs/temp/

this would tar everything .. it tars what the temp folder contains

i tried the commands listed in this thried but they all tared everthing:)

any other things you want to know?
thanks

0x0001 12-03-2002 07:32 AM

The --exclude requires and = after it. It reports no error if it is missing, it just doesn't work. Kinda stupid but we got to live with it.
try:
tar -cvf backup.tar httpdocs/ --exclude=httpdocs/temp/


All times are GMT -5. The time now is 07:42 AM.