HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Exclude directory when making a tarball

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#86365 (In Topic #17663)
Avatar

Community saint

I am trying to make a tarball with the 'uploads' directory excluded. I can successfully create the tarball but I cannot get it to exclude the 'uploads' directory. I am in public_html and I execute the following command:

Code

tar cvfzpP FILENAME.tar.gz --exclude='/DIR/uploads/*' DIR
This seems like it should exclude all the contents of the 'uploads' directory but the tarball always includes them. Cam any of you command line commandoes point out the error of my ways?

Thanks for any help.

Bob
Back to the top
 
Posted
Item has a rating of 5 (Liked by BobS)  
Rating:
#86375
Avatar

Community saint

Apparently the -f parameter needs to be last, so try cvzpPf instead of cvfzpP.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#86380
Avatar

Community saint

Thanks for the input , temp. I tried using the following:

Code

tar cvzpPf FILENAME.tar.gz --exclude='/DIR/uploads/*' DIR

but, unfortunately, got the same results which including the unwanted /uploads directory. It seems like this should be so straight-forward but I can't seem to figure it out. I've tried a few other variations on your suggestion, but the result was always the same.

Thanks for your help though. Ay more ideas?

Bob
Back to the top
 
Posted
Item has a rating of 5 (Liked by BobS)  
Rating:
#86383
Avatar

Community saint

Nothings jumping out at me other then the obvious missing "-" in front of cvzpPf, but I'm sure that is just a typo in your example code.

I don't think the position of –exclude is significant, but most of the example I've seen have it after DIR.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Item has a rating of 5 (Liked by BobS)  
Rating:
#86386
Avatar

Community saint

Use the full path of the excluded directory.

Steve
Back to the top
 
Posted
Rating:
#86398
Avatar

Community saint

This is one of the most frustrating things I have encountered in a long time.

I've tried all the suggestions above including using the full path to the excluded directory and placing the exclude at the end of the command (with no whitespace). I have scoured the web for other solutions which included using no single-quotes around the exclusion and placing exclusion as the first parameter. Some post insist that the full path is needed while others argue the the relative path is preferred. None of them work.

Who would have thought that something so simple could end up being so difficult.

Bob
Back to the top
 
Posted
Item has a rating of 5 (Liked by BobS)  
Rating:
#86399
Avatar

Community saint

Try this, I know it works on my box…

Code

tar cvzpP --exclude /path/to/DIR -f test.tar.gz /path/to/dir

You don't need to specify a wildcard for the excluded DIR, only the DIR name. The path to the excluded DIR is also optional.

This will create the tarball in your current directory.

Steve
Back to the top
 
Posted
Rating:
#86400
Avatar

Community saint

Unfortunately, that didn't work either but my host came up with something that does:

Code

tar -cvzpPf FILENAME.tar.gz /home/HOME_DIR/public_html/ROOT_DIR/ --exclude "/home/HOME_DIR/public_html/ROOT_DIR/uploads" --exclude "/home/HOME_DIR/public_html/ROOT_DIR/persistant_cache"

I hate the full paths but they seem to be required, maybe because I am on a shared server. Who knows? I'm just glad to have something that works.

I've excluded a second directory (persistant_cache - I hope this one is being renamed in v9) – my initial 2GB tarfile has been reduced down to just 57MB. Much better and better-suited for my purposes.

Thanks for the help temp and sholzy.

Bob
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: