🧘 Keep calm and pull your site. 🧘
Inofficial DDEV pull and push scripts for happy local WordPress development: Pull in the latest site content to your local dev sever. Test, develop and design in peace without breaking your live site. These scripts require at least DDEV 1.18.2.
Status: Work in Progress, please use with caution.
- ⚡️ ddev pull ssh - pull a site with just one command
- ⚡️ ddev push ssh --skip-db - push the child theme (experimental)
- 💾 ddev pull backup - download and import a BackWpUp .zip-file
- Online config generator: DDEV pull wp generator (Source code)
- 🎥 Screencasts: ddev pull ssh
- DDEV discord community
Pull in your live WordPress site via SSH (and rsync). Your webspace needs support for mysqldump and you need to be able to connect to your SSH webspace via SSH key authentication (without password).
First time project setup
You can as use the Online Generator or the manual approach:
- Adjust
.ddev/config.yaml
for your needs - Configure
.ddev/providers/ssh.yaml
(SSH host, user and WordPress path on server) - Run
ddev start
- Run
ddev auth ssh
Nice! You ready to pull!
Pull in your latest site content
- Run
ddev pull ssh
That's it, run ddev launch
to open your site in the web browser. If you experience issues, see Troubleshooting.
Source code: .ddev/providers/ssh.yaml
If you want to clean and delete all pulled filles, you can use git clean -fdx -e .ddev
.
Use with caution, rsync can overwrite files or cause chaos! Always backup your live site!
This will push your child theme folder to the remote site you already configured for the pull.
- Run
ddev push ssh --skip-db
Currently rsync is configured without --delete
-flag, therefore no files will be deleted on remote child theme folder.
Hosting company | Pull tested? | Push tested ? |
---|---|---|
Manitu (DE) | ✅ | In progress |
Raidboxes (DE) | ✅ | In progress |
WPEngine | In progress | In progress |
Mittwald (DE) | In progress | In progress |
Create and (manually) download a BackWpUp backup-file from your live site, import it to your local DDEV project. No SSH required, just download your backup file and import it as .zip-file.
Gitpod support via drud/ddev-gitpod-launcher
First time project setup
- Copy
.ddev/example.config.yaml
to.ddev/config.yaml
- Configure Child theme folder name in
.ddev/config.yaml
(optional) - Adjust child theme folder name in
.gitignore
(optional) - Run
ddev start
andddev auth ssh
Import a backup:
- Create a backup with BackWPup – WordPress Backup Plugin (Open Source) on your live site
- Download BackWpUp .zip file to root of local project folder
- Rename backup file to
backup.zip
ddev pull backup
- Open imported website in browser:
ddev launch
Source code: .ddev/providers/backup.yaml
You can optionally manage a child theme via git and deploy it with a tool like WPPusher or SayHelloGmbH/git-installer (no git on server required, works via HTTP apis of Github, Bitbucket, etc.). This repository already contains an example child theme.
Pull scripts are import steps for database and files which are stored as .yaml-files in .ddev/providers
. They can be executed via ddev pull
. See DDEV pull (providers) documentation for more insights.
Design, test and develop sites in local isolated DDEV project environments without breaking the live site.
- delete pulled files:
git clean -fdx -e .ddev
- removes all untracked files and directories (pulled files), but without deleting the DDEV folder
- reset DDEV project:
ddev delete -O
- deletes DDEV project with database and containers (files will be kept)
git clean -fdx
- removes all untracked files and directories
- if .ddev/config.yaml is untracked in git, it will be removed as well (!)
- you need to run 'ddev start' again afterwards to init
Please check with ddev -v
that you are using DDEV 1.18.2 or newer.
If you use double quotes or single + double quotes mixed in wp-config.php, the script can't figure out the database credentials.
Bad: define('DB_NAME', "db75994");
Good - use only single quotes: define('DB_NAME', 'db75994');
(Debug this with a) connect to ssh ddev ssh-production
and b) run echo (cat wp-config.php | grep DB_NAME | cut -d \' -f 4)
, if this output is empty the bash parsing doesn't work properly for your site.)
Please use only single quotes for all DB_
-values in wp-config.php.
Please make sure that the DDEV database type matches the database type of the backup / import.
https://ddev.readthedocs.io/en/latest/users/extend/database_types/
If .htaccess has a https-only rule with something like 'RewriteCond %{HTTPS} !=on', it will result in 'ERR_TOO_MANY_REDIRECTS'. Just remove these rules from .htaccess. https://twitter.com/m_andrasch/status/1481290725694349316
/wp-super-cache/wp-cache-base.php): failed to open stream: No such file or directory in /var/www/html/wp-content/plugins/wp-super-cache/wp-cache.php on line 99`
Warning: include_once(/home/sites/site100026635/web/matthias-andrasch.eu/blog/wp-content/plugins/wp-super-cache/wp-cache-phase1.php): failed to open stream: No such file or directory in /var/www/html/wp-content/advanced-cache.php on line 22
Just login into wp-admin/-dashboard, WP Super Cache will repair the path or remove the define('WPCACHEHOME',..
line from pulled wp-config.php manually after import.
Update: This should be fixed now.
This is a charset issue I wasn't able to fix automatically yet. Please check your live sites wp-config.php
and look for DB_CHARSET
. Set this value in ssh.yaml for REMOTE_DB_CHARSET=
and pull via ssh again (ddev pull ssh
).
(Technical infos: It is related to DB_CHARSET set to something other than default 'utf8' in wp-config.php. For utf8mb4 the export needs to done with mysqldump --default-character-set=utf8mb4
to be correct (https://stackoverflow.com/a/45301470/809939). But WordPress docs state DB_CHARSET setting may be not existent in wp-config.php, so we can't just read it from wp-config.php via bash, needs to be a conditional bash parsing from wp-config.php (See: https://wordpress.org/support/article/editing-wp-config-php/#database-character-set).)
- Use "- REMOTE_DB_CHARSET=utf8" as optional parameter, only use it in provider script if it is set
- Test SSH with password-based auth, should be working as well?
- Only single quotes are currently support with getting db values via bash (because of cut -d = delimiter is
'
) - PHP 8.1 support? WP-CLI threw some errors, maybe fixed in new release? https://make.wordpress.org/cli/2022/01/26/wp-cli-v2-6-0-release-notes/
- Find out how to integrate https://git-updater.com/ within this workflow (See: afragen/git-updater#716)
- Is https://github.com/jackd248/db-sync-tool more reliable? (ddev must be extended to support python), saw this via https://www.youtube.com/watch?app=desktop&v=nzxTPAMFssA)
Thanks to
- DDEV maintainer @randyfay for helpful advice
- @dahaupt for awesome advice on db sync,
- @BokuNoMaxi for testing and collaboration on this
- All people in the WordPress & DDEV community for sharing their knowledge online
- My colleagues at gugler* MarkenSinn.
My code is released as CC0 Public Domain, feel free to use it with or without attribution.