WordPress Toolkit Cloning hangs or stops on a Plesk server | Fix it today

WordPress Toolkit Cloning hangs or stops on a Plesk server? We have a solution for you. 

At Bobcares, we offer solutions for every query, big and small, as a part of our Server Management Service.

Let’s take a look at how our Support Team recently helped a customer when the WordPress Toolkit Cloning kept hanging or stoping on a Plesk server.

Why does WordPress Toolkit Cloning hang or stop on a Plesk server?

Have you been facing trouble while attempting to use the WordPress Toolkit Cloning feature? Our Support Team has been helping out customers who find themselves facing an error similar to the one below:

WP-CLI command has not finished working in 60 seconds, so it was terminated. Usually this means that there are problems with WordPress instance WordPress instance #12 ('https://staging.example.com') itself, for example it could be infected with malware. Check the wp-config.php file of the instance for potential malware code.

Moreover, we can find the error messages in the /var/log/plesk/panel.log file:

[2021-10-09 19:24:03.957] ERR [1] '/usr/local/psa/admin/bin/filemng' 'jdoe' 'exec' '/var/www/vhosts/example.com/staging.example.com' '/opt/plesk/php/7.2/bin/php' '-d' 'safe_mode=off' '-d' 'display_errors=off' '-d' 'opcache.enable_cli=off' '-d' 'open_basedir=' '-d' 'error_reporting=341' '-c' '/var/www/vhosts/system/staging.example.com/etc/php.ini' '/usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/wp-cli/php/boot-fs.php' '--path=/var/www/vhosts/example.com/staging.example.com' 'search-replace' 'https://example.com' 'https://staging.example.com' '--precise' '--all-tables' failed with code 15.

In this scenario, we will also notice that the PHP handler of the main domain of the subscription is usually either PHP 7.2 or 7.3.

According to our Support Techs, the error is due to an issue with the `search-replace` from WP-CLI utility in connection with PHP 7.2 & 7.3.

How to resolve “WordPress Toolkit Cloning hangs or stops on a Plesk server”

Fortunately, there are two workarounds to resolve this specific issue:

  • Via Plesk Web interface
  • Via command-line (SSH) or RDP (for Windows)

Via Plesk web interface

  1. First, log in to Plesk.
  2. Then, we will create the subdomain where we want to clone the instance. For instance, it is staging.example.com in this scenario.
  3. Next, we will navigate to PHP Settings under staging.example.com in the Domains section. Then, we will switch to PHP version to 7.1 in this example.
  4. After that, we will head to Clone under example.com in WordPress. Here we will select Use existing domain or subdomain and choose the new domain staging.example.com as the Target. We can opt to change the database name here.
  5. Finally, once the cloning is over, we will head to PHP Settings under staging.example.com in the Domains section and switch back to PHP version 7.2.

Via command line

In case the cloning procedure fails, we can still resolve the issue through the command line. Our Support Team offers us two options to get this done, via SSH or RDP.

Workaround via SSH

  1. First, we will connect to the server via SSH.
  2. Then we have to create the subdomain where we want to clone the instance with this command:
    # plesk bin subdomain --create staging -domain example.com -www-root /staging.example.com -empty-document-root true

    If the target instance is not the subdomain of the source instance, we have to run the following command:

    # plesk bin site --create staging.example.com -webspace-name example.com -hosting true -www-root /staging.example.com -empty-document-root true
  3. Next, we have to copy the files to the target folder from the source folder with this command:
    # cp -pr /var/www/vhosts/example.com/httpdocs/* /var/www/vhosts/example.com/staging.example.com/

     

  4. After that, we have to replace the source URL with the target URL:
    # for i in $(grep -rl "example.com" /var/www/vhosts/example.com/staging.example.com/); do sed -i "s/example.com/staging.example.com/g" $i; done
  5. Then, we will find the source database details as seen below:
    # cat /var/www/vhosts/example.com/httpdocs/wp-config.php | egrep 'DB_NAME|DB_USER|DB_PASSWORD|DB_HOST'
    define('DB_NAME', 'example-db');
    define('DB_USER', 'wp_abcdef');
    define('DB_PASSWORD', 'pa$$w0rd');
    define( 'DB_HOST', 'localhost:3306' );
  6. Next, we will make a dump of the database with the following command:
    # mysqldump -u wp_abcdef -p example-db -h localhost > example-db.sql
  7. After that we will replace the strings example.com with staging.example.com in the dump:
    # sed -i 's/example.com/staging.example.com/g' example-db.sql
  8. Then, we will create a new database for the target as well as a user for this database with the following commands:
    # plesk bin database --create example-stg -domain example.com -server localhost:3306
    # plesk bin database --create-dbuser stg-example -passwd "MyPass" -domain example.com -server localhost:3306 -database example-stg
  9. Now, we have to edit the /var/www/vhosts/example.com/staging.example.com/wp-config.php and change the values of DB_USER, DB_NAME, and DB_PASSWORD according to the previous step:
    # cat /var/www/vhosts/example.com/staging.example.com/wp-config.php | egrep 'DB_NAME|DB_USER|DB_PASSWORD'
    define('DB_NAME', 'example-stg');
    define('DB_USER', 'stg-example');
    define('DB_PASSWORD', 'MyPass');
  10. Finally, we have to insert the dump into the newly created database example-stg:
    # mysql -u stg-example -p example-stg < example-db.sql

Workaround via RDP

  1. First, we have to connect to the server via RDP.
  2. Then we will create the staging subdomain as seen below:
    C:> plesk bin subdomain --create staging -domain example.com -www-root /staging.example.com -empty-document-root true

    However, if the target instance is not the subdomain of the source instance, we will run the following command instead:

    C:> plesk bin site --create staging.example.com -webspace-name example.com -hosting true -www-root /staging.example.com -empty-document-root true
  3. Next, we will copy the files from the target folder to the source folder. For instance, from C:inetpubvhostsexample.comhttpdocs to C:inetpubvhostsexample.comstaging.example.com.
  4. Then, we will open the wp-config.php file in the document root of the domain we copied. After that, we will replace the source URL with the target URL. We can find the source database details with this command:
    define('DB_NAME', 'example-db');
    define('DB_USER', 'wp_abcdef');
    define('DB_PASSWORD', 'pa$$w0rd');
    define( 'DB_HOST', 'localhost:3306' );
  5. After that, we have to create a dump of the source database via Export Dump under example-db in Databases, followed by example.com in Domains.
  6. Then we will open the database dump via a text editor and replace all ‘example.com’ with ‘staging.example.com’ as seen below:

    Wordpress Toolkit Cloning hangs or stops on a Plesk server

  7. Then, we have to create a new database as well as a database user for the target domain under Domains in staging.examples.com in the Databases section.
  8. Next. We will edit the C:inetpubvhostsexample.comstaging.example.comwp-config.php file and change the values of DB_USER, DB_NAME, and DB_PASSWORD according to the previous step:
    define('DB_NAME', 'example-stg');
    define('DB_USER', 'stg-example');
    define('DB_PASSWORD', 'MyPass');
  9. Finally, we will import the dump into the new database via Domains > staging.example.com > Databases > example-stg > Import Dump.

[Looking for a solution to another query? We are just a click away.]

Conclusion

In essence, the skilled Support Engineers at Bobcares demonstrated what to do when WordPress Toolkit Cloning hangs or stops on a Plesk server.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED