LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-29-2002, 07:23 AM   #1
lhoff
Member
 
Registered: Jun 2001
Location: Chicago
Distribution: Mandrake 10.0 Official
Posts: 181

Rep: Reputation: 30
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?
 
Old 10-29-2002, 08:09 AM   #2
0x0001
Member
 
Registered: Sep 2002
Distribution: Slackware 8.1
Posts: 84

Rep: Reputation: 15
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>

Last edited by 0x0001; 10-29-2002 at 08:10 AM.
 
Old 10-29-2002, 08:15 AM   #3
lhoff
Member
 
Registered: Jun 2001
Location: Chicago
Distribution: Mandrake 10.0 Official
Posts: 181

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by 0x0001
i wonder, do you know man?

offence meant!

None taken.
 
Old 10-29-2002, 08:21 AM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
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.

Last edited by trickykid; 10-29-2002 at 08:23 AM.
 
Old 10-29-2002, 09:27 AM   #5
lhoff
Member
 
Registered: Jun 2001
Location: Chicago
Distribution: Mandrake 10.0 Official
Posts: 181

Original Poster
Rep: Reputation: 30
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!

Last edited by lhoff; 10-29-2002 at 09:29 AM.
 
Old 10-29-2002, 10:16 AM   #6
0x0001
Member
 
Registered: Sep 2002
Distribution: Slackware 8.1
Posts: 84

Rep: Reputation: 15
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"
 
Old 10-29-2002, 10:22 AM   #7
lhoff
Member
 
Registered: Jun 2001
Location: Chicago
Distribution: Mandrake 10.0 Official
Posts: 181

Original Poster
Rep: Reputation: 30
Merci, gracias, thanks, or what you will.
 
Old 10-29-2002, 01:14 PM   #8
0x0001
Member
 
Registered: Sep 2002
Distribution: Slackware 8.1
Posts: 84

Rep: Reputation: 15
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.

Last edited by 0x0001; 10-29-2002 at 01:15 PM.
 
Old 10-29-2002, 01:35 PM   #9
lhoff
Member
 
Registered: Jun 2001
Location: Chicago
Distribution: Mandrake 10.0 Official
Posts: 181

Original Poster
Rep: Reputation: 30
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.
 
Old 12-03-2002, 06:05 AM   #10
murshed
Member
 
Registered: Jan 2002
Posts: 157

Rep: Reputation: 30
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?
 
Old 12-03-2002, 06:10 AM   #11
0x0001
Member
 
Registered: Sep 2002
Distribution: Slackware 8.1
Posts: 84

Rep: Reputation: 15
Error messages if any? What command did you use, and was the file created?
 
Old 12-03-2002, 07:07 AM   #12
murshed
Member
 
Registered: Jan 2002
Posts: 157

Rep: Reputation: 30
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
 
Old 12-03-2002, 07:59 AM   #13
0x0001
Member
 
Registered: Sep 2002
Distribution: Slackware 8.1
Posts: 84

Rep: Reputation: 15
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.
 
Old 12-03-2002, 08:22 AM   #14
murshed
Member
 
Registered: Jan 2002
Posts: 157

Rep: Reputation: 30
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
 
Old 12-03-2002, 08:32 AM   #15
0x0001
Member
 
Registered: Sep 2002
Distribution: Slackware 8.1
Posts: 84

Rep: Reputation: 15
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/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 03:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 11:55 AM
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 12:02 PM
.rpms, .tar.gz, .tgz, .src.rpm, & .tar.bz2 whoots Mandriva 10 10-18-2003 01:08 PM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 07:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration