Pull Script (Staging to Local)
The pull.sh script syncs a remote staging site’s database and files to your local WP Local environment.
Prerequisites
Section titled “Prerequisites”- 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”)
What it does
Section titled “What it does”- Exports the remote database via SSH + WP-CLI
- Downloads the SQL file via rsync
- Cleans up the remote backup
- Detects and fixes table prefix mismatches (e.g.
RVqYRUrc_→wp_) - Imports the database locally
- Runs search-replace on the domain (catches both
http://andhttps://) - Flushes the cache
- Syncs
wp-content/files via rsync (excludes cache, logs, etc.)
Configuration
Section titled “Configuration”The script has a config block at the top. For a new site, update these values:
# ── Configuration ─────────────────────────────────────REMOTE_SSH_HOST="user@host.com" # SSH connection stringREMOTE_SSH_PORT="2222" # SSH portREMOTE_PATH="/path-to-www" # Remote WordPress rootREMOTE_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)Important: domain-only search-replace
Section titled “Important: domain-only search-replace”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.
File excludes
Section titled “File excludes”The script excludes these from the file sync:
cache/uploads/cache/upgrade/debug.log*.logobject-cache.phpadvanced-cache.php.DS_StoreSetting up for a new site
Section titled “Setting up for a new site”- Copy
pull.shto the new site’s root (e.g./Users/.../Local Sites/newsite/) - Update the 6 config variables at the top
- Ensure you have SSH access to the remote server (
ssh -p PORT USER@HOST) - Open Local Site Shell and run
bash pull.sh
Troubleshooting
Section titled “Troubleshooting”| Issue | Fix |
|---|---|
wp: command not found | Run from Local Site Shell, not regular terminal |
wp db import fails | Check MySQL is running in Local |
| SSH connection refused | Verify SSH host, port, and key are correct |
| URLs still pointing to staging | Check the remote DB uses the same domain you configured — try wp option get siteurl after import |