Skip to content

mandrasch/ddev-pull-wp-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DDEV pull wp scripts

🧘  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.

Scripts

Helpful resources

Usage

⚡️  ddev pull ssh

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:

  1. Adjust .ddev/config.yaml for your needs
  2. Configure .ddev/providers/ssh.yaml (SSH host, user and WordPress path on server)
  3. Run ddev start
  4. Run ddev auth ssh

Nice! You ready to pull!

Pull in your latest site content

  1. 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.

(experimental) ⚡️  ddev push ssh

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.

Webhoster support

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

💾  ddev pull backup

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.

Open in Gitpod

Gitpod support via drud/ddev-gitpod-launcher

First time project setup

  1. Copy .ddev/example.config.yaml to .ddev/config.yaml
  2. Configure Child theme folder name in .ddev/config.yaml (optional)
  3. Adjust child theme folder name in .gitignore (optional)
  4. Run ddev start and ddev auth ssh

Import a backup:

  1. Create a backup with BackWPup – WordPress Backup Plugin (Open Source) on your live site
  2. Download BackWpUp .zip file to root of local project folder
  3. Rename backup file to backup.zip
  4. ddev pull backup
  5. Open imported website in browser: ddev launch

Source code: .ddev/providers/backup.yaml

Child theme deployment

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.

Technical Documentation

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.

Reset / delete

  • 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

Troubleshooting

DDEV version correct?

Please check with ddev -v that you are using DDEV 1.18.2 or newer.

Database dump doesn't work - only single quotes are supported in wp-config.php!

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.

Correct database type (mysql or maria db)?

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/

ERR_TOO_MANY_REDIRECTS (apache)

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 warnings

/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.

Emojis get lost after import and are replaced with ????

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).)

TODOs

Acknowledgements

Thanks to

License

My code is released as CC0 Public Domain, feel free to use it with or without attribution.

About

Inofficial DDEV pull scripts for happy local WordPress development. Status: Work in progress.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published