Cleaning and cloning with the CLI tool
There are some useful commands available to allow you to clean a hub or clone content items, schemas, content types and settings from one hub to another. In this section we'll explain how to use these commands and the most common options.
To explore what can be done with dc-cli hub, add --help
to the end of the dc-cli hub
command as shown below:
dc-cli hub --help
dc-cli hub
Hub
Commands:
dc-cli hub clean Cleans an entire hub. This will archive all content
items, types and schemas. Note that these are not
fully deleted, but they can be resurrected by a future
import.
dc-cli hub clone <dir> Clone an entire hub. The active account and hub are
the source for the copy. Exported data from the source
hub will be placed in the specified folder.
Options:
--version Show version number [boolean]
--clientId [string] [required]
--clientSecret [string] [required]
--hubId [string] [required]
--config Path to JSON config file
--help Show help [boolean]
Cleaning an entire hubLink copied!
To clean an entire hub, use the dc-cli hub clean
command.
This action does not permanently delete all content items, types and schemas in a hub but instead moves them to the archive. You can unarchive them later if you choose.
You need to specify the destination hubId of the specific hub you would like to clean either on the command line or in the configuration file.
dc-cli hub clean
To start at a specific step use the --step
option. You can specify "content", "type" or "schema".
dc-cli hub clean --step content
To explore what else can be done with dc-cli hub clean function, add --help
to the end of the dc-cli hub clean
command, as shown below:
Cleans an entire hub. This will archive all content items, types and schemas.
Note that these are not fully deleted, but they can be resurrected by a future
import.
Options:
--version Show version number [boolean]
--help Show help [boolean]
--clientId [string] [required]
--clientSecret [string] [required]
--hubId [string] [required]
--config Path to JSON config file
[string] [default: "/Users/kojogbede/.amplience/dc-cli-config.json"]
-f, --force Overwrite content, create and assign content types, and ignore
content with missing types/references without asking.[boolean]
--logFile Path to a log file to write to.
[string] [default: (generated-value)]
--step Start at a specific step. Steps after the one you specify will
also run. [string] [choices: "content", "type", "schema"]
Cloning an entire hubLink copied!
Cloning allows you to copy all content from one hub to another with a single command. Unlike copy, which allows you to go through each of the steps, clone automatically performs all the steps for you to take everything from one location to another. The steps involved in this process are:
- Clone Extensions
- Clone Content Type Schemas
- Clone Content Types
- Clone Indexes
- Clone Content
- Clone Events
- Clone Settings
To clone an entire hub from scratch, you need the following information and credentials:
- The directory for where you would like to store the clone locally
- The clientId of your source hub
- The clientSecret of your source hub
- The hubId of your source hub
- The clientId of your destination hub
- The clientSecret of your destination hub
- The hubId of your destination hub
Once you have all these in hand, you can build a clone command using the following format (replace the asterisks with your credentials):
dc-cli hub clone ./yourDirectory --clientId ***** --clientSecret ***** --hubId ***** --dstHubId ***** --dstClientId ***** --dstSecret *****
After running your command, you should receive an output similar to the one shown below if all your content is valid:
=== Running Step 1 - Clone Extensions ===
Exporting existing extensions from destination.
No extensions to export from this hub, exiting.
Exporting extensions from source.
No extensions to export from this hub, exiting.
No extensions found in kojogbede/export/extension
=== Running Step 2 - Clone Content Type Schemas ===
+--------------------------------+--------------------------------+------------------------------------------------------------------------------------------------------+------------+
| File | Schema file | Schema ID | Result |
|--------------------------------|--------------------------------|------------------------------------------------------------------------------------------------------|------------|
| /Users/kojogbede/kojogbede/exp | | https://schema-examples.com/blog-post-filter | UP-TO-DATE |
| ort/schema/blog-post-filter.js | | | |
| on | | | |
|--------------------------------|--------------------------------|------------------------------------------------------------------------------------------------------|------------|
| /Users/kojogbede/kojogbede/exp | | https://schema-examples.com/example-text | UP-TO-DATE |
| ort/schema/example-text.json | | | |
|--------------------------------|--------------------------------|------------------------------------------------------------------------------------------------------|------------|
| /Users/kojogbede/kojogbede/exp | | https://schema-examples.com/example-image | UP-TO-DATE |
| ort/schema/example-image.json | | | |
|--------------------------------|--------------------------------|------------------------------------------------------------------------------------------------------|------------|
| /Users/kojogbede/kojogbede/exp | | https://schema-examples.com/example-author | UP-TO-DATE |
| ort/schema/example-author.json | | | |
|--------------------------------|--------------------------------|------------------------------------------------------------------------------------------------------|------------|
| /Users/kojogbede/kojogbede/exp | | https://schema-examples.com/example-video | UP-TO-DATE |
| ort/schema/example-video.json | | | |
|--------------------------------|--------------------------------|------------------------------------------------------------------------------------------------------|------------|
| kojogbede/export/schema/tutori | kojogbede/export/schema/schema | https://schema-examples.com/tutorial-banner | CREATED |
| al-banner.json | s/tutorial-banner-schema.json | | |
+--------------------------------+--------------------------------+------------------------------------------------------------------------------------------------------+------------+
+--------------------------+------------------------------------------------------------------------------------------------------+------------+
| ID | Schema ID | Result |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482fd9c29307500296a6034 | https://schema-examples.com/blog-post-filter | UP-TO-DATE |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482fd9c9f42be0029cb6c97 | https://schema-examples.com/example-author | UP-TO-DATE |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482fd9d9f42be0029cb6c98 | https://schema-examples.com/example-image | UP-TO-DATE |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482fd9d9f42be0029cb6c99 | https://schema-examples.com/example-text | UP-TO-DATE |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482fd9d13e72a002928a3b6 | https://schema-examples.com/example-video | UP-TO-DATE |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482ffbf13e72a002928a3b8 | https://schema-examples.com/tutorial-banner | CREATED |
+--------------------------+------------------------------------------------------------------------------------------------------+------------+
=== Running Step 3 - Clone Content Types ===
Exporting existing types from destination.
+--------------------------+------------------------------------------------------------------------------------------------------+------------+
| File | Schema ID | Result |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| kojogbede/export/oldType | https://schema-examples.com/blog-post-filter | CREATED |
| /blog-post-filter.json | | |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| kojogbede/export/oldType | https://schema-examples.com/example-author | CREATED |
| /example-author.json | | |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| kojogbede/export/oldType | https://schema-examples.com/example-image | CREATED |
| /example-image.json | | |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| kojogbede/export/oldType | https://schema-examples.com/example-text | CREATED |
| /example-text.json | | |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| kojogbede/export/oldType | https://schema-examples.com/example-video | CREATED |
| /example-video.json | | |
+--------------------------+------------------------------------------------------------------------------------------------------+------------+
Exporting types from source.
+--------------------------+------------------------------------------------------------------------------------------------------+------------+
| File | Schema ID | Result |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| /Users/kojogbede/kojogbe | https://schema-examples.com/blog-post-filter | UP-TO-DATE |
| de/export/type/blog-post | | |
| -filter.json | | |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| /Users/kojogbede/kojogbe | https://schema-examples.com/example-text | UP-TO-DATE |
| de/export/type/example-t | | |
| ext.json | | |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| /Users/kojogbede/kojogbe | https://schema-examples.com/example-image | UP-TO-DATE |
| de/export/type/example-i | | |
| mage.json | | |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| /Users/kojogbede/kojogbe | https://schema-examples.com/example-author | UP-TO-DATE |
| de/export/type/example-a | | |
| uthor.json | | |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| /Users/kojogbede/kojogbe | https://schema-examples.com/example-video | UP-TO-DATE |
| de/export/type/example-v | | |
| ideo.json | | |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| kojogbede/export/type/tu | https://schema-examples.com/tutorial-banner | CREATED |
| torial-banner.json | | |
+--------------------------+------------------------------------------------------------------------------------------------------+------------+
+--------------------------+------------------------------------------------------------------------------------------------------+------------+
| ID | Schema ID | Result |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482fda128d18d5f1c66d4e3 | https://schema-examples.com/blog-post-filter | UPDATED |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482fda1c50ce36da0bb5500 | https://schema-examples.com/example-author | UPDATED |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482fda2cd2e2160aa86bc82 | https://schema-examples.com/example-image | UPDATED |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482fda3ee9f8439821ad7ec | https://schema-examples.com/example-text | UPDATED |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482fda4078d032a0d58ef20 | https://schema-examples.com/example-video | UPDATED |
|--------------------------|------------------------------------------------------------------------------------------------------|------------|
| 6482ffc44cdf4460a1dc8b43 | https://schema-examples.com/tutorial-banner | CREATED |
+--------------------------+------------------------------------------------------------------------------------------------------+------------+
undefined
=== Running Step 4 - Clone Indexes ===
Exporting existing indexes from destination.
WARNING: Search Indexes link missing for the given hub - they are likely disabled for this account.
Exporting indexes from source.
WARNING: Search Indexes link missing for the given hub - they are likely disabled for this account.
No search indexes found in kojogbede/export/index
=== Running Step 5 - Clone Content ===
=== Exporting from source... ===
Retrieving content items, please wait.
Found 1 base folders.
Processing Content/_dependancies/...
Scanning for dependancies.
Saving content items.
/Users/kojogbede/.amplience/copy-1686306758494/Content/Winter banner.json
/Users/kojogbede/.amplience/copy-1686306758494/Content/Summer banner.json
=== Importing to destination... ===
Existing mapping loaded from '/Users/kojogbede/.amplience/clone/hub-6452aa021a8f3574f598716f.json', changes will be saved back to it.
Scanning structure and content in '/Users/kojogbede/.amplience/copy-1686306758494/Content' for repository 'Content'...
Scanning structure and content in '/Users/kojogbede/.amplience/copy-1686306758494/Examples' for repository 'Examples'...
Scanning structure and content in '/Users/kojogbede/.amplience/copy-1686306758494/Slots' for repository 'Slots'...
Done. Validating content...
Found 1 dependancy levels in 2 items, 0 referencing a circular dependancy.
Importing 2 content items...
Creating circular dependants.
Resolving circular dependants.
Done!
=== Done! ===
Using the validate optionLink copied!
Use the --validate
option to check for any invalid content without running the clone. This checks for any content that does not validate against its schema.
Using the step optionLink copied!
Use the --step
option to start the clone from the specified step. You can specify "settings", "extension", "schema", "type", "index", "content" and "event". For example, specifying --step content
would start the clone process at the content step.
"settings", "extension", "schema", "type", "index", "content", "event"
Other optionsLink copied!
To explore what else can be done with clone command, just add --help
to the dc-cli hub clone
command, as shown below:
Clone an entire hub. The active account and hub are the source for the copy.
Exported data from the source hub will be placed in the specified folder.
Positionals:
dir Directory to export content to, then import from. This must be set to the
previous directory for a revert. [string] [required]
Options:
--version Show version number [boolean]
--help Show help [boolean]
--clientId [string] [required]
--clientSecret [string] [required]
--hubId [string] [required]
--config Path to JSON config file
[string] [default: "/Users/kojogbede/.amplience/dc-cli-config.json"]
--acceptSnapshotLimits Must be passed to use the event clone step. Only use
this argument if you fully understand its limitations.
[boolean]
--dstHubId Destination hub ID. If not specified, it will be the
same as the source. [string]
--dstClientId Destination account's client ID. If not specified, it
will be the same as the source. [string]
--dstSecret Destination account's secret. Must be used alongside
dstClientId. [string]
--mapFile Mapping file to use when updating content that already
exists. Updated with any new mappings that are
generated. If not present, will be created. [string]
-f, --force Overwrite content, create and assign content types,
and ignore content with missing types/references
without asking. [boolean]
-v, --validate Only recreate folder structure - content is validated
but not imported. [boolean]
--skipIncomplete Skip any content item that has one or more missing
dependancy. [boolean]
--lastPublish When available, export the last published version of a
content item rather than its newest version. [boolean]
--publish Publish any content items that either made a new
version on import, or were published more recently in
the JSON. [boolean]
--batchPublish Batch publish requests up to the rate limit. (35/min)
[boolean]
--republish Republish content items regardless of whether the
import changed them or not. (--publish not required)
[boolean]
--excludeKeys Exclude delivery keys when importing content items.
[boolean]
--media Detect and rewrite media links to match assets in the
target account's DAM. Your client must have DAM
permissions configured. [boolean]
--revertLog Revert a previous clone using a given revert log and
given directory. Reverts steps in reverse order,
starting at the specified one. [string]
--step Start at a specific step. Steps after the one you
specify will also run.
[string] [choices: "settings", "extension", "schema", "type", "index",
"content", "event"]
--logFile Path to a log file to write to.
[string] [default: (generated-value)]