Is it possible to zip changed files into a separate archive with only the changed files
Yes, it's possible to do this and there's a zip
command switch specially designed for that purpose. I'll show you by way of an example, and then you can adapt it to your own purposes.
I first created a zip archive of my script folder with the following command (working from my home folder):
zip -r Scripts.zip Scripts
Now this had 76 items. I then added some 2 pdfs to the Scripts folder on disk and then ran the following command, and transferred just the new and changed files to a new zipfile:
zip -r Scripts.zip Scripts -DF --out new.zip
This was the output:
updating: Scripts/ (stored 0%)
adding: Scripts/GIMP+Magazine+Issue+1.pdf (deflated 2%)
adding: Scripts/Whitepaper-CentralisedLogging-v1.pdf (deflated 10%)
Now only these 2 new files are in new.zip
, and they have not been added to the original zip. In the command, the -DF
option allowed us to create a 'difference archive' specified with the --out
switch, so that any new files present in the folder on disk, but not in the original zip, go to the new zip. So according to the man page, it is indeed possible to
create an archive that contains all new and changed files since the original archive was created. For this to work, the input file list and current directory must be the same as during the original zip operation.
There are some interesting options to play around with for zip, so please see man zip
or the Ubuntu manpages online.