Symptoms
-
WordPress instance example.com cannot be cloned, process hangs at 51% or fails with the 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
:[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
-
Create the subdomain where to clone the instance (E.G: staging.example.com).
-
Go to Domains > staging.example.com > PHP Settings and switch PHP version to 7.1 for example.
-
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. -
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)
-
Connect to the server via SSH.
-
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
-
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/
-
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
-
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…