tags:

views:

19

answers:

1

I am rsync'ing a a folder from one host to another, I am then zipping the mirrored folder so that it can be transferred to tape.

Now, when I zip the folder (bearing in mind that the folder is ~300GB) using the below script it keeps the files which have been deleted from the directory that I am zipping.

zip -ru /home/rsync/www.zip /home/rsync/www/

This is because I'm using the u - update flag, which won't remove missing files from the archive.

In rsync I use the flag --delete, which removes files which no longer exist on the remote server. Is there a similar way of doing this with a zip archive?

+2  A: 

I don't know of any option to do that. Here is a simple script you could use as a basis for something more robust:

unzip -lqq archive | cut -c 31- | while read -r line; do if [[ ! -f $line ]]; then zip -d archive "$line"; fi; done
Dennis Williamson