Docs cipi.yml Web panel API MCP Guides Compare GitHub Telegram channel
  1. Docs
  2. Deploy
  3. Safe deploy & DB snapshots

Safe deploy & DB snapshots

Back up before a release and snapshot the database before migrations.

Deploy

A safe deploy has a restore point taken before new code and migrations touch production. Cipi gives you two levels; use one or both.

LevelHowRestoresWhere it lives
Database snapshot--snapshot or --predeploy-snapshotThe databaseOn the server
Full backupcipi backup run in a pipeline stageDatabase + files (shared/: .env, uploads)S3 or any S3-compatible bucket
Step 1 of 4Tests pass

Your CI runs the tests. Only a green build goes on.

Database snapshot before every deploy#

bash
cipi deploy shop --snapshot             # dump first; warn and continue if it fails
cipi deploy shop --snapshot-required    # dump first; abort the deploy if it fails
cipi app edit shop --predeploy-snapshot # always, for every trigger (CLI, webhook, CI)

Dumps go to /var/log/cipi/backups/, the same place as cipi db backup.

cipi deploy --rollback restores code, not data. To undo a migration, restore the snapshot: cipi db restore shop /var/log/cipi/backups/shop_<timestamp>.sql.gz.

Full backup in a pipeline#

A webhook deploys as soon as you push, so an off-site backup step belongs in a CI pipeline. Configure S3 once with cipi backup configure.

yaml
# .github/workflows/deploy.yml (jobs only)
  backup:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: appleboy/ssh-action@v1
        with:
          host: ${{ secrets.SERVER_HOST }}
          username: cipi
          key: ${{ secrets.SERVER_SSH_KEY }}
          script: sudo cipi db backup shop && sudo cipi backup run --profile=shop-nightly
  deploy:
    needs: backup
    runs-on: ubuntu-latest
    steps:
      - uses: appleboy/ssh-action@v1
        with:
          host: ${{ secrets.SERVER_HOST }}
          username: cipi
          key: ${{ secrets.SERVER_SSH_KEY }}
          script: sudo cipi deploy shop || (sudo cipi deploy shop --rollback && exit 1)

test → backup → deploy: if one fails, the next never runs; if the deploy fails, the previous release is restored.

Restore#

bash
ls -lh /var/log/cipi/backups/shop_*.sql.gz
cipi db restore shop /var/log/cipi/backups/shop_20261103_143012.sql.gz
cipi deploy shop --rollback
# from S3
cipi backup list --profile=shop-nightly
cipi backup fetch shop-nightly 2026-11-03_020000 --dest=/root/restore

Local snapshots are kept until you remove them; see Backups for retention rules that prune automatically.