LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 04-28-2005, 05:33 AM   #1
tobycatlin
Member
 
Registered: Apr 2005
Location: Norwich, UK
Posts: 30

Rep: Reputation: 15
Excluding a file when using pax


I am using pax to backup my files and need to exclude a couple of large files. The file names never change.

From reading the man pages i should use the -c operator but it doesn't give any examples. this is my best guess but it says i am using a invaild combination of w c and f

pax -w -f test /root/code_samples -c /root/code_samples/phpMyAdmin-2.6.2.zip

Does anyone know how to exclude a file??

thanks

t
 
Old 04-28-2005, 08:29 AM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
I think pax could turn out to be a nice little gem and may have to check it out some more.
The man page can be a bit confusing for sure but here is an excellent article. The -c option is on page three and is used like this.... -c './Linux Stuff' where that is the directory which I don't want restored.
http://www.onlamp.com/pub/a/bsd/2002...cs.html?page=1

Here is an example I used.
Code:
# ls
Linux Stuff  Linux Technical Docs

# I cd into the Linux directory and make a backup file called backup
pax -wf /home/backup .

# Now I want to restore everything exept the directory called "Linux Stuff"
# In this example, I'll restore to /home/images for testing purposes.
cd /home/images
pax -rvf /home/backup -c './Linux Stuff'
Don't forget to use single quotes on the file or directory to exclude from the restore.
 
Old 04-28-2005, 09:05 AM   #3
tobycatlin
Member
 
Registered: Apr 2005
Location: Norwich, UK
Posts: 30

Original Poster
Rep: Reputation: 15
so the -c flag is only good for excluding a folder from being restored?
Not excluding it from being in the backup in the first place?
 
Old 04-28-2005, 09:09 AM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
That's what I gather so far. I'll have to do some more checking to see what other options there are but I don't think -c is used during save operations.
 
Old 04-28-2005, 09:20 AM   #5
tobycatlin
Member
 
Registered: Apr 2005
Location: Norwich, UK
Posts: 30

Original Poster
Rep: Reputation: 15
what i want to do it to backup a users site into a single file and then offer it back to them so that they can download it and save it. (Basically so they are ultimately responsible for the data and not me)

My users like many others are a bit thick and we have advertised as a 'no extra software required' websites. So i would like to avoid using a FTP client. It would be great if the user just clicks a link and off they go.

Therefore i thought if i can backup /home/website1 and then copy that file to /home/website1/backup the users can download from /home/website1/backup directly (obviously with sufficent authentication)

This leads to the problem that the next time the backup is run it will backup the backup. Because the user is downloading the backup file it is vital that it is as small as possible.
 
Old 04-28-2005, 09:21 AM   #6
tobycatlin
Member
 
Registered: Apr 2005
Location: Norwich, UK
Posts: 30

Original Poster
Rep: Reputation: 15
Can specific file be removed from the backup file after creation??
 
Old 04-28-2005, 09:30 AM   #7
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Quote:
(Basically so they are ultimately responsible for the data and not me)
You are about to find out just how "thick" these people can be.

I don't know what all options you can use.
 
Old 04-28-2005, 09:49 AM   #8
tobycatlin
Member
 
Registered: Apr 2005
Location: Norwich, UK
Posts: 30

Original Poster
Rep: Reputation: 15
the man reason i am doing this is because one of my users deleted all the products out of the database then phoned me asking what the undo command was. He wasn't happy when i said there wasn't one. I did have a backup but it was before he added 400 products, again he wasn't happy.

I am open to any and all suggestions

thanks for your help
 
Old 04-28-2005, 11:02 AM   #9
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: Ubuntu, FreeBSD, NetBSD
Posts: 1,449

Rep: Reputation: 47
Code:
find /path/to/dir -name "*" | grep -v "file_to_exclude" | pax -w -d -x ustar | bzip2 > name_of_tar.tar.bz2
Okay this is involved but not too complicated. The find command is going to find every single file in their directory. It will pass that to the grep command, which will remove the lines which match the pattern of the file you don't want (use the whole name and path -- look at the find output to determine what this is -- to make sure you get only it). The grep command pipes all those filenames to pax... which writes an archive. The -d flag is what is important. It tells pax to match directories but not all the files beneath it. Basically, it says "only archive what I specifically name". In this case I use ustar as my format but you can use whichever makes sense for your users and is supported. I also pass it through bzip2 to compress it as well. This may or may not work for you (if you don't think your users will have bunzip2 or access to a program that will handle it).
 
Old 04-28-2005, 11:13 AM   #10
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: Ubuntu, FreeBSD, NetBSD
Posts: 1,449

Rep: Reputation: 47
Okay, here it is in more of a script format.
Code:
#!/bin/sh
DIRECTORY=/directory/to/backup
EXCLUDE="backup/backup.file.name.tar.bz2"
COMPRESS=bzip2
ARCHIVE=$DIRECTORY/$EXCLUDE
find $DIRECTORY -name "*" |\
grep -v $EXCLUDE |\
pax -w -d -x ustar |\
$COMPRESS > $ARCHIVE
Note, you could pass each user's directory as an argument and just assign it to DIRECTORY, or you could modify this script to step through each one... and do this for each. But it gives you the basic idea.

Last edited by frob23; 04-28-2005 at 11:20 AM.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excluding a directory when copying Woodsman Slackware 2 10-30-2005 06:25 PM
OpenBSD vs Linux+PaX+SSP+RSBAC jakaro *BSD 3 06-23-2005 07:05 PM
excluding an I.P. or domain with php dave4545 Programming 4 11-27-2003 10:51 PM
tar and excluding files murshed Linux - Newbie 7 03-15-2003 02:32 PM
DHCP excluding IP addresses AndyJ Linux - Networking 8 03-03-2003 03:09 PM


All times are GMT -5. The time now is 05:46 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration