Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In the command line, 7zip has the command 'a' to "Add files to archive". But I want to sync the files instead. This is one of the main options in the GUI, but the CLI has disregarded it for some reason.

How can I do this? Example appreciated.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Using some info I found online, I figured out that -uq0 is the switch you probably want. Here's an example of an update script I just tested out based on this:

"C:\Program Files\7-Zip\7z.exe" u "C:\Users\dane\Documents\Docz.7z" -uq0 "C:\Users\dane\Documents\*" -r -x!*.7z -ssw -ms=off

I tested this out and it removed a file from the archive after I deleted the file.

share|improve this answer
    
Ah that did the trick! I previously saw that page, but next to "Synchronize", it says set p to 1, q to 0, r to 2, x to 1 etc. etc. (i.e. "-u-p1q0r2x1y2z1w2" - which I tried and it didn't work). I'm not sure how you interpreted the seemingly cryptic description so well. –  Dan W Jan 4 '13 at 21:09
    
Actually, you had it right, except you inserted an extra dash in "-u-p1q0r2x1y2z1w2". If you had just used "-up1q0r2x1y2z1w2" instead, you would've been good, I believe. That dash in "-u-" apparently disables updates to the base archive, which would totally negate my example line if included. My example of "u -uq0" is identical to "u -up1q0r2x1y2z1w2", because only the "q0" is different from what "u" usually does. –  Dane Jan 4 '13 at 21:16
    
Great that explains it all, and makes perfect sense. Thanks a lot! –  Dan W Jan 4 '13 at 21:32

Use the 'u' operator (update)

Slightly edited snippit from a backup job I run:

7z.exe u Documents.7z ".\Documents\*" -r -x!*.7z -x!*.pst -t7z -ssw -mx=3 -m3=LZMA2 -mmt=2 
share|improve this answer
    
Simply using 'u' doesn't sync, as files which are in the archive which aren't in the original files/folder anymore aren't deleted. –  Dan W Jan 4 '13 at 18:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.