The extract command extracts files from an APACK archive to a specified directory.
apack extract [OPTIONS] <archive>
apack x [OPTIONS] <archive>
Arguments:
<archive>- Path to the archive file to extract
| Option | Description | Default |
|---|---|---|
-o, --output <dir> |
Output directory | Current directory |
-p, --password <pwd> |
Decryption password | Interactive prompt |
--overwrite |
Overwrite existing files | false |
-v, --verbose |
Show each file as extracted | false |
--dry-run |
Preview extraction without writing | false |
# Extract to current directory
apack extract archive.apack
# Extract to specific directory
apack extract -o ./output/ archive.apack
# Using alias
apack x archive.apack -o ./extracted/# Interactive password prompt
apack extract archive.apack -o ./output/
# Password on command line (use with caution)
apack extract -p mypassword archive.apack -o ./output/# Default: skip existing files with warning
apack extract archive.apack -o ./output/
# Overwrite existing files
apack extract --overwrite archive.apack -o ./output/apack extract -v archive.apack -o ./output/Output:
Extracting: src/main.java (2.3 KB)
Extracting: src/util/Helper.java (1.1 KB)
Extracting: README.md (512 B)
Extracted 3 file(s), 3.9 KB
apack extract --dry-run archive.apackOutput:
Would extract: src/main.java (2.3 KB)
Would extract: src/util/Helper.java (1.1 KB)
Would extract: README.md (512 B)
Would extract 3 file(s), 3.9 KB
When extracting an encrypted archive without -p:
Enter password: ********
The password is read securely (not echoed) when a console is available.
apack extract -p "mypassword" archive.apackSecurity Warning: Command-line passwords are visible in:
- Process listings (
ps) - Shell history
- System logs
Use interactive prompts for sensitive data.
Error: Failed to derive decryption key (wrong password?)
The decryption will fail if the password doesn't match. The archive is not modified.
Parent directories are created automatically:
Archive contents:
data/config/settings.json
data/logs/app.log
Extraction creates:
./output/data/config/settings.json
./output/data/logs/app.log
If the output directory doesn't exist, it's created:
# Creates ./new-folder/ if it doesn't exist
apack extract -o ./new-folder/ archive.apackWithout --overwrite, existing files are skipped:
Warning: Skipping existing file: ./output/config.json
With --overwrite, existing files are replaced:
apack extract --overwrite archive.apack -o ./output/The extract command automatically detects the compression algorithm used:
- Scans entry headers for compression IDs
- Loads the appropriate decompression provider
- Decompresses data transparently
Supported algorithms:
- ZSTD (ID: 1)
- LZ4 (ID: 2)
The extract command detects encryption from the file header:
- Checks the file header encryption flag
- Reads the encryption block for KDF parameters
- Prompts for password if needed
- Derives the decryption key using Argon2id or PBKDF2
- Unwraps the content encryption key
- Decrypts data transparently
Supported algorithms:
- AES-256-GCM (ID: 1)
- ChaCha20-Poly1305 (ID: 2)
Supported KDFs:
- Argon2id (ID: 1)
- PBKDF2-SHA256 (ID: 2)
| Error | Cause | Solution |
|---|---|---|
| "Archive not found" | File doesn't exist | Check the path |
| "Password required for encrypted archive" | No password provided | Use -p or interactive prompt |
| "Failed to derive decryption key" | Wrong password | Re-enter correct password |
| "Skipping existing file" | File exists | Use --overwrite or delete file |
| "Archive is encrypted but encryption metadata is missing" | Old archive format | Original key required |
Archives created before encryption block support cannot be decrypted with a password:
Error: Archive is encrypted but encryption metadata is missing.
This archive may have been created before encryption block support was added.
Such archives cannot be decrypted with a password - the original key is required.
Extracted 42 file(s), 15.2 MB
Would extract 42 file(s), 15.2 MB
Warning: Skipping existing file: ./output/config.json
Warning: Skipping existing file: ./output/data.bin
Extracted 40 file(s), 14.8 MB
| Code | Meaning |
|---|---|
0 |
Success (all files extracted) |
1 |
Error (password error, I/O error) |
-
Always verify first:
apack verify archive.apack apack extract archive.apack -o ./output/
-
Use dry-run for preview:
apack extract --dry-run archive.apack
-
Secure password handling:
- Use interactive prompts
- Avoid
-pon shared systems
-
Check disk space:
- Use
apack infoto see original sizes - Ensure sufficient space in output directory
- Use
-
Backup before overwrite:
# Instead of overwriting directly apack extract archive.apack -o ./new-output/ # Then compare and merge as needed
Next: List Command | Previous: Create Command