Marinus Klasen

Marinus Klasen

  • Development
  • Consultancy
  • Developer Resources
  • Blog
  • Contact

October 11, 2022

WordPress.com SSH & duplicating a WordPress.com website locally

Marinus Klasen

A while back, WordPress.com enabled SSH access for Business and eCommerce plans. I recently had a look at what those environments look like. First test: WP-CLI commands. It’s great to see that commands like wp db export work just fine. You’re also allowed to create folders in the home directory, so we can easily export a file and save them outside of the public root, in a folder like ~/_sql/.

Plugins, themes and WordPress Core

Most plugins and themes installed in the Dashboard are actually symlinks, linking to the root /wordpress/ folder. This is also where WordPress Core is stored. It seems like all of these files are shared files, that are used by all WordPress.com websites. That means that, for example, the Yoast SEO plugin is stored in /wordpress/plugins/wordpress-seo/latest/ which in turn links to /wordpress/plugins/wordpress-seo/19.6.1/ in which the actual files are stored.

What does that mean?

This means that creating a backup or local environment is not as straight forward as it usually is. I normally just run a command like rsync -r public_html/wp-content/ app/www/content followed by a wp db import and a wp search-replace. In this case we also have to do that for files stored in /wordpress/plugins/, /wordpress/themes/ and /wordpress/mu-plugins.

Creating a local environment for a WordPress.com website

Allright, let’s have a look at all steps involved for duplicating a WordPress.com site locally

  1. Connect via SSH (make sure to enable SSH access for the site and connect to it via Settings -> Hosting Configuration)
  2. Create a ~/_sql/ directory or something similar
  3. Run wp db export && mv *.sql ~/_sql/ in ~/htdocs
  4. Prepare a local environment for your site locally (using MAMP, docker-compose or something different)
  5. Download the sql file with something like: scp {name}@sftp.wp.com:~/_sql .
  6. Run wp db import {sql_file_name}.sql in your local site
  7. Run wp search-replace {live-domain-name} {local-domain-name} in your local site
  8. Create a new admin user with something like: wp user create admin [email protected] --role=administrator --user_pass=password
  9. Download the wp-content files with: rsync -r {name}@sftp.wp.com:~/htdocs/wp-content/ {path_to_your}/wp-content/
  10. Download the shared plugin and theme files with:
    • rsync -r {name}@sftp.wp.com:/wordpress/plugins {path_to_your}/wp-content/plugins
    • rsync -r {name}@sftp.wp.com:/wordpress/themes {path_to_your}/wp-content/themes
  11. Visit your new local environment!

Key Take-aways

  • WP-CLI works!
  • Core, plugins and themes are stored in a root folder: /wordpress/
  • The current version of WordPress is stored in ~/htdocs/__wp__ which is a symlink to /wordpress/core/{version-number}
  • The directory structure is a bit.. unusual, a symlink called wordpress-seo in wp-content/plugins/ points to /wordpress/plugins/wordpress-seo/latest which points to /wordpress/plugins/wordpress-seo/19.6.1
  • The  /wordpress folder seems to be a a shared folder readable by all WP sites, but only after enabling or purchasing the plugin for the site

About Marinus Klasen

Marinus has been working in software/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge.

Marinus Klasen on Twitter

This site runs on Cloudways.
It's fast isn't it?
Cloudways offers high-quality, fast and affordable hosting.

Learn more

Need a hand? Post your project and hire me and other top notch developers on Codeable.

Hire me on Codeable

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Ready to take action?

I'm looking forward to discuss your projects and goals!
Feel free to reach out using the contact details below.

Marinus Klasen

[email protected]
twitter.com/marinusklasen
linkedin.com/in/marinusklasen

  • GitHub
  • LinkedIn
  • Twitter

Have you read?

  • Storing private data with SSH on WPEngine sitesDecember 15, 2022
  • Get the HTML content of a block edit page or post in WordPressNovember 30, 2022
  • Rename Coupon code text to Discount code in WoocommerceNovember 3, 2022
  • Background-size cover in mPDFOctober 22, 2022
  • WordPress.com SSH & duplicating a WordPress.com website locallyOctober 11, 2022

Copyright © 2023 · Marinus Klasen | Webdesign by Team Rood