User Tools

Site Tools


Copy wordpress multisite site (theme) to another site

Wordpress saves the different sites inside wp-content/uploads/sites/<site_number> e.g. wp-content/uploads/sites/3/. There are corresponding wp tables in the database e.g.

| wp_3_actionscheduler_actions                      |
| wp_3_actionscheduler_claims                       |
| wp_3_actionscheduler_groups                       |
| wp_3_actionscheduler_logs                         |
| wp_3_commentmeta                                  |
| wp_3_comments                                     |
| wp_3_links                                        |
| wp_3_options                                      |
| wp_3_postmeta                                     |
| wp_3_posts                                        |
| wp_3_term_relationships

Copy the required themes and plugins from main site

Example copying astra and astra-child theme to site number 3 (check wp admin for number).

cp -r wp-content/themes/astra* wp-content/uploads/sites/3/

Copying elementor plugin as well

cp -r wp-content/uploads/elementor wp-content/uploads/sites/3/

Also copy any images or other files that are uploaded in e.g. wp-content/uploads/sites/3/2021 folders.

Update the database tables

Dump the database first:

mysqldump -uroot -p sitedb > sitedb_bak.sql

Cut out only the main site tables which we will use for import later:

sed -n -e '/DROP TABLE.*`wp_[a-zA-Z].*`/,/UNLOCK TABLES/p' sitedb_bak.sql > wp_main_site.sql

Open the file with vim and search and replace table names with correct prefix, e.g we want to overwrite settings in site numbered 3 in DB so we are renaming the table names to wp_3_*

vi wp_main_site.sql

So a statement like

 INSERT INTO `wp_postmeta` VALUES ...

will be

 INSERT INTO `wp_3_postmeta` VALUES ...

Substitute URLs as well


Import and overwrite tables in DB

mysql -uroot -p sitedb < wp_main_site.sql

Refresh the page and regenerate CSS from WP admin theme settings or plugin, depending on what is being used.

Tested on

  • Debian 10.7
  • Wordpress 5.6
  • Elementor v3.0.16

See also

wiki/copy_wordpress_multisite_site_theme_another.txt · Last modified: 2021/01/15 16:04 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki