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:
-t7znumber
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:
p0- If in both: ignore (no update)q0- If in archive only: ignore (keep in archive)r2- If on disk only: add from diskx1- If archive is newer: keep archive versiony2- If disk is newer: update from diskz1- If same age: keep archive version
Examples
Basic update (newer files only)
Update with maximum compression
Update specific files
Update all text files
Synchronize archive with directory
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 diskr2- Add new files from diskx2- 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 filesy2- Update with newer files from disk
Add New Files Only
Add files not in archive, don’t update existing:p0- Ignore files in bothr2- Add files only on disk
Complex Examples
Update with 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
- Use update instead of recreating - Much faster for large archives
- Enable multi-threading - Add
-mmt=onfor faster compression - Adjust compression level - Use
-mx=1for faster updates - Use solid archives carefully - Solid mode requires recompression
- 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.Related Commands
- Add Command (a) - Create or add to archives
- Delete Command (d) - Remove files from archives
- List Command (l) - View archive contents