Skip to main content
The u (update) command updates files in archives with fine-grained control over which files are updated, added, or refreshed based on timestamps and existence.

Syntax

Description

The update command provides sophisticated archive maintenance by:
  • Updating existing files with newer versions
  • Adding new files not in the archive
  • Skipping files that haven’t changed
  • Supporting complex update modes
  • Preserving archive structure and metadata
The main difference between a (add) and u (update): the a command always adds/updates files, while u compares timestamps and only updates newer files by default.

Common Options

string
required
Name of the archive to update. Must already exist.
string
Files or directories to update. Supports wildcards.
string
Set update action mode. Controls behavior for different file states.Format: -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]See Update Modes below.
string
Set archive type.Example: -t7z
number
Set compression level (0-9).
string
Set password for encrypted archives.
flag
Recurse subdirectories.
string
Exclude files by pattern.
string
Include files by pattern.
string
Set working directory.

Update Modes

The -u switch controls update behavior with a complex but powerful syntax:

State Codes

Each letter represents a file state:

Action Numbers

Each state can have an action:

Default Update Mode

Without -u, the update command uses:
Meaning:
  • p0 - If in both: ignore (no update)
  • q0 - If in archive only: ignore (keep in archive)
  • r2 - If on disk only: add from disk
  • x1 - If archive is newer: keep archive version
  • y2 - If disk is newer: update from disk
  • z1 - If same age: keep archive version

Examples

Basic update (newer files only)

Output:

Update with maximum compression

Update specific files

Update all text files

Synchronize archive with directory

This creates sync.7z that exactly matches the files/ directory.

Update and delete removed files

Advanced Update Modes

Synchronization Mode

Create an archive that exactly mirrors a directory:
  • q0 - Remove files deleted from disk
  • r2 - Add new files from disk
  • x2 - Use newer file (from disk if disk is newer)
  • y2 - Use newer file (from disk if disk is newer)
  • z0 - When same, ignore (keeps archive version)

Incremental Backup

Update only changed files:

Freshen Existing Files

Update only files that already exist in archive:
  • r0 - Don’t add new files
  • y2 - Update with newer files from disk

Add New Files Only

Add files not in archive, don’t update existing:
  • p0 - Ignore files in both
  • r2 - Add files only on disk

Complex Examples

Update with password

Prompts for password:

Update excluding patterns

Update with new compression method

Update and show differences

Conditional update based on size

Update multiple archives

Update vs Add Command

When to Use Update

  • Incremental backups - Only backup changed files
  • Syncing archives - Keep archive matching directory
  • Efficiency - Skip unchanged files to save time
  • Selective updates - Complex update logic needed

When to Use Add

  • Creating archives - New archive from scratch
  • Full refresh - Rebuild entire archive
  • Simplicity - Don’t need timestamp checking
  • Force update - Update all files regardless of timestamp

Scripting Examples

Daily Incremental Backup

Smart Update Script

Synchronize Directory to Archive

Performance Tips

  1. Use update instead of recreating - Much faster for large archives
  2. Enable multi-threading - Add -mmt=on for faster compression
  3. Adjust compression level - Use -mx=1 for faster updates
  4. Use solid archives carefully - Solid mode requires recompression
  5. Skip unchanged files - Default behavior saves significant time
For solid archives (-ms=on), updating files requires recompressing the entire solid block, which can be slow. Non-solid archives allow updating individual files independently.
The update command requires the archive to already exist. Use the a (add) command to create a new archive.
To see which files would be updated without actually updating:
Check the log before running the actual update.