Archive
Work with archive files directly from a DAG step without relying on shell utilities. The executor uses github.com/mholt/archives and streams data for efficiency.
Supported Formats
Archive Formats
| Format | Extension | Read | Write | Password Support | Notes |
|---|---|---|---|---|---|
| ZIP | .zip | ✓ | ✓ | No | Full read/write support |
| TAR | .tar | ✓ | ✓ | No | Full read/write support |
| RAR | .rar | ✓ | ✗ | Yes (read) | Read-only; extraction with password |
| 7-Zip | .7z | ✓ | ✗ | Yes (read) | Read-only; extraction with password |
Compressed Single Files
Standalone compressed files (.gz, .bz2, .xz, .zst, .lz4) are not supported. create and extract fail, and list returns no entries. Use these compressions through the TAR formats below.
Combined Formats (Archive + Compression)
| Format | Extensions | Read | Write | Compression Level |
|---|---|---|---|---|
| TAR+GZIP | .tar.gz, .tgz | ✓ | ✓ | 1-9 (default: -1) |
| TAR+Bzip2 | .tar.bz2, .tbz2, .tbz | ✓ | ✓ | 1-9 (default: -1) |
| TAR+XZ | .tar.xz, .txz | ✓ | ✓ | Fixed |
| TAR+Zstandard | .tar.zst, .tar.zstd | ✓ | ✓ | Fixed |
Format Detection
The executor automatically detects archive format from:
- File extension - Recognizes all standard extensions (
.tar.gz,.zip, etc.) - Magic bytes - Examines file headers when extension is ambiguous
- Explicit configuration - Override with
formatfield when needed
Supported Operations
| Command | Description |
|---|---|
extract | Unpack an archive into a directory |
create | Create an archive from files/folders |
list | Enumerate entries in an archive |
Quick Start
steps:
- id: unpack
action: archive.extract
with:
source: logs.tar.gz
destination: ./logs
- id: package
action: archive.create
with:
source: ./logs
destination: logs-backup.tar.gz
depends: unpack
- id: inspect
action: archive.list
with:
source: logs-backup.tar.gz
output: ARCHIVE_INDEX
depends: packageextract and create emit a JSON summary (files processed, bytes, duration, etc.) on stdout. list outputs a JSON object whose files array lists the entries, so subsequent steps can filter or inspect the archive with tools like jq.
Configuration
| Field | Description | Type | Default | Notes |
|---|---|---|---|---|
source | Input archive or directory | string | required | Path to archive file (extract/list) or source directory (create) |
destination | Output directory or archive path | string | . (extract) | Target directory (extract) or output archive path (create); optional for list |
format | Archive format override | string | auto-detect | Explicit format: zip, tar, tar.gz, tar.bz2, tar.xz, tar.zst, 7z, rar, etc. |
compression_level | Compression level | int | -1 | -1 or 0 = default, 1-9 = level; applies to gzip and bzip2 only |
overwrite | Replace existing files | bool | false | When false, extraction fails if destination file exists |
strip_components | Strip leading path segments | int | 0 | Remove N leading directories from paths (like tar --strip-components=N) |
preserve_paths | Preserve full paths | bool | true | When false, only extracts the basename of each file |
include | Include glob patterns | []string | all files | Only process files matching these patterns (e.g., **/*.csv) |
exclude | Exclude glob patterns | []string | none | Skip files matching these patterns (applied after include) |
follow_symlinks | Follow symlinks when creating | bool | false | When true, dereferences symlinks; when false, preserves them |
verify_integrity | Verify archive after operation | bool | false | Performs full read pass to validate archive integrity |
continue_on_error | Continue on individual file errors | bool | false | Logs errors but continues processing remaining files |
dry_run | Simulate operation | bool | false | Calculate metrics without writing files to disk |
password | Archive password | string | none | Extraction only for password-protected 7z and rar archives |
All fields support scoped value references such as ${env.NAME}, ${params.name}, and ${steps.step_id.outputs.name}.
On Dagu v2.25.3 or later, a relative source or destination resolves from the step working directory, and extract without a destination extracts there. Outputs keep the paths as written.
Additional Examples
Selective Extraction
working_dir: /data/pipeline
steps:
- id: extract_csv
action: archive.extract
with:
source: dataset.tar.zst
destination: ./data
include:
- "**/*.csv"
strip_components: 1Create Archive With Verification
working_dir: /deploy/release
steps:
- id: bundle_artifacts
action: archive.create
with:
source: ./dist
destination: dist.tar.gz
format: tar.gz
verify_integrity: trueExtract Password-Protected 7z (Read-Only)
working_dir: /data/decrypted
secrets:
- name: ARCHIVE_PASSWORD
provider: env
key: ARCHIVE_PASSWORD
steps:
- id: unpack_secure
action: archive.extract
with:
source: secure-data.7z
destination: ./decrypted
password: ${env.ARCHIVE_PASSWORD}
include:
- "**/*.csv"
overwrite: trueImportant: Password protection is read-only. You can extract password-protected
7zandrararchives, but creating encrypted archives is not supported.
Security Features
The executor protects against malicious archives:
- Path traversal prevention - Rejects archives with entries escaping the destination directory
- Symlink validation - Blocks symlinks with absolute targets or paths escaping the destination
- Safe path handling - Validates all extracted paths before writing files
These protections defend against "zip slip" and similar archive-based attacks.
Limitations
| Format | Limitation |
|---|---|
| RAR | Read-only; cannot create RAR archives |
| 7-Zip | Read-only; cannot create 7z archives |
| Password Protection | Extraction only; cannot create encrypted archives |
| Compression Levels | Only GZIP and Bzip2 support configurable levels (1-9) |
| Compressed single files | Not supported; use a TAR-based format |
Output Format
Extract and Create Operations
Both extract and create commands output JSON to stdout with operation metrics:
{
"operation": "extract",
"source": "logs.tar.gz",
"destination": "./logs",
"filesExtracted": 1523,
"bytesExtracted": 45829384,
"filesSkipped": 0,
"duration": "1.234s",
"verifyPerformed": false,
"errors": []
}List Operation
The list command outputs a JSON object with the archive entries in files:
{
"operation": "list",
"source": "logs.tar.gz",
"totalFiles": 1523,
"totalSize": 45829384,
"verified": false,
"duration": "0.123s",
"files": [
{
"path": "logs/app.log",
"size": 12345,
"mode": "-rw-r--r--",
"modTime": "2025-11-02T12:34:56Z",
"isDir": false
}
]
}
