> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vulpy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Backup and restore your Vulpy Commerce shop

> Snapshot environments with pnpm vulpy env backup, migrate data from a local dev machine to a VPS, and restore on demand from a bundle archive.

Vulpy Commerce persists everything under `.data/` in the project folder, so backup and restore are file-level operations wrapped by CLI commands. This page covers per-environment snapshots and the local-to-VPS migration flow.

<Tip>
  **Ask Fox to draft the backup and migration commands.** Fox knows what a backup includes and can spell out the exact tar and rsync for you.

  Try prompts like:

  * "Explain what a backup includes."
  * "Draft the migrate-from-laptop command sequence for me."
  * "What's the safest way to restore Payload media only?"
</Tip>

## Environment backups

Every environment has a matching pair of commands.

<CodeGroup>
  ```bash Backup theme={null}
  pnpm vulpy env backup <name>
  ```

  ```bash Restore theme={null}
  pnpm vulpy env restore <name> <archive>
  ```
</CodeGroup>

Use these against `dev`, `staging`, or `live`. Backups include configuration (per the app contract) and the environment's persistent data.

<Note>
  Fox cannot run these commands. Backups and restores are host-scope operations that you run as the deploy user (`sudo -iu vulpy-commerce`).
</Note>

## Migrate from local dev to a VPS

If you have been developing on your laptop and want to move data onto a fresh VPS install, use the migrate bundle scripts.

<Steps>
  <Step title="Export on your laptop">
    ```bash theme={null}
    ./scripts/migrate/export-local.sh
    ```

    This writes a bundle under `.tmp/migrate-bundle-*.tar.gz`.
  </Step>

  <Step title="Copy the bundle to the VPS">
    ```bash theme={null}
    scp .tmp/migrate-bundle-*.tar.gz user@vps:/opt/<project-name>/
    scp deploy/.env user@vps:/opt/<project-name>/deploy/.env
    ```
  </Step>

  <Step title="Sync the working tree (optional)">
    If you also want the code from your laptop, exclude regenerable artifacts:

    ```bash theme={null}
    rsync -aH \
      --exclude='node_modules' \
      --exclude='.next' \
      --exclude='.medusa' \
      --exclude='.turbo' \
      --exclude='.tmp/migrate-bundle-*' \
      ./ user@vps:/opt/<project-name>/
    ssh user@vps 'cd /opt/<project-name> && pnpm install'
    ```
  </Step>

  <Step title="Import on the VPS">
    ```bash theme={null}
    cd /opt/<project-name>
    COMPOSE_SUDO=1 ./scripts/deploy/rollout-vps.sh migrate-bundle-YYYYMMDD.tar.gz
    ```
  </Step>
</Steps>

## Seed-first deploys

For an empty-DB rollout that seeds on start instead of importing a bundle, set two variables before the rollout:

```bash theme={null}
SEED_ON_START=1
SYNC_PUBLISHABLE_KEY=1
```

The `--seed` install flag sets both automatically.

<Warning>
  Restore replaces data. Take a fresh `pnpm vulpy env backup <name>` before restoring anything into a live environment so you can roll back.
</Warning>

<CardGroup cols={2}>
  <Card title="Environments" icon="layer-group" href="/deploy/environments">
    How dev, staging, and live are isolated on disk.
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/reference/troubleshooting">
    Common issues and the exact commands to fix them.
  </Card>
</CardGroup>
