Articles in this section

WP Toolkit Cloning hangs or stops after 60 seconds on a Plesk server

kb: technical Plesk ext: wptk ABT: Group A

Applicable to:

  • Plesk

Symptoms

  • WordPress instance example.com cannot be cloned, process hangs at 51% or fails with the error:

    PLESK_ERROR: 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.

  • Below errors can be found in /var/log/plesk/panel.log:

    CONFIG_TEXT: [2019-06-05 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.

  • PHP handler of the main domain of the subscription is PHP 7.2 or 7.3;

Cause

Issue in the function `search-replace` from WP-CLI utility in combination with PHP 7.2 & 7.3.

Resolution

Two workarounds are possible:

Via Plesk web interface
  1. Log into Plesk.

  2. Create the subdomain where to clone the instance (E.G: staging.example.com).

  3. Go to Domains > staging.example.com > PHP Settings and switch PHP version to 7.1 for example.

  4. Go to WordPress > example.com > Clone
    Check Use existing domain or subdomain and select the new domain staging.example.com as Target in the list, the database name can be optionally changed.

  5. Once cloning finishes, go again to Domains (Or as customer: Websites & Domains) > staging.example.com > PHP Settings and switch back the PHP version to 7.2.

If cloning still fails, clone WordPress manually:

Via command line (SSH)
  1. Connect to the server via SSH.

  2. Create the subdomain where to clone the instance (E.G: staging.example.com):

    # plesk bin subdomain --create staging -domain example.com -www-root /staging.example.com -empty-document-root true

    Note: In case the target instance is not a subdomain of the source instance, run this command instead:

    # plesk bin site --create staging.example.com -webspace-name example.com -hosting true -www-root /staging.example.com -empty-document-root true

  3. Copy the files from the source instance to the target folder:

    # cp -pr /var/www/vhosts/example.com/httpdocs/* /var/www/vhosts/example.com/staging.example.com/

  4. Replace the source URL by the target URL in all these files:

    # 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. Find the source database details:

    # 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. And make a dump of this database:

    # mysqldump -u wp_abcdef -p example-db -h localhost > example-db.sql

  7. Replace all strings example.com by staging.example.com in the dump:

    # sed -i 's/example.com/staging.example.com/g' example-db.sql

  8. Create the new database for the target:

    # plesk bin database --create example-stg -domain example.com -server localhost:3306

  9. Create a user for this database:

    # plesk bin database --create-dbuser stg-example -passwd "MyPass" -domain example.com -server localhost:3306 -database example-stg

  10. Edit the file /var/www/vhosts/example.com/staging.example.com/wp-config.php and change the values of DB_NAME, DB_USER and DB_PASSWORD accordingly with the previous step (+ DB_HOST if needed):

    # 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');

  11. Insert the dump into the newly created database example-stg:

    # mysql -u stg-example -p example-stg < example-db.sql

Via RDP (for Windows)
  1. Connect to the server via RDP.

  2. Create the staging subdomain:

    C:\> plesk bin subdomain --create staging -domain example.com -www-root /staging.example.com -empty-document-root true

    Or, in case the target instance is not a subdomain of the source instance, run this 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. Copy the files from the source instance to the target folder, e.g. from C:\inetpub\vhosts\example.com\httpdocs to C:\inetpub\vhosts\example.com\staging.example.com.

  4. Open wp-config.php file in the document root of the copied domain and replace the source URL with the target URL, if it is mentioned.
    Find the source database details:

    CONFIG_TEXT: define('DB_NAME', 'example-db');
    define('DB_USER', 'wp_abcdef');
    define('DB_PASSWORD', 'pa$$w0rd');
    define( 'DB_HOST', 'localhost:3306' );

  5. Create a dump of source database in Domains > example.com > Databases > example-db > Export Dump.

  6. Open the database dump with a text editor and replace all strings 'example.com' by 'staging.example.com':

  7. Create a new database and database user for the target domain in Domains > staging.example.com > Databases.

  8. Edit the file C:\inetpub\vhosts\example.com\staging.example.com\wp-config.php and change the values of DB_NAME, DB_USER and DB_PASSWORD accordingly with the previous step:

    CONFIG_TEXT: define('DB_NAME', 'example-stg');
    define('DB_USER', 'stg-example');
    define('DB_PASSWORD', 'MyPass');

  9. Import the dump into the newly created database in Domains > staging.example.com > Databases > example-stg > Import Dump.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.