Transfer a Website
Overview
Transferring a website allows you to copy an existing WordPress® website from a source server to your WP Squared server. The source server is where the website contents are currently. You can either transfer your website using the Transfer Tool or with the manual instructions provided below.
Transfer your website using the Transfer Tool
You can use the WHM Transfer Tool to copy a cPanel & WHM WordPress site to WP Squared. To transfer accounts, you must have root
-level privileges.
It is important to note that the following features will not work in WP Squared:
- Calendars and Contacts
- Custom Locales
- Email Accounts and Settings
- FTP Accounts
- Linked Node Configurations
- PostgreSQL Databases
- Teams and Subaccounts
- Web Calls
- Web Disk Accounts
- Websites Without WordPress
Start the transfer process with the following steps:
- Provide the following information for the source server:
- IP address and remote SSH port.
- Root or other
root
-level user and password. - Authentication method - either username and password or SSH key.
- Security - Restricted Restore - This should not be considered an effective security control.
- Advanced - We recommend leaving the default settings for this section, unless you understand the settings.
- Click the Scan Remote Server button.
You may receive a notice that the source server is not running the same major version as the WP Squared server. You can proceed with caution if your source server version is older than your target, WP Squared, server. If the source server is newer than the WP Squared server, the transfer will be blocked.
- Select the accounts, packages, and service configurations you want to transfer.
You have the option to select any or all of the accounts, packages, and service configurations from the source server. Some packages or service configurations may not work properly on a WP Squared server.
- Click the Copy button.
Once you start the transfer process, it cannot be stopped. The process will continue if you navigate from the window.
- Review the Transfer Summary.
Make sure to read any warnings given for the transferred accounts.
Manually Transfer a WordPress Website to WP Squared
A manual transfer takes a website that already exists as a WordPress site and moves its contents to a WP Squared server through SSH, using the command line and API calls. You will need SSH access to both the source server and the WP Squared server. Some of the steps below will require root
-level access. To complete this process, follow the steps below:
Prepare the data on the source server
Login to the source server via SSH to download and transfer the data:
ssh user@source-server
Set the variables for your SSH session. This will allow the shell to input these variables in future commands, rather than providing them manually each time. Enter the following on the command line, where
~/public_html/source-website.com
represents your website’s root directory and~/source-website.tar.gz
represents the temporary file for the website’s content:#Run as user export local_docroot=~/public_html/source-website.com export website_tarball=~/source-website.tar.gz
Create a tarball with website content:
cd $local_docroot; tar cvzf ${website_tarball} .
Set a path for using WP-CLI installed by WP Toolkit (
wp-cli
):export wp_cli="/usr/local/bin/php /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/boot-fs.php"
If your source server is a cPanel & WHM server, you can use its wp-cli
, or adjust the command to the path where wp-cli
is installed.
To confirm that the
wp-cli
path is set correctly, run the following command:${wp_cli} --version
This command will return the WP-CLI version number, (
WP-CLI 2.9.0
), when the path is set correctly.To dump the MYSQL database using the WP-CLI, run the following command:
${wp_cli} db export --path=$local_docroot
When completed, you will receive a success message like the following:
Success: Exported to 'mydomain_wp_vsyc5-2024-08-01-385bf1f.sql'.
Confirm that you created the files needed to transfer your website.
export website_sql_dump='mydomain_wp_vsyc5-2024-08-01-385bf1f.sql' ls ${website_tarball} ${website_sql_dump} /home/mydomain/source-website.tar.gz mydomain_wp_vsyc5-2024-08-01-385bf1f.sql
Prepare the destination server
Create a WP Squared account
You can either create a new user account or add your website to an existing user account.
Add your domain to a new WP Squared user account
To create a new user, you will need root
-level permissions on the WP Squared server. The following command will create a user, skipping the website creation so you can transfer your website without errors. You should replace $username
and $domain.tld
with the username you want to create and the domain you want to transfer.
whmapi1 createacct username=$username domain=$domain.tld skip_wp_install_on_domain=1
Transfer your information from the source server to the destination server
After you have a user on the WP Squared server, you can transfer the files you previously created. On the source server, where ${website_tarball}
and ${website_sql_dump}
are the filenames you created in the previous steps, run the following command:
scp ${website_tarball} ${website_sql_dump} user@destination-server:
Setup the WP Squared website
- Login to the WP Squared (destination) server via SSH with the following command:
ssh user@destination-server
- Create the MySQL database and user
Before you import your website data, the MySQL database must be created and set up. Run the following commands on the wp-cli
to create the database and user for your WP Squared website:
export database_suffix="wp_$(openssl rand -base64 16 | tr -d -c '[:lower:][:digit:]' | cut -b 1-5)"
export database_user_suffix="wp_$(openssl rand -base64 16 | tr -d -c '[:lower:][:digit:]' | cut -b 1-5)"
export database_password="$(openssl rand -base64 20 | tr -d -c '[:alnum:]')"
export database=${USER}_${database_suffix}
export database_user=${USER}_${database_user_suffix}
You then need to create the database and user for your database, by running the following commands:
uapi Mysql create_database name=${database}
uapi Mysql create_user name=${database_user} password=${database_password}
uapi Mysql set_privileges_on_database user=${database_user} database=${database} privileges=ALL
- Restore the MySQL dump from the source server
Using the database and user above, restore the MySQL dump from your source server. In the example below, replace the <...>
with the filename of your MySQL dump. You can import the .sql
file using the following command:
export website_sql_dump=<...>
mysql -u ${database_user} -p${database_password} ${database} < ${website_sql_dump}
- Import the website data from the source server
The data that you previously saved to a tarball, will need to be extracted into your WP Squared directory. Once extracted, you will need to remove the .htaccess
file. Run these commands as the WP Squared user. You can extract the website and remove the file using the following commands:
export domain=source-website.com
export local_docroot=~/public_html/${domain}
tar xvzf ${website_tarball} -C ${local_docroot}
rm -f ${local_docroot}/.htaccess
- Update the MySQL information
To update the MySQL information for your newly imported website, use the wp-cli
or by manually editing the wp-config.php
file. To use the wp-cli
, run the following command:
export wp_cli="/usr/local/bin/php /usr/local/cpanel/3rdparty/wp-toolkit/plib/vendor/wp-cli/vendor/wp-cli/wp-cli/php/boot-fs.php"
Confirm that the wp-cli
is setup correctly on the destination server using the following command:
${wp_cli} --version
You should receive a response similar to the following:
WP-CLI 2.9.0
Add the following information to manually set the database details in the wp-config.php
file:
${wp_cli} config set DB_NAME ${database} --path=${local_docroot}
${wp_cli} config set DB_USER ${database_user} --path=${local_docroot}
${wp_cli} config set DB_PASSWORD ${database_password} --path=${local_docroot}
${wp_cli} config set DB_HOST localhost:3306 --path=${local_docroot}
- Register your website
To complete the setup of your new WP Squared site, you will need to register the website. The following actions happen when you run the UAPI call to register your website:
- The domain is assigned to the user.
- The web server virtual host is created.
- Any additional plugins provided by WP Squared are installed and listed in the default set (such as AccelerateWP).
- The website shows up in the WP Squared Dashboard.
Register your website by running the following command, where {domain} is your domain name:
uapi WP add_domain domain=${domain} use_existing_wp_installation=1
This process may take a few seconds to finalize.
- Remove the tarball and MySQL dump from your servers
To prevent your website from using too much disk space, be sure to remove these large files from your server. You can run the following command to remove both of these files:
rm -f ${website_tarball} /incoming/${website_sql_dump}
- Test your website
You can verify that your site has imported correctly in multiple ways. You can use the curl
command on the command line to check the connection to the website from the destination server, or you can check the website’s title. You can also edit the /etc/hosts
file on your computer to browse the website from your browser. In these examples, domain.com
represents your domain name.
Use one of the following curl commands on the destination server to check your site from the command line:
Checking the connection with the curl
command:
export domain=<domain.com>
curl -s -k --resolve ${domain}:443:$(hostname -i) https://${domain}
Checking the website’s title with the curl
command:
export domain=<domain.com>
curl -s -k --resolve ${domain}:443:$(hostname -i) https://${domain} | grep '<title>'
To browse your website from your browser, add the following line to your etc/hosts
file:
# add a line to /etc/hosts with the source IP and your test domain
1.2.3.4 domain.com
Now you should be able to browse domain.com
from your favorite browser.
- Update your DNS entries
Now that you have confirmed your website is working correctly, you will need to update the DNS for your website. We recommend you update the NS record to point to the new server’s IP, but if you have multiple websites in the same zone, you can just adjust the A record.
Setup the WP Squared website with a script
The attached script is available to set up the destination server’s WP Squared website. Download and copy the wp-manual-transfer.sh
file to a location that is accessible by the WP Squared user account with the following changes:
- Replace
domain.com
with the domain name for the transferred website. - Replace
~/domain.com.tar.gz
with the path to the website tarball on the WP Squared server. - Replace
~/domain.com.sql
with the path to the sql dump on the WP Squared server.
Run the script with the following command:
bash wp-manual-transfer.sh --domain "domain.com" --website-tarball ~/domain.com.tar.gz --sql-dump ~/domain.com.sql
Use the --help
option to see all available options for the script.