The nself sync command synchronizes databases, files, and configuration between environments. Enhanced in v0.4.7 with auto-sync and watch mode.
Synchronize database between environments.
nself sync db <environment>
# Examples
nself sync db staging # Sync database to staging
nself sync db production # Sync database to productionSynchronize files/uploads between environments.
nself sync files <environment>
# Examples
nself sync files staging # Sync files to staging
nself sync files production # Sync files to productionSynchronize configuration between environments.
nself sync config <environment>
# Examples
nself sync config staging # Sync config to stagingFull synchronization (database, files, and configuration).
nself sync full <environment>
# Examples
nself sync full staging # Full sync to staging
nself sync full production # Full sync to productionConfigure automatic synchronization service.
nself sync auto --setup # Configure auto-sync service
nself sync auto --stop # Stop auto-sync service
# Auto-sync runs in the background and keeps
# environments synchronized automaticallyContinuously sync changes between environments using file watching.
nself sync watch # Watch all changes
nself sync watch --path <dir> # Watch specific path
nself sync watch --interval <seconds> # Set polling interval
# Examples
nself sync watch --path ./uploads
nself sync watch --interval 30
# Press Ctrl+C to stop watchingCheck synchronization status.
nself sync status
# Output:
# Sync Status
# ===========
# Environment: staging
# Last Sync: 2026-01-23 10:30:00
#
# Database:
# Tables synced: 24
# Rows synced: 15,432
# Status: up-to-date
#
# Files:
# Files synced: 1,234
# Size: 2.3GB
# Status: 3 files pending
#
# Config:
# Status: up-to-dateView synchronization history.
nself sync history
# Output:
# Sync History
# ============
# DATE TYPE TARGET STATUS
# 2026-01-23 10:30:00 database staging success
# 2026-01-23 09:15:00 files staging success
# 2026-01-22 18:00:00 full staging success
# 2026-01-22 14:00:00 config prod successFor full cross-environment migration, use the nself migrate command:
Migrate schema, data, and configuration between environments.
nself migrate <source> <target> [options]
# Options:
# --dry-run Preview migration without changes
# --schema-only Migrate only database schema
# --data-only Migrate only data (no schema changes)
# --config-only Migrate only configuration
# --force Skip confirmation prompts
# --watch Continuous sync mode
# Examples
nself migrate local staging --dry-run # Preview migration
nself migrate staging prod # Migrate staging to production
nself migrate local staging --schema-only # Schema onlyShow differences between environments.
nself migrate diff <source> <target>
# Examples
nself migrate diff local staging # Compare local vs staging
nself migrate diff staging prod # Compare staging vs productionKeep environments continuously in sync.
nself migrate sync <source> <target>
nself migrate sync staging prod --watch # Continuous sync
# Press Ctrl+C to stopRollback the last migration.
nself migrate rollback # Undo last migrationWhen running a migration, ɳSelf follows this process:
Migrations can include:
| Component | Description | Flag |
|---|---|---|
| Schema | Database tables, indexes, constraints | --schema-only |
| Data | Database records | --data-only |
| Config | Environment variables, service settings | --config-only |
| Environment | Alias | Description |
|---|---|---|
| local | dev | Local development environment |
| staging | - | Staging environment |
| prod | production | Production environment |
When migrating to production:
--force to skip confirmation (CI/CD use)--dry-run first# Safe production migration workflow
nself migrate staging prod --dry-run # Preview
nself migrate staging prod # Execute with confirmationEach migration creates a checkpoint in .ɳSelf/migrations/. Checkpoints allow you to rollback if needed.
# View checkpoints
ls .ɳSelf/migrations/
# Rollback using checkpoint
nself migrate rollbackMigration uses these configuration sources:
| Environment | Config Files |
|---|---|
| local | .env, .env.local, .env.dev |
| staging | .env.staging, .environments/staging/server.json |
| production | .env.prod, .environments/prod/server.json |
# Pull latest staging data to local
nself sync db staging
# Work locally...
# Push changes back
nself migrate local staging# Reset staging with fresh data
nself sync full staging
# Verify
nself sync status# Start watching for changes
nself sync watch --path ./uploads
# Or use auto-sync
nself sync auto --setup| Option | Description |
|---|---|
| --dry-run | Preview without making changes |
| --schema-only | Migrate only database schema |
| --data-only | Migrate only data |
| --config-only | Migrate only configuration |
| --force | Skip confirmation prompts |
| --watch | Continuous sync mode |
| --json | Output in JSON format |