Google Answers Logo
View Question
 
Q: HOWTO use tar to backup *.pub files ( Answered,   3 Comments )
Question  
Subject: HOWTO use tar to backup *.pub files
Category: Computers > Operating Systems
Asked by: schmerold-ga
List Price: $15.00
Posted: 23 Nov 2004 13:31 PST
Expires: 23 Dec 2004 13:31 PST
Question ID: 433050
Our server has large publisher files, so we backup with following command:
tar czf $bakname --exclude 'bu?.*' --exclude '*.?BK' --exclude '_Q*'
--exclude '*.pub' /home/* /etc/*

I need to backup the publisher files, so I tried:
tar czf /usr/backup/publisher.tar.gz /home/*.pub

No files are found. What am I doing wrong?

"locate .pub" finds 100 files
Answer  
Subject: Re: HOWTO use tar to backup *.pub files
Answered By: leapinglizard-ga on 30 Nov 2004 00:34 PST
 
Dear schmerold,

Let me begin by noting that if you want to find all .pub files found
recursively under /home, you should use the following command.

  find /home -name "*.pub"

Because some of the returned filenames may contain spaces, you can't
feed them directly to the tar command. Instead, you should pipe them
into a temporary file whose name you subsequently pass to tar.

If you can write to the directory /usr/backup, execute

  find /home -name "*.pub" > /usr/backup/found.txt

followed by

  tar cvfz /usr/backup/publisher.tar.gz -T /usr/backup/found.txt

to achieve the desired effect.

You can enter both commands on a single line, if you insist, by
separating them with a semicolon. It would make an awfully long line,
though. There's no harm in separating the procedure into a pair of
lines.

If any part of my answer is unclear or incorrect, please let me know
with a Clarification Request so that I have the opportunity to fully
meet your needs before you assign a rating.

Regards,

leapinglizard
Comments  
Subject: Re: HOWTO use tar to backup *.pub files
From: powerspike-ga on 23 Nov 2004 20:34 PST
 
one of the easiest ways to do this would be 

tar czvf filename.tar.gz `locate .pub`
the `` will execute the command and pass the results into the command
line, which will effectively back all the .pub files for you on the
server.
Subject: Re: HOWTO use tar to backup *.pub files
From: schmerold-ga on 23 Nov 2004 22:11 PST
 
Close, but this solution needs something more. We get long list of
errors due to the spaces in the file names:
tar: Booklet.pub: Cannot stat: No such file or directory
tar: /home/data/PUBS/Publisher: Cannot stat: No such file or directory
tar: Files/Funeral: Cannot stat: No such file or directory
tar: Service: Cannot stat: No such file or directory
tar: Bulletins/deuschle1.pub: Cannot stat: No such file or directory
tar: /home/data/PUBS/Publisher: Cannot stat: No such file or directory
tar: Files/Funeral: Cannot stat: No such file or directory
tar: Service: Cannot stat: No such file or directory
tar: Bulletins/politsch.pub: Cannot stat: No such file or directory
tar: /home/data/PUBS/Publisher: Cannot stat: No such file or directory
tar: Files/Funeral: Cannot stat: No such file or directory
tar: Service: Cannot stat: No such file or directory
tar: Bulletins/Winter: Cannot stat: No such file or directory
tar: James.pub: Cannot stat: No such file or directory
tar: /home/data/PUBS/Publisher: Cannot stat: No such file or directory
tar: Files/Semi: Cannot stat: No such file or directory
tar: Annual: Cannot stat: No such file or directory
tar: Report/2004: Cannot stat: No such file or directory
tar: Semi: Cannot stat: No such file or directory
tar: Annual: Cannot stat: No such file or directory
tar: Report/Annual: Cannot stat: No such file or directory
tar: Report: Cannot stat: No such file or directory
tar: Sample.pub: Cannot stat: No such file or directory
tar: /home/data/PUBS/Publisher: Cannot stat: No such file or directory
tar: Files/Construction: Cannot stat: No such file or directory
tar: Campaign: Cannot stat: No such file or directory
tar: 2005/2004-2005: Cannot stat: No such file or directory
tar: Share: Cannot stat: No such file or directory
tar: the: Cannot stat: No such file or directory
tar: Vision: Cannot stat: No such file or directory
tar: Campaign/Share: Cannot stat: No such file or directory
tar: the: Cannot stat: No such file or directory
tar: Vision: Cannot stat: No such file or directory
tar: Pledge: Cannot stat: No such file or directory
tar: card.pub: Cannot stat: No such file or directory
tar: /home/PRIVATE/steenomc/WEDDING/wedding: Cannot stat: No such file or directory
tar: booklet.rev.june: Cannot stat: No such file or directory
tar: 2000.doc.pub: Cannot stat: No such file or directory
Subject: Re: HOWTO use tar to backup *.pub files
From: crythias-ga on 24 Nov 2004 09:03 PST
 
You have spaces in your filenames :).
http://www.cygwin.com/ml/cygwin/2004-06/msg00138.html might be a
solution, using xargs. or the -T option.

This is a free comment.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy