Skip navigation

So recently I wanted a way to backup a specific folder to a compressed archive. I also wanted to be able to continue to backup only the files that have been changed or added to that directory. Looks like the 7Zip Command Line Tool is just what I needed.

Step 1: Create the archive. It’s important that the archive be created with solid mode disabled. This means that the files will not be combined before they are compressed. This will make the compression weaker, but if you want to do differential backups you need to turn this off. Here is the command I used to compression the folder initially.

7za a c:\archive.7z c:\folder_to_archive -ms=off

Step 2: Add to the archive. This next command will update the archive and add files that have changed. It will also delete files that have been deleted.

Here is the command to update the archive:

7za u c:\archive.7z c:\folder_to_archive -ms=off -mx=9 -t7z -up0q3r2x2y2z0w2

The long string after the -u tells the program what to do with specific cases of files:

The letters:

p – File exists in archive, but is not matched with wildcard.

q – File exists in archive, but doesn’t exist on disk.

r – File doesn’t exist in archive, but exists on disk.

x – File in archive is newer than the file on disk.

y – File in archive is older than the file on disk.

z – File in archive is same as the file on disk

w – Can not be detected what file is newer (times are the same, sizes are different)

The numbers:


0 Ignore file (don't create item in new archive for this file)

1 Copy file (copy from old archive to new)

2 Compress (compress file from disk to new archive)

3 Create Anti-item (item that will delete file or directory during extracting). This feature is supported only in 7z format

From here you could write a small bat file that runs the update command and then schedule it if you want it to happen on a regular basis

Leave a Reply