Skip to content

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 ​

FormatExtensionReadWritePassword SupportNotes
ZIP.zip✓✓NoFull read/write support
TAR.tar✓✓NoFull 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) ​

FormatExtensionsReadWriteCompression 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:

  1. File extension - Recognizes all standard extensions (.tar.gz, .zip, etc.)
  2. Magic bytes - Examines file headers when extension is ambiguous
  3. Explicit configuration - Override with format field when needed

Supported Operations ​

CommandDescription
extractUnpack an archive into a directory
createCreate an archive from files/folders
listEnumerate entries in an archive

Quick Start ​

yaml
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: package

extract 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 ​

FieldDescriptionTypeDefaultNotes
sourceInput archive or directorystringrequiredPath to archive file (extract/list) or source directory (create)
destinationOutput directory or archive pathstring. (extract)Target directory (extract) or output archive path (create); optional for list
formatArchive format overridestringauto-detectExplicit format: zip, tar, tar.gz, tar.bz2, tar.xz, tar.zst, 7z, rar, etc.
compression_levelCompression levelint-1-1 or 0 = default, 1-9 = level; applies to gzip and bzip2 only
overwriteReplace existing filesboolfalseWhen false, extraction fails if destination file exists
strip_componentsStrip leading path segmentsint0Remove N leading directories from paths (like tar --strip-components=N)
preserve_pathsPreserve full pathsbooltrueWhen false, only extracts the basename of each file
includeInclude glob patterns[]stringall filesOnly process files matching these patterns (e.g., **/*.csv)
excludeExclude glob patterns[]stringnoneSkip files matching these patterns (applied after include)
follow_symlinksFollow symlinks when creatingboolfalseWhen true, dereferences symlinks; when false, preserves them
verify_integrityVerify archive after operationboolfalsePerforms full read pass to validate archive integrity
continue_on_errorContinue on individual file errorsboolfalseLogs errors but continues processing remaining files
dry_runSimulate operationboolfalseCalculate metrics without writing files to disk
passwordArchive passwordstringnoneExtraction 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 ​

yaml
working_dir: /data/pipeline

steps:
  - id: extract_csv
    action: archive.extract
    with:
      source: dataset.tar.zst
      destination: ./data
      include:
        - "**/*.csv"
      strip_components: 1

Create Archive With Verification ​

yaml
working_dir: /deploy/release

steps:
  - id: bundle_artifacts
    action: archive.create
    with:
      source: ./dist
      destination: dist.tar.gz
      format: tar.gz
      verify_integrity: true

Extract Password-Protected 7z (Read-Only) ​

yaml
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: true

Important: Password protection is read-only. You can extract password-protected 7z and rar archives, 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 ​

FormatLimitation
RARRead-only; cannot create RAR archives
7-ZipRead-only; cannot create 7z archives
Password ProtectionExtraction only; cannot create encrypted archives
Compression LevelsOnly GZIP and Bzip2 support configurable levels (1-9)
Compressed single filesNot supported; use a TAR-based format

Output Format ​

Extract and Create Operations ​

Both extract and create commands output JSON to stdout with operation metrics:

json
{
  "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:

json
{
  "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
    }
  ]
}

Dagu is open source under the GNU General Public License v3.0.