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

FlagDescriptionDefault
--fromSource: .lift.json path or server IPRequired
--toTarget: .lift.json path or server IPRequired
--toolsComma-separated tool names to cloneAll tools
--as-stagingPrefix domains with staging. in Traefik labelsfalse
--keySSH private key path (when using bare IP)-
--userSSH 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:

  1. Transfers Docker images (tries docker pull first, falls back to docker save/load)
  2. Copies compose files and .env from source
  3. Runs docker compose up -d on target
  4. 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:

  1. Worker connects to target server via SSH
  2. Writes clone config JSON (containing source SSH credentials) to /tmp/
  3. Launches lift clone --config /tmp/X.json --token-file /tmp/X.token via nohup
  4. SSH disconnects immediately
  5. CLI on target handles all operations and reports back via HTTP callback