Skip to content

targets add

Add a new database target.

clonit targets add --src-url <url> [flags]
Flag Type Default Description Required
--name string (derived from src-url) Target name No
--db-type string postgres Database type (postgres, mysql) No
--src-url string Source database URL Yes
--dst-url string Destination database URL No
--sanitize-dst-url string Sanitize destination database URL No
--sanitize-query-file string Path to sanitization SQL query file No
--storage-profile string Storage profile name No
--dump-jobs int 0 Number of parallel dump jobs (0 = use default) No
--restore-jobs int 0 Number of parallel restore jobs (0 = use default) No
--src-schema-include string[] Schemas to include in dump (glob patterns) No
--src-schema-exclude string[] Schemas to exclude from dump (glob patterns) No
--dst-schema-include string[] Schemas to include in restore (glob patterns) No
--dst-schema-exclude string[] Schemas to exclude from restore (glob patterns) No
--no-verify bool false Skip URL connectivity verification No
--read-only bool false Mark target as read-only No

Creates a new database target with the specified configuration. At minimum, a source database URL is required. If --name is omitted, the target name is derived from the database name in the source URL.

By default, the command verifies connectivity to all provided database URLs before saving the target. Use --no-verify to skip this check.

Add a target with minimal configuration (name derived from database name):

clonit targets add --src-url "postgresql://user:pass@localhost:5432/mydb"

Add a target with all options:

clonit targets add \
--name production-snap \
--db-type postgres \
--src-url "postgresql://user:pass@prod-host:5432/appdb" \
--dst-url "postgresql://user:pass@localhost:5432/appdb_restore" \
--sanitize-dst-url "postgresql://user:pass@localhost:5432/appdb_sanitize" \
--sanitize-query-file /path/to/sanitize.sql \
--storage-profile my-s3 \
--dump-jobs 4 \
--restore-jobs 4

Add a target with schema filtering (include only public and tenant_* schemas):

clonit targets add \
--src-url "postgresql://user:pass@prod-host:5432/appdb" \
--src-schema-include public,tenant_*

Exclude temporary schemas from dump:

clonit targets add \
--src-url "postgresql://user:pass@prod-host:5432/appdb" \
--src-schema-exclude temp_*,pg_temp_*

Add a target without verifying connectivity:

clonit targets add \
--src-url "postgresql://user:pass@remote-host:5432/mydb" \
--no-verify

Schema filter flags accept comma-separated glob patterns. These control which PostgreSQL schemas are included or excluded during dump and restore operations.

  • --src-schema-include / --src-schema-exclude apply to pg_dump (build)
  • --dst-schema-include / --dst-schema-exclude apply to pg_restore (load)

Include and exclude are mutually exclusive for the same direction (src or dst). If both are set, include takes precedence.

Glob patterns support * as a wildcard. For example, tenant_* matches tenant_1, tenant_abc, etc.