Skip to content

Archive ​

The archive actions create, extract, and list archive files inside a step. They do not need tar, zip, or unzip on the host, and they print a JSON summary to stdout.

Use them instead of shell archive commands in run: steps. To keep files from a run for download in the Web UI, use Artifact.

ActionDoesRequired fields
archive.createPack a file or directory into an archivesource, destination
archive.extractUnpack an archive into a directorysource
archive.listReport the entries of an archivesource

Basic Usage ​

yaml
working_dir: .

steps:
  - id: pack
    action: archive.create
    with:
      source: ./reports
      destination: ./out/reports.tar.gz

  - id: unpack
    depends: pack
    action: archive.extract
    with:
      source: ./out/reports.tar.gz
      destination: ./restore

pack stores the directory as reports/... inside reports.tar.gz and prints:

json
{
  "operation": "create",
  "source": "./reports",
  "destination": "./out/reports.tar.gz",
  "filesAdded": 4,
  "bytesArchived": 244,
  "duration": "33.466666ms",
  "verifyPerformed": false
}

unpack recreates restore/reports/.... Relative paths resolve against the step working directory, which is a fresh per-run directory unless working_dir is set, and missing parent directories of destination are created.

Create an Archive ​

The format comes from format when set, otherwise from the destination extension. format wins even when the extension disagrees.

yaml
working_dir: .

steps:
  - id: bundle
    action: archive.create
    with:
      source: ./dist
      destination: ./release/dist.tgz
      exclude:
        - "**/*.map"
      compression_level: 9
      verify_integrity: true
  • A directory source is stored under its own name, such as dist/app.js. A source of . stores the directory's contents at the archive root.
  • include and exclude match the path stored in the archive, such as dist/assets/app.js.
  • compression_level applies to gzip and bzip2 only, from 1 to 9.
  • verify_integrity reads the new archive back once and fails the step if it cannot be read.
  • Symbolic links are stored as links. follow_symlinks: true stores the files they point to.

Extract an Archive ​

The format is detected from the file content and name. Set format to skip detection.

yaml
working_dir: .

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

strip_components removes leading directories from each entry; preserve_paths: false keeps only the file name:

text
Archive entry              strip_components: 1    preserve_paths: false
export/2026/jan.csv   ->   2026/jan.csv           jan.csv
export/readme.txt     ->   readme.txt             readme.txt
  • Without destination, files go to the step working directory.
  • Without overwrite: true, the step fails when a file it would write already exists.
  • include and exclude match the path after strip_components and preserve_paths apply. Skipped entries are counted in filesSkipped.
  • continue_on_error: true records a failing entry in errors, writes a warning to stderr, and continues with the next entry.

Path Safety ​

An entry whose path would land outside destination, such as ../escape.txt, fails the step with escapes destination. Symbolic links are checked the same way: an absolute link target, or one that leads outside destination through links in the archive or already on disk, fails the step. Links that stay inside destination are extracted. Entries written before the failure are not rolled back.

Password-Protected Archives ​

password opens encrypted 7z and RAR archives for archive.extract and archive.list. It is ignored for zip and tar formats, and archive.create with a password fails. Creating encrypted archives is not supported.

yaml
working_dir: .

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}

List an Archive ​

archive.list reads the archive without extracting it. include and exclude filter the entries it reports.

yaml
working_dir: .

steps:
  - id: inspect
    action: archive.list
    with:
      source: ./out/reports.tar.gz
      include:
        - "**/*.csv"
    output:
      csv_count:
        from: stdout
        decode: json
        select: .totalFiles

  - id: report
    run: echo "CSV files in archive ${steps.inspect.outputs.csv_count}"
json
{
  "operation": "list",
  "source": "./out/reports.tar.gz",
  "totalFiles": 1,
  "totalSize": 14,
  "files": [
    {
      "path": "reports/2026/jan.csv",
      "size": 14,
      "mode": "-rw-r--r--",
      "modTime": "2026-12-04T06:34:00Z",
      "isDir": false
    }
  ],
  "verified": false,
  "duration": "735.958µs"
}

The object form of output publishes fields of this JSON as named outputs.

Formats ​

FormatNames and extensionsCreateExtract and list
ZIPzipYesYes
TARtarYesYes
TAR + gziptar.gz, tgzYesYes
TAR + bzip2tar.bz2, tbz2, tbzYesYes
TAR + xztar.xz, txzYesYes
TAR + Zstandardtar.zst, tar.zstdYesYes
7-Zip7zNoYes, with password
RARrarNoYes, with password

Single compressed files (.gz, .bz2, .xz, .zst, .lz4) are not archives: create and extract fail on them. Use a TAR-based format.

Configuration ​

FieldActionsRequiredDefaultDescription
sourceAllYesArchive to read, or file or directory to pack.
destinationcreate, extractFor createWorking directory (extract)Archive to write, or directory to extract into.
formatAllNoDetectedFormat name from Formats.
compression_levelcreateNo-11 to 9 for gzip and bzip2. -1 or 0 uses the library default.
includeAllNoAll entriesGlob patterns (** crosses directories). An entry must match one.
excludeAllNoNoneGlob patterns. A matching entry is skipped, even when included.
overwriteextractNofalseReplace existing files.
strip_componentsextractNo0Leading path segments to remove. Zero or greater.
preserve_pathsextractNotruefalse writes every file at the top of destination.
follow_symlinkscreateNofalseStore link targets instead of links.
verify_integrityAllNofalseRead the whole archive once and fail if it is unreadable.
continue_on_errorextractNofalseRecord per-entry errors and continue.
dry_runcreate, extractNofalseCount what would be written without writing archive or file contents.
passwordextract, listNoNonePassword for 7z and RAR archives.
verboseAllNofalseAccepted; has no effect.

Every field accepts references such as ${params.name} and ${steps.id.outputs.name}.

Output ​

Each action prints one JSON object to stdout:

ActionFields
createoperation, source, destination, filesAdded, bytesArchived, duration, verifyPerformed, errors
extractoperation, source, destination, filesExtracted, bytesExtracted, filesSkipped, duration, verifyPerformed, errors
listoperation, source, totalFiles, totalSize, files, verified, duration

source and destination are printed as written in the step. errors appears only when continue_on_error recorded one. filesAdded counts directory entries as well as files.

Errors ​

Validation rejects a missing source, a negative strip_components, and unknown fields. A misspelled field gets a suggestion, such as did you mean "overwrite".

These fail when the step runs:

  • archive.create without destination (unless dry_run), or with password.
  • archive.create whose format cannot be inferred: could not infer format; specify config.format.
  • A source that does not exist: source not found.
  • An existing file without overwrite: exists (overwrite disabled).

The exit code tells the failure class, so continue_on.exit_code can act on it:

Exit codeFailure
2Invalid configuration found at run time, such as an archive.extract source that is a directory
3Source not found
4Destination error, such as an existing file without overwrite
5Format not detected or not supported
6Extraction failed, including an entry that escapes destination
7Creation failed
10Permission denied
12Archive unreadable during verify_integrity
14Cancelled
1Any other failure

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