Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zip command skip errors

zip -r file.zip folder/

This is the typical command I use to zip a directory, however it is on an active site so images are constantly deleted/updated. Leading to the command failing due to a file being there when it started the process but not there when it gets to actually compressing it (at least from what I can see).

I have no option to stop the editing of the files in this case so my only hope is to just skip them, the amount of images getting edited compared to the sheer size of the directory is insigificant. so 2-3 files changing out of 100,000 is nothing, but the error stops the compression altogether.

I tried to look for a way around this, but have had no luck, could be just looking in the wrong direction but I feel that there is no way this is impossible.

Here is an example error:

zip I/O error: No such file or directory

zip error: Input file read failure (was zipping uploads/2010/03/file.jpg)

Is there some way to use the zip command or something similar to zip a folder, but if it runs into an error when it hits a file, it just skips it?

like image 827
Jordan Ramstad Avatar asked Aug 28 '14 19:08

Jordan Ramstad


1 Answers

tar is always a good option to compress in Linux. Beware that zip may also have file size limit issue.

tar vcfz file.tar.gz folder
like image 185
Wenbing Li Avatar answered Oct 13 '22 21:10

Wenbing Li