Console commands

Everything the export screen does, from the command line — which is where you want a big export, and the only place you can schedule one.

Building a bundle

php craft archive/export
php craft archive/export --types=entries,assets --format=csv
php craft archive/export --sites=default,fr --sections=news --name=news-only
php craft archive/export --queue

With no options it uses the plugin defaults: every available content type, the default format, the primary site. It prints a running record count while it works, then the per-type totals, any warnings, and where it wrote the file.

Options

OptionDefaultWhat it does
--typesevery available typeComma-separated content types: entries, categories, tags, globals, assets, users, addresses.
--formatthe configured defaultjson, ndjson, xml, yaml or csv.
--sitesthe primary siteComma-separated site handles.
--sectionsevery sectionComma-separated section handles, narrowing which entries are collected.
--volumesevery volumeComma-separated volume handles, narrowing which assets are collected.
--namegeneratedBundle name without extension. Generated from the system name and time when omitted.
--includeDisabledfalseCollect disabled elements too.
--assetsthe configured defaultWhether files from local volumes are copied in.
--schemathe configured defaultWhether the site’s structure travels with the content.
--limitCap on elements collected per type. Useful for a trial run.
--queuefalseHand the export to Craft’s queue instead of running it now.

Pass an unknown type or format and the command lists the valid ones rather than guessing:

Available types:   entries, categories, tags, globals, assets, addresses
Available formats: json, ndjson, xml, yaml, csv

Note that users is absent from that list until user export is allowed in the settings.

Managing bundles

php craft archive/bundles                 # list them
php craft archive/bundles/prune           # apply the retention settings
php craft archive/bundles/delete 4        # delete one, by ID

The list shows ID, name, format, status, size and creation date, and flags any bundle whose file has gone missing from disk — which is how you spot a bundle directory that got cleaned out from underneath the ledger.

prune applies both retention settings and reports how many it removed. delete takes the ID from the list and removes the file along with the ledger row.

Scheduling

A rolling, platform-neutral snapshot of the site, kept to the retention settings:

# Sunday 03:00 — export everything as JSON, in the background
0 3 * * 0 cd /var/www/example.com && php craft archive/export --queue >> /dev/null 2>&1

# Sunday 04:00 — apply retention
0 4 * * 0 cd /var/www/example.com && php craft archive/bundles/prune >> /dev/null 2>&1

Drop --queue if the machine running cron has no queue worker — the command runs the export inline, and memory stays flat either way because records are spooled to disk rather than held.

Big exports

The console is the right place for these. There’s no request to time out, and PHP’s CLI has its own memory limit, usually a generous one. Two things worth knowing:

  • --limit=5 first. A five-record bundle in the target format tells you whether the receiving system can read it, in about a second.
  • batchSize in the settings controls how many elements are loaded at a time. Lower it on a memory-tight host.