Register
It is currently Wed Aug 20, 2014 6:39 am

Zip Ignore Errors?


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Tue May 17, 2011 9:56 am   

Joined: Tue May 17, 2011 9:50 am
Posts: 1
Hello all, I am trying to write a backup bash script that will just zip folders on my Red hat server.

Here is the script:

Code:
#!/bin/bash
cd /opt/backups/
myfilename="Site_$(date +%A-%m-%d-%y).zip"
zip -r "$myfilename" /opt/websites/thesite


The problem is that sometimes a file wont exist? Zip exits with an I/O error File Not Found. Perhaps a broken symnlink? Of course when the zip dies midway through a 1 gig backup then the rest of the backup doesn't finish.

Is there any way to make Zip ignore errors and just move on to the next file? Thanks for any help.

Other ideas: (Feel free to shoot them down)
Perhaps tar can do this?
Maybe copy the folder to another folder before zipping? That way only existing files would be copied.


Top
 Profile  
 PostPosted: Tue May 17, 2011 11:33 pm   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
If you try to zip a directory of a gigabyte on an active webserver where (temp/cache) files are being created and destroyed on the fly, you're bound to run into some 'missing files'.
I would suggest using tar: tar -zcf </backup/location/file.tgz> <foldername>
You will still get the errors, but tar doesn't mind and skip them.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP