Skip to content

Pull Script (Staging to Local)

The pull.sh script syncs a remote staging site’s database and files to your local WP Local environment.

  • Local by WP installed with the site set up
  • SSH access to the remote server
  • The script must be run from the Local Site Shell (Open Local → select site → “Open Site Shell”)
  1. Exports the remote database via SSH + WP-CLI
  2. Downloads the SQL file via rsync
  3. Cleans up the remote backup
  4. Detects and fixes table prefix mismatches (e.g. RVqYRUrc_wp_)
  5. Imports the database locally
  6. Runs search-replace on the domain (catches both http:// and https://)
  7. Flushes the cache
  8. Syncs wp-content/ files via rsync (excludes cache, logs, etc.)

The script has a config block at the top. For a new site, update these values:

Terminal window
# ── Configuration ─────────────────────────────────────
REMOTE_SSH_HOST="user@host.com" # SSH connection string
REMOTE_SSH_PORT="2222" # SSH port
REMOTE_PATH="/path-to-www" # Remote WordPress root
REMOTE_TEMP_DIR=".pressidium" # Safe dir for temp DB exports
LOCAL_WP_PATH="/Users/.../app/public" # Local WordPress root
REMOTE_SITE_DOMAIN="staging.example.com" # Remote domain (no protocol)
LOCAL_SITE_DOMAIN="site.local" # Local domain (no protocol)

The search-replace uses domain only (no https:// prefix). This ensures both http:// and https:// references are caught — remote databases sometimes store URLs with inconsistent protocols.

The script excludes these from the file sync:

cache/
uploads/cache/
upgrade/
debug.log
*.log
object-cache.php
advanced-cache.php
.DS_Store
  1. Copy pull.sh to the new site’s root (e.g. /Users/.../Local Sites/newsite/)
  2. Update the 6 config variables at the top
  3. Ensure you have SSH access to the remote server (ssh -p PORT USER@HOST)
  4. Open Local Site Shell and run bash pull.sh
IssueFix
wp: command not foundRun from Local Site Shell, not regular terminal
wp db import failsCheck MySQL is running in Local
SSH connection refusedVerify SSH host, port, and key are correct
URLs still pointing to stagingCheck the remote DB uses the same domain you configured — try wp option get siteurl after import