• Hello

    I would like to know how to copy a current subdomain site within a Multisite network to a second server and it’s Multisite network that uses subdomains. One network is prod and another dev. Ex: one domain would be prod.abc.com and the second would be dev.abc.com

    The site would have a different URL on each server.

    The current site that we want to copy/clone is fully developed.

    Ideally we would like to do that using “wp cli”

    Thanks for your time

    • This topic was modified 1 year, 7 months ago by jbr11.
    • This topic was modified 1 year, 7 months ago by jbr11.
Viewing 2 replies - 1 through 2 (of 2 total)
  • To copy a subdomain site from one WordPress Multisite network to another using WP-CLI, you can follow these steps:

    1. Export the source site’s content using wp export:

    On the source server, navigate to the root directory of your WordPress installation and run:

    wp export --url=source-site.example.com --dir=/path/to/export/directory
    

    This will create an XML file containing all the content from the source site.

    1. Compress the source site’s wp-content/uploads directory:

    Still on the source server, compress the wp-content/uploads directory, as you’ll need to transfer it to the destination server:

    tar czvf uploads.tar.gz /path/to/wordpress/wp-content/uploads
    
    1. Transfer the exported content and the compressed uploads directory to the destination server:

    You can use a tool like scp or an FTP client to transfer the exported XML file and the compressed uploads.tar.gz file to the destination server.

    1. Import the content on the destination site:

    On the destination server, navigate to the root directory of your WordPress installation and run:

    wp import /path/to/exported/content/file.xml --authors=create --url=destination-site.example.com
    

    This command will import the content and create new users if necessary.

    1. Uncompress the transferred uploads directory:

    Still on the destination server, uncompress the uploads.tar.gz file to the wp-content/uploads directory:

    tar xzvf uploads.tar.gz -C /path/to/wordpress/wp-content
    
    1. Update the site URL and other configurations (optional):

    If you need to update the site URL, search and replace the old URL with the new URL using wp search-replace:

    wp search-replace 'https://source-site.example.com' 'https://destination-site.example.com' --url=destination-site.example.com
    

    Remember to replace the URLs with your actual domain names. Also, note that this command will only update the database content; if there are hardcoded URLs in your theme or plugin files, you’ll need to update them manually.

    To copy a subdomain site within a WordPress Multisite network from one server to another using WP CLI, you can follow these steps:

    1. Export the site content from the production server using WP CLI’s export command. Run the following command:wp export --dir=/path/to/export/folderThis will create an XML file in the specified folder that contains all the site’s content.
    2. Copy the exported XML file to the development server.
    3. Create a new subdomain site on the development server using WP CLI’s site create command. Run the following command:wp site create --slug=devsite --title="Development Site" --network=dev.abc.comReplace “devsite” with the desired subdomain slug and “Development Site” with the desired site title. Replace “dev.abc.com” with the development network’s subdomain.
    4. Import the site content into the new subdomain site using WP CLI’s import command. Run the following command:wp import /path/to/export/folder/exported_file.xml --authors=createThis will import the site content into the new subdomain site. The –authors=create flag will create new user accounts for any authors who are not already present on the development server.
    5. Update any URLs that may be hardcoded in the site’s content using WP CLI’s search-replace command. Run the following command:wp search-replace 'prod.abc.com' 'dev.abc.com/devsite' --skip-columns=guidThis will update any instances of the production subdomain URL in the site’s content to the development subdomain URL. Replace “devsite” with the subdomain slug you used in step 3.
    6. Test the new subdomain site on the development server to ensure everything is working as expected.

    Note: Make sure to backup your production site before attempting to export, and your development site before running the import and search-replace commands.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘“wp cli” copy subdomain from Multisite network to 2nd server Multisite network’ is closed to new replies.