我已经做了这件事,所以我可以测试插件更新。我编写了一个shell脚本(bash)来创建子目录并复制文件。然后,我利用WP-CLI 用于创建wp配置文件、导出/导入数据库以及在DB中搜索和替换站点名称的命令。这是我的脚本,细节改为;您的网站;
#!/bin/bash
shopt -s expand_aliases
alias wp=~/bin/wp-cli.phar
wp --version
sourceDir=~/public_html
destDir=~/public_html/test/
### Delete existing files in $destDir
read -p "Deleting all files in $destDir ...Continue? (y/n): " -n 1 -r
echo
if [[ $REPLY = [yY] ]]; then
#rm -rf "$destDir/".[!.]* "$destDir/"*
rm -rf "$destDir"
mkdir "$destDir"
if [[ -z $(ls -A "$destDir") ]]; then
echo "Destination cleaned"
else
echo "Error: destination not empty"
exit 2
fi
else
echo "Script aborted by user"
exit 0
fi
### Clone source files
echo "Starting clone of source files"
cp "$sourceDir/"* "$destDir"
cp "$HOME/bin/.htaccess" "$destDir"
cp -R "$sourceDir/wp-"* "$destDir"
echo "Source files transfered"
### Create wp-config.php
cd "$destDir"
rm ./wp-config.php
wp config create \\
--dbname=test_yoursite --dbuser=test_user --dbpass=\'yoursitePass\' --dbprefix=wp_ --extra-php <<EOL
@ini_set(\'display_errors\', \'Off\');
@ini_set(\'log_errors\', \'On\');
define(\'WP_DEBUG\', true);
define(\'WP_DEBUG_LOG\', true);
define(\'WP_DEBUG_DISPLAY\', false);
define(\'SAVEQUERIES\', false);
define(\'WP_MEMORY_LIMIT\', \'1024M\');
define(\'WP_POST_REVISIONS\', 10);
define(\'WP_MEMORY_LIMIT\', \'128M\');
define(\'WP_AUTO_UPDATE_CORE\', \'minor\');
EOL
### Clone DB and update site name
echo "Starting clone of Database"
cd "$destDir"
wp db export prod.sql --path="$sourceDir"
wp db reset --yes
wp db import prod.sql && rm -f prod.sql
wp option update siteurl http://test.yoursite.com
wp option update home http://test.yoursite.com
wp option update blogname \'Yoursite TEST\'
echo "Searching and replacing domain name. Please wait this takes several minutes"
wp search-replace \'yoursite.com\' \'test.yoursite.com\' \'wp_posts\'
wp rewrite flush
### Disable plugins
wp plugin deactivate w3-total-cache
wp plugin deactivate wordfence
echo "Done"
exit 0
还有免费或付费的插件,如
Duplicator 它可以以半自动化的方式克隆您的站点。。。可能你已经在使用了。
还有一些网站托管公司,包括站点克隆功能(临时站点);例如WP Engine, SiteGround 和其他人。