Caution
Use at your own discretion. This code is not fully tested and is provided as-is. Review and validate all scripts before running them in any environment.
Moves Sitecore content between environments using the Content Transfer API (source) and the Item Transfer API (destination).
- PowerShell 5.1 or later
- Organization Admin or Organization Owner role in the Sitecore Cloud Portal
- Automation client credentials for both the source and destination environments
Repeat the following for each environment (source and destination):
- In the Sitecore Cloud Portal, open SitecoreAI Deploy.
- Go to Credentials → Environment → Create credentials → Automation.
- Fill in the client details and click Create.
- Copy the Client ID and Client Secret — they are shown only once.
Edit transferitems.json to list the Sitecore items you want to transfer.
Each entry in DataTrees is one item path with its own scope and merge strategy.
{
"Database": "master",
"DataTrees": [
{
"ItemPath" : "/sitecore/content/Home",
"Scope" : "ItemAndDescendants",
"MergeStrategy": "OverrideExistingItem"
},
{
"ItemPath" : "/sitecore/media library/Project/banner",
"Scope" : "SingleItem",
"MergeStrategy": "KeepExistingItem"
}
]
}| Field | Required | Values |
|---|---|---|
Database |
Yes | "master" | "web" |
ItemPath |
Yes | Full Sitecore item path |
Scope |
Yes | "SingleItem" — transfer only this item"ItemAndDescendants" — transfer item and all children |
MergeStrategy |
Yes | "OverrideExistingItem" — overwrite matching items in destination"KeepExistingItem" — skip items that already exist"OverrideExistingTree" — overwrite the entire subtree"LatestWin" — keep whichever version is newer |
Set your credentials in the current PowerShell session before running the script:
$env:SITECORE_SRC_CLIENT_ID = "source-client-id-xxxx"
$env:SITECORE_SRC_CLIENT_SECRET = "source-client-secret-xxxx"
$env:SITECORE_DEST_CLIENT_ID = "destination-client-id-yyyy"
$env:SITECORE_DEST_CLIENT_SECRET = "destination-client-secret-yyyy"The environment host name can be found in
SitecoreAI Deploy → Projects → your project → Authoring environments → your environment → Details → Environment host name
.\Move-SitecoreContent.ps1 `
-SourceBaseUrl "https://xmc-yourproject-source.sitecorecloud.io" `
-DestinationBaseUrl "https://xmc-yourproject-dest.sitecorecloud.io" `
-ConfigFile .\transferitems.json| Parameter | Required | Default | Description |
|---|---|---|---|
-SourceBaseUrl |
Yes | — | Host URL of the source environment |
-DestinationBaseUrl |
Yes | — | Host URL of the destination environment |
-ConfigFile |
No | .\transferitems.json |
Path to the transfer configuration file |
-PollIntervalSeconds |
No | 5 |
Seconds between status poll requests |
-TimeoutMinutes |
No | 20 |
Max total time before the script aborts |
-LogFolder |
No | .\logs |
Folder where timestamped log files are written |
Source environment Destination environment
────────────────── ───────────────────────
POST /transfers ──create──>
GET /transfers/{id}/status <──poll──
GET .../chunks/{n} ──stream──> PUT .../chunks/{n}
POST .../chunksets/{id}/complete → .raif file
DELETE /transfers/{id} ──cleanup──>
POST /ItemsTransfer/...sources (consume .raif)
GET /ItemsTransfer/transfers/{id} <──poll──
- Creates a Content Transfer operation on the source for all
DataTreesin one API call. - Polls until the operation reaches
Completedstate. - Streams each encrypted/compressed chunk from source → destination.
- Completes each chunk set, producing a
.raiffile on the destination. - Deletes the transfer from the source (cleanup).
- Triggers Item Transfer on the destination to consume each
.raifinto the database. - Polls until each Item Transfer reaches
Finishedstate.
A timestamped log file is written to .\logs\content-transfer_<yyyyMMdd_HHmmss>.log.
The final lines of the log show a per-RAIF summary:
[OK] contentTransfer-<uuid>.raif
State=Finished Items=34/34 Strategy=OverrideExistingItem
Id=consumed.20260709... DB=master Consumed=2026-07-09T...
=== Migration complete in 60.8s ===
[OK] = Finished · [FAIL] = Failed or Discarded
| File | Description |
|---|---|
Move-SitecoreContent.ps1 |
Main transfer script |
transferitems.json |
List of items to transfer (edit before each run) |
logs/ |
Timestamped log files from each run |