The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 22, 2019, 07:29:24 PM

Login with username, password and session length


Pages: [1] 2
  Print  
Author Topic: Dammit! How do I exclude files from a tar archive????  (Read 4983 times)
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« on: September 10, 2009, 10:26:16 AM »

I've tried this a bazillion ways and always just give up because I've got to get it done.

I've tried:
tar -czvf -x *.flv ../mytarball.tar.gz *
tar -c -z -v -f -x *.flv ../mytarball.tar.gz *
tar -c -z -v -f -x=*.flv ../mytarball.tar.gz *
tar -c -z -v -f --exclude=*.flv ../mytarball.tar.gz *
tar -c -z -v -f --exclude-file=./aFileWithPatterns  ../mytarball.tar.gz *

... and none of them do the proper exclusions. What I want to do is exclude tarballs, flvs and isos from my tarball.

Any help appreciated. Motrin also.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #1 on: September 10, 2009, 11:47:49 AM »

 
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« Reply #2 on: September 10, 2009, 02:10:14 PM »

Kind of a hack but could you use find and | the results to tar cf?
Logged

Will code for food.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: September 10, 2009, 02:24:06 PM »

Hmmm... going positive rather than exclude... perhaps. Do you know what the format is if I want to lots of suffixes or even whole directories? This is a backup application, so I want to include all my MySQL files (from over there) images, pdfs, php etc from (from another dir) etc... don't know what that'd look like.

My goal here is to quit with my gigantic tarball creation and download... I have dozens of hundreds of large flvs that I don't need to back up, ISOs, old tarballs etc that I don't want to eliminate but don't want to backup. I want to do it more often and it'll need to be much lighter to do so...
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« Reply #4 on: September 10, 2009, 02:33:33 PM »



find . -not -name *.flv -not -name *.tar

should work, no?

Logged

Will code for food.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #5 on: September 10, 2009, 04:40:28 PM »

Hmmm... an interesting notion. With a inclusive, rather than exclusive notion it'd be easier for me to potentially grab everything that I want to archive into one biggie, rather than several archives.

Thanks C, gonna give that a think.

j'Preciate Smiley
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
kurdt
Lifer
*****
Offline Offline

Posts: 1153


paha arkkitehti


View Profile
« Reply #6 on: September 10, 2009, 05:05:49 PM »

And you tested rm *.tar* also? That excludes..
Logged

I met god and he had nothing to say to me.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #7 on: September 10, 2009, 05:08:56 PM »

Grrr.

Need some more helps perhaps. I have find doing exactly what I want, and I like what you've proposed C. It gives me a nice list of everything I want to backup in a text file, so that I can preview it before it goes - this is handier than getting half way through a tarball and realizing I've got something I don't want.

Now I'm having trouble telling tar what to *include*. Sites all say -I or --include or --include-from and such, but those options do not seem to exist in this version of tar (version 1.5.1, FC 6 on this box, no listing in the man page either) so I've seen some things like cat list.txt|xargs tar.cf thearchive.tar ... and tried them - but it ignored the cat'd list and just started archiving everything.

Sorry for the lean meng, thanks for the help.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #8 on: September 10, 2009, 05:09:40 PM »

And you tested rm *.tar* also? That excludes..

Heh... excludes permanently you mean Wink Don't want to get rid of stuff, just to keep them out of this oft-run backup.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #9 on: September 10, 2009, 05:13:40 PM »

What I'm working with now is a bash script with lines like this:

find /www/sites/aproject -not -name *.flv -not -name *.tar* -not -name *.iso -not -name *OLD* -not -name *DS_Store* >> aproject.todo

where aproject is a website and all resources, then another line that includes it's database files from mysql and then another that includes it's sitefile from my Apache configuration (I have all my sites included into the httpd.conf rather than actually in them). I get a very attractive list that, having run from the root, includes the entire file page of everything I want to grab to keep (aproject)'s associated files.

So What I'd like to do is just feed tar with these files, then I could either have a project file for just (aproject) or one master backup file should I choose - I'll probably go with distinct files.

I don't understand the usage of cat, have tried it in front and in back of the tar command with < and | and such - I'm CERTAIN that I'm just a luddite and doing it wrong.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« Reply #10 on: September 11, 2009, 06:09:03 AM »

One thing you could do is read in the entire file line by line, build the tar command, and execute it. It's not pretty but it should work.
Logged

Will code for food.
kurdt
Lifer
*****
Offline Offline

Posts: 1153


paha arkkitehti


View Profile
« Reply #11 on: September 11, 2009, 06:18:07 AM »

Or you could just press ctrl down and pick only the files you want to compress... wait.. I think I have one more.. Or you could mv *.tar* to another hd while you compress other files.
Logged

I met god and he had nothing to say to me.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #12 on: September 11, 2009, 07:23:13 AM »

Sec, I will bang something out. Sorry Perks if I'd caught this last night I'd have written you a simple one-liner. You guys are WAY wrapped around the axle here.
Code:
find /www/sites/aproject -not -name *.flv -not -name *.tar* -not -name *.iso -not -name *OLD* -not -name *DS_Store* | xargs tar -czvf

Haven't tested it. Would be VERY surprised if it didn't do exactly what you need. Write a log with >> like you were doing, but I would not append the raw list of files like that or you're just going to keep duplicating stuff.
Logged

hai
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #13 on: September 11, 2009, 07:36:02 AM »

Here's one from scratch that should be faster (find is a BEAR on its own):

Code:
find /www/sites/aproject -not -regex '/\.flv.*?|\.tar.*?|\.iso.*?|.*?OLD.*?|.*?DS\_Store.*?/' | xargs tar -czvf
Logged

hai
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #14 on: September 11, 2009, 07:49:52 AM »

Thanks guys ... and hiya V - I was wondering if you were just giving me the silent treatment for being an idiot  ROFLMAO

I worked through most of it last night.

First issue, the tar executable was not current & didn't have files-from - downloaded the newest GNU tar, compiled and installed.

Problem was it was including every single file, regardless of the files-from instruction (or so I thought). Then finally got the idea that the find command would have found dirs as well - in other words, calling out a dir it was recursing the dir and collecting everything it saw, even though I had not specifically called out the files. So I added no dir recursion to the command line.

Then I was getting an error at the end of it which was bollocksing the tarball, which I gathered was a bad read of a sym link - add ignore bad reads and it's all good.

So my goals today are to write up the construction portion (which builds the todo lists for all the sites that are affected by this) and the downloader.

And also to understand xargs and the pipe better, which you use here are it looks understandable, but I'd love it if you'd just give a light overview of how and where piping and various *nix commands can be combined on a line like this to create complex instructions.

thanks again lads Smiley
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1] 2
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!