Skip to main content

GravityKit\GravityMigrate\CLI\Migrate

Migrate Gravity Forms + GravityKit data (forms, entries, Views, and the pages that

embed them) from the command line: export a portable bundle, import one, inspect one, or reset stuck migration state.

Both export and import drive the same batch state machine the browser UI uses (the Export/Import AJAX route closures), run to completion synchronously. The AJAX die-on-error handlers are disabled under WP-CLI (see Import::set_error_environment()).

Since: 1.2.0

Source: src/CLI/Migrate.php:23

Details

  • Kind: class
  • Namespace: GravityKit\GravityMigrate\CLI
  • Extends: WP_CLI_Command

Methods

MethodDescription
export()Exports Gravity Forms + GravityKit data to a portable ZIP bundle.
import()Imports a GravityMigrate ZIP bundle into this site.
inspect()Inspects a bundle without importing: prints its forms, data types, and source URL,
status()Reports current migration state: whether an import lock is held (and whether
reset()Clears stuck migration state: temporary tables, extracted import files, and the

Method Reference

export()

public function export( $args, $assoc_args )

Exports Gravity Forms + GravityKit data to a portable ZIP bundle.

OPTIONS

--forms=<ids> : Comma-separated form IDs to export, or "all".

default: entries,views,posts

[--date-start=<Y-m-d>] : Only export entries created on or after this date.

[--date-end=<Y-m-d>] : Only export entries created on or before this date.

[--password=<password>] : Encrypt the ZIP (AES-256).

[--public-url=<url>] : Rewrite this site's origin to <url> in exported file-upload URLs, page content, and info.json (src_url/uploads_dir). Use it when exporting from a site whose stored URL is not reachable from the destination (e.g. a demo clone's internal host) so uploads download on import. The URL must be public and resolvable from the importing server.

[--output=<path>] : Copy the finished ZIP to this path (the export directory is auto-deleted after 3 hours).

[--porcelain] : Output only the resulting ZIP path.

[--format=<format>] : Summary format.

default: table options:

  • table
  • json

EXAMPLES

wp gk migrate export --forms=2 --data=entries,views,posts \
--public-url=https://gravityview--abc123.demo.gravitykit.com \
--output=/srv/bundles/abc123.zip --porcelain

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:80

import()

public function import( $args, $assoc_args )

Imports a GravityMigrate ZIP bundle into this site.

Imports are not resumable: a failed import prints the form IDs it committed before the failure, so you can remove them and re-run.

OPTIONS

<zip> : Path to the GravityMigrate export ZIP.

default: all

[--password=<password>] : ZIP password if it was encrypted.

[--skip-uploads] : Do not download entry file uploads.

[--download-timeout=<secs>] : Per-hop timeout for downloading a linked entry file upload. Overrides the gk/gravitymigrate/import/download-timeout filter (default 300 seconds).

[--max-download-bytes=<n>] : Maximum bytes accepted for a single downloaded entry file upload. Overrides the gk/gravitymigrate/import/max-download-bytes filter (default 100 MB).

[--max-dump-file-size=<n>] : Maximum allowed size, in bytes, of the bundle's SQL dump file. Overrides the gk/gravitymigrate/import/max-dump-file-size filter (default 500 MB).

[--format=<format>] : Summary format.

default: table options:

  • table
  • json

[--yes] : Skip the confirmation prompt (import writes into Gravity Forms tables).

[--porcelain] : Output only the newly-created form IDs, one per line, for scripting.

EXAMPLES

wp gk migrate import bundle.zip --user=admin --yes

wp gk migrate import bundle.zip --user=admin --yes --porcelain

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:222

inspect()

public function inspect( $args, $assoc_args )

Inspects a bundle without importing: prints its forms, data types, and source URL,

and whether its upload URLs will resolve from this site.

OPTIONS

<zip> : Path to the GravityMigrate export ZIP.

[--password=<password>] : ZIP password if encrypted.

[--format=<format>] : Output format.

default: table options:

  • table
  • json

EXAMPLES

wp gk migrate inspect bundle.zip

wp gk migrate inspect bundle.zip --format=json

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:374

status()

public function status( $args, $assoc_args )

Reports current migration state: whether an import lock is held (and whether

it's stale), whether a crashed import is saved for resume, and whether an export has state left over to clean up.

[--format=<format>] : Output format.

default: table options:

  • table
  • json

EXAMPLES

wp gk migrate status
wp gk migrate status --format=json

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:448

reset()

public function reset( $args, $assoc_args )

Clears stuck migration state: temporary tables, extracted import files, and the

import/export progress options.

OPTIONS

[--yes] : Skip the confirmation prompt.

EXAMPLES

wp gk migrate reset --yes

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:489