lift clone
Clone deployments from one server to another, including Docker images, databases, and volumes.
lift clone
Clone all (or specific) deployments from a source server to a target server. Copies compose files, Docker images, databases, and volumes.
Usage
# Clone using .lift.json configs
lift clone --from source/.lift.json --to target/.lift.json
# Clone using bare IP addresses
lift clone --from 1.2.3.4 --to 5.6.7.8 --key ~/.ssh/id_rsa
# Clone specific tools only
lift clone --from source/.lift.json --to target/.lift.json --tools redis,postgres
# Clone as staging (prefix domains with staging.)
lift clone --from source/.lift.json --to target/.lift.json --as-staging
Flags
| Flag | Description | Default |
|---|---|---|
--from | Source: .lift.json path or server IP | Required |
--to | Target: .lift.json path or server IP | Required |
--tools | Comma-separated tool names to clone | All tools |
--as-staging | Prefix domains with staging. in Traefik labels | false |
--key | SSH private key path (when using bare IP) | - |
--user | SSH user (when using bare IP) | onelift |
How It Works
The clone operation runs a 5-phase pipeline:
Phase 1: Discovery
Finds all .onelift.json manifests on the source server under /home/deploy/ and /opt/onelift/tools/. Parses each manifest to determine services, databases, volumes, and images. Tools are sorted by dependency order (databases first, apps last).
Phase 2: Backup
Creates database dumps and volume archives on the source server. Database backups use the manifest's backupCommand (e.g., pg_dump, mysqldump). Volumes with critical, high, or medium backup priority are archived as tar.gz.
Phase 2b: Transfer
Downloads backup artifacts from source and uploads them to target via SSH. Each file is transferred individually with progress reporting.
Phase 3: Deploy
For each tool:
- Transfers Docker images (tries
docker pullfirst, falls back todocker save/load) - Copies compose files and
.envfrom source - Runs
docker compose up -don target - Performs a brief health check
Phase 4: Restore
Restores databases by piping dumps into containers via docker exec -i. Restores volumes by extracting tar.gz archives into Docker volumes. Volume names are automatically remapped if the Docker Compose project name differs between source and target.
Phase 5: Finalize
Updates .onelift.json manifests on target with clone metadata. Cleans up temporary backup files on both servers.
Staging Mode
With --as-staging, domain references in Traefik labels are prefixed with staging.. For example, example.com becomes staging.example.com. Subdomain references (e.g., api.example.com) are NOT modified to prevent corruption.
Fire-and-Forget (Panel)
When triggered from the OneLift panel, clone runs as a fire-and-forget operation:
- Worker connects to target server via SSH
- Writes clone config JSON (containing source SSH credentials) to
/tmp/ - Launches
lift clone --config /tmp/X.json --token-file /tmp/X.tokenvia nohup - SSH disconnects immediately
- CLI on target handles all operations and reports back via HTTP callback
Related
- lift migrate - Clone + cleanup source (move instead of copy)
- lift backup - Per-tool backup with Restic
- lift push - Deploy from local machine