Files
OpenShell/examples/sync-files.md

1.9 KiB

Syncing Files To and From a Sandbox

Move code, data, and artifacts between your local machine and an OpenShell sandbox using openshell sandbox upload and openshell sandbox download.

Push local files into a sandbox

Upload your current project directory into /sandbox on the sandbox:

openshell sandbox upload my-sandbox .

Push a specific directory to a custom destination:

openshell sandbox upload my-sandbox ./src /sandbox/src

Push a single file:

openshell sandbox upload my-sandbox ./config.yaml /sandbox/config.yaml

Pull files from a sandbox

Download sandbox output to your local machine:

openshell sandbox download my-sandbox /sandbox/output ./output

Pull results to the current directory:

openshell sandbox download my-sandbox /sandbox/results

Sync on create

Push all files in the current directory into a new sandbox automatically:

openshell sandbox create --upload . -- python main.py

This uploads the current directory into /sandbox before the command runs.

Workflow: iterate on code in a sandbox

# Create a sandbox and upload your repo
openshell sandbox create --name dev --upload .

# Make local changes, then push them
openshell sandbox upload dev ./src /sandbox/src

# Run tests inside the sandbox
openshell sandbox connect dev
# (inside sandbox) pytest

# Pull test artifacts back
openshell sandbox download dev /sandbox/coverage ./coverage

How it works

File sync uses tar-over-SSH. The CLI streams a tar archive through the existing SSH proxy tunnel -- no rsync or other external tools required on your machine. The sandbox base image provides GNU tar for extraction.

  • Push: tar::Builder (Rust) -> stdin | ssh <proxy> sandbox "tar xf - -C <dest>"
  • Pull: ssh <proxy> sandbox "tar cf - -C <dir> <path>" | stdout -> tar::Archive (Rust)