-
Notifications
You must be signed in to change notification settings - Fork 5
Remotes and sync
This is the canonical guide for Govard remote environments, sync operations, and remote-backed database workflows.
govard remote add staging --host staging.example.com --user deploy --path /var/www/appremote add flags:
| Flag | Description |
|---|---|
--host |
Remote hostname or IP |
--user |
SSH username |
--path |
Remote project path |
--port |
SSH port (default: 22) |
--capabilities |
Comma-separated capabilities (files,media,db,deploy) |
--auth-method |
Auth method (keychain, ssh-agent, keyfile) |
--key-path |
Path to SSH key (for keyfile method) |
--strict-host-key |
Enable strict host-key verification |
--known-hosts-file |
Custom known_hosts file |
--protected |
Write-protect this remote |
[TIP] TIP To use the remote user's home directory, quote the path so the local shell does not expand it:
govard remote add staging --host staging.example.com --user deploy --path '~/public_html'
govard remote copy-id staging # Copy your SSH public key to remote authorized_keys
govard remote test staging # Validate SSH + rsync, measure latency, classify failuresremote test identifies failure types: network, auth, permission, host_key, dependency.
govard remote exec staging -- ls -la
govard remote audit tail --lines 20
govard remote audit tail --status failure --lines 50
govard remote audit stats --lines 200Audit log paths:
~/.govard/remote.log~/.govard/operations.log
| Protection | Behavior |
|---|---|
| Production write protection |
prod remotes are write-protected by default |
| Capability enforcement | Each operation checks files, media, db, deploy scopes |
| Strict host-key | Opt-in per remote, not enforced by default |
| 1Password integration | Remote fields support op://... secret references |
govard sync moves files, media, and database data between local and named remotes.
govard sync --source staging --destination local --full --plan
govard sync --from staging --to local --media
govard sync -s dev --db --no-noise --no-pii
govard sync -s prod --file --path app/etc/config.phpAuto-selects staging if no --source provided, falling back to dev.
Bare --media defaults to the optimized media mode.
| Flag | Description |
|---|---|
-s, --source / --from
|
Source environment |
-d, --destination / --to
|
Destination environment |
-e, --environment |
Alias for --source
|
| Flag | Syncs |
|---|---|
-A, --full |
Everything (files + media + database) |
-f, --file |
Source code and generic files |
-m, --media [mode] |
Framework-specific media assets; bare --media defaults to optimized
|
-b, --db |
Project database |
| Flag | Description |
|---|---|
--plan |
Print plan and exit without executing |
-D, --delete |
Delete destination files missing from source |
-R, --resume |
Enable resumable transfers (default: true) |
--no-resume |
Disable resumable transfers |
-C, --no-compress |
Disable rsync compression |
-y, --yes |
Skip confirmation prompts |
-p, --path |
Specific file/directory relative to project root |
-I, --include |
Rsync include pattern (repeatable) |
-X, --exclude |
Rsync exclude pattern (repeatable) |
| Flag | Category | Magento 2 Exclusions | Laravel | WordPress |
|---|---|---|---|---|
--no-noise |
Ephemeral data |
cron_schedule, session, cache_tag, report_event
|
cache, sessions, failed_jobs
|
redirection_404, wflogs
|
--no-pii |
Sensitive data |
customer_entity, sales_order, quote, admin_user
|
users, password_resets
|
users, usermeta, comments
|
[NOTE] NOTE Database filters are optimized for Magento 2. For other frameworks, safe default patterns are used when available.
File and media sync use resumable rsync mode by default (--partial + --append-verify).
govard sync -s staging --file # resumable by default
govard sync -s staging --file --no-resume # disable resumable--include and --exclude (or -I and -X) apply only to -f, --file and -m, --media scopes โ they are ignored for DB-only sync.
In govard bootstrap, --exclude acts as a global ignore list for both the source code clone and the subsequent media sync.
Govard implements automated filtering for Magento media sync to optimize bandwidth and disk usage.
| Category | Behavior | Excluded Paths |
|---|---|---|
| None | --media none |
Skips media sync entirely |
| Minimal | --media minimal |
*.jpg, *.png, *.webp, *.mp4, *.pdf (assets only) |
| Optimized | Default mode |
catalog/product/ (Magento), */cache/* (WordPress) |
| All | --media all |
Truly all (includes everything, use with caution) |
[NOTE] NOTE All modes except All automatically exclude framework noise like
tmp/,cache/, andlogs/.
To download everything, use --media all. To sync only CSS/JS/Fonts, use --media minimal.
[WARNING] WARNING
--deletecombined with--dbsurfaces policy warnings. Production remotes are write-protected by default and will block destructive writes.
govard bootstrap uses the same sync/filter flags for environment initialization:
govard bootstrap --clone -e staging --no-pii --no-noise --deleteGovard accepts any valid identifier as a remote environment name. Names must use lowercase letters, digits, hyphens, or underscores (e.g. qa, preprod, demo, client-uat, load-test).
Remote flags support:
- Exact remote key lookup (e.g.
qa,preprod) - Normalized aliases for well-known environments (e.g.
stgโstaging,liveโproduction) - Case-insensitive fallback matching
| Input | Resolved as |
|---|---|
dev, development, develop
|
development |
staging, stage, stg
|
staging |
prod, production, live
|
production |
Everything else (qa, preprod, demo, etc.) |
Passed through as-is |
When no remote is specified for bootstrap or sync, Govard resolves:
-
staging(or any alias:stg,stage) -
development(or any alias:dev,develop)
If neither staging nor development exists, use -e to specify the remote explicitly:
govard sync -s qa --db
govard bootstrap -e preprod --yesThese are equivalent when the staging remote exists:
govard sync -s stg --db
govard sync --source staging --db
govard sync --from staging --db# Add a QA environment
govard remote add qa --host qa.example.com --user deploy --path /var/www/app
# Add a pre-production environment
govard remote add preprod --host preprod.example.com --user deploy --path /var/www/app
# Bootstrap from QA (must specify -e since it's not auto-selected)
govard bootstrap -e qa --yes
# Sync DB from preprod
govard sync -s preprod --db --no-piiCustom environment names have no automatic write protection. Use --protected or the protected: true config flag to opt in:
govard remote add preprod --host preprod.example.com --user deploy --path /var/www/app --protectedOr in .govard.yml:
remotes:
preprod:
host: preprod.example.com
user: deploy
path: /var/www/app
protected: trueOnly remotes whose name normalizes to prod (i.e. prod, production, live) are write-protected automatically.
govard snapshot create -e staging
govard snapshot list -e staging
govard snapshot restore latest -e staging
govard snapshot delete latest -e stagingRemote snapshots run mysqldump and tar directly on the remote server without transferring data over the network. Stored in ~/.govard/snapshots/ within the remote project path.
# Pull from staging to local
govard snapshot pull before-upgrade -e staging
# Push local snapshot to production (blocked by default protection policy)
govard snapshot push fallback-state -e prodgovard db dump # Local DB to project var/
govard db dump -e staging # Remote DB โ saved on remote (~backup/)
govard db dump -e staging --local # Remote DB โ streamed to local var/
govard db dump --no-noise --no-pii # With privacy filtersgovard db import --file backup.sql --drop
govard db import --stream-db -e staging --drop--stream-db pulls from the remote and imports into the local database. --drop performs a safe reset before import.
govard db query "SELECT COUNT(*) FROM sales_order"
govard db info -e staging
govard db top -e staging # Live process monitoringDesktop remote actions call the same backend paths as CLI commands:
-
Open Database (Remote) โ
govard open db -e <remote> --client -
Open SSH (Remote) โ native Linux terminal launchers, fallback to
ssh:// -
Open SFTP (Remote) โ prefers FileZilla, fallback to
sftp://
For auth.method: ssh-agent, Govard reuses SSH_AUTH_SOCK and probes /run/user/<uid>/keyring/ssh on Linux.
Safe review before execution:
govard sync --source staging --destination local --full --planTarget one file:
govard sync --source prod --file --path app/etc/config.phpCreate a local-safe DB snapshot:
govard db dump -e staging --local --no-noise --no-piiFull workflow: clone from staging with privacy:
govard bootstrap --clone -e staging --no-pii --no-noise --yesCase Study: Efficient Magento Bootstrap
Imagine you are bootstrapping a large Magento 2 project but only want the code and a subset of media:
# Clone code, sync DB without PII, and sync media WITHOUT heavy product images (default: optimized)
govard bootstrap --clone -e staging --no-pii --no-noise --yesCase Study: Targeted Media Sync with Excludes
If you need to sync media but want to skip a specific large folder that isn't covered by default smart exclusions:
# Sync media from staging but skip a custom 'large-assets' directory
govard sync -s staging --media -X "large-assets/*"Case Study: Including Products during Bootstrap
If you actually need the product images for a front-end task:
govard bootstrap --clone -e staging --media all --yesCase Study: The "Broom" vs the "Tweezers"
Combine predefined smart modes (the Broom) with custom excludes (the Tweezers) for ultimate control:
# Get all media, but skip a specific legacy backup folder left on the server
govard bootstrap --clone -e staging --media all -X "pub/media/backup_2022/*" --yesCase Study: Ultra-Fast Sync (Minimal)
If you are working on frontend CSS/JS and don't care about images at all:
# Sync only static assets (css, js, fonts, json)
govard sync -s staging --media minimalGovard โ Go-based Versatile Runtime & Development GitHub ยท Releases ยท Issues ยท MIT License