Manually Migrate Sites to Pantheon
Learn how to manually migrate a Drupal or WordPress site to Pantheon
Manually migrate your site to Pantheon when any of the following apply:
If you are using Drupal version 9 or higher, or are moving a Drupal site and want to upgrade to the latest version of Drupal, use one of the following guides instead:
- Your site is Composer-managed: Migrate a Composer Managed Drupal Site from Another Platform or Import Drush Site Archives with Terminus
- Your site is not Composer-managed: Migrate a Drupal Site from Another Platform
- Large Drupal Site Archive: Site archive exceeds the import file size limit of 500MB.
- Large WordPress Site: WordPress site exceeds 500MB.
- Preserve Git History: You'd like to preserve your site's existing Git commit history.
- WordPress Multisite
- Plugin install unavailable on existing WordPress site: For example, if your existing site is hosted on WordPress.com, you'll be unable to install the Pantheon Migrations plugin.
- Local WordPress Site: If your WordPress site is only on your local machine and not yet live.
- Debug Failed Migration: It can be helpful to migrate your code, database, and files separately if the standard migration procedure failed.
The steps outlined below do not work for Composer-based sites. If you have need help migrating a Composer-based site (or any site, for that matter), site migrations are one of the services offered by our Professional Services team.
Before You Begin
To ensure a successful migration, complete the following tasks on the source site before you start:
- Read Platform Considerations
- Upgrade to the latest version of WordPress or Drupal core
- Reference your plugins and/or modules against Modules and Plugins with Known Issues
- Make sure your code is compatible with PHP 7.2 or greater. Review your CMS's PHP version requirements. You may need to adjust PHP versions.
- Clear all caches
- Remove unneeded code, database tables, and files
- Configure SSH keys
Advanced Tips for Successful Migration
.gitignore
Check the contents of your current codebase for existing .gitignore
files. To be compatible with the platform, using the Pantheon version is advised. Otherwise, attempts to import files to restricted paths could break the import process. See the platform-provided versions for WordPress, Drupal 7, and Drupal (Latest Version).
Local Drupal configurations
To preserve the database connection credentials for a site built on a local development environment, and to exclude them from version control, move your settings.php
file to settings.local.php
and add it to .gitignore
so that it will be ignored by Git and included from Pantheon's settings.php
when working on your site locally. Make sure that you can modify it, and restore the protections after the move:
chmod u+w sites/default/{.,settings.php}
mv sites/default/{settings.php,settings.local.php}
chmod u-w sites/default/{settings.local.php,.}
Sites running Drupal 7 must add a settings.php
file that includes settings.local.php
as this file is not bundled on Pantheon.
Create Pantheon Site
Go to your Personal Workspace and click the Migrate Existing Site button:
Enter your current website URL, choose your site type, and click Continue:
Note: It is possible to upload a site running locally by putting in the local url. For example, (
http://localhost
).Name your site and select an Workspace (optional), then click Create Site:
Click the link to manually migrate your site then select Yes to confirm:
Click Visit your Pantheon Site Dashboard:
Now that you have a new site on Pantheon, you're ready to add the major components from your existing site: custom code, files, and the database.
Import Your Code
Your code is all custom and contributed modules or plugins, themes, and libraries. The codebase should not include the wp-content/uploads
(WordPress) / sites/default/files
(Drupal) directory, or any other static assets you do not want tracked by version control.
The codebase for each CMS upstream offered by Pantheon can be found on GitHub:
- Info:Note
If your existing site is already version controlled and you would like to preserve the commit history, import the code from the command line with Git using the instructions below. If you prefer to avoid the command line entirely, we suggest importing the codebase using an SFTP Client such as Transmit or Cyberduck.
SFTP Client
Navigate to Code in the Dev tab of your Site Dashboard. Confirm that Development Mode is set to SFTP.
Click Connect with SFTP to access the credentials for connecting to your preferred SFTP client.
Click Open SFTP Client to open your default local SFTP client, and enter your password when prompted.
If you run into issues, please refer to Pantheon's SFTP documentation.
Do not overwrite WordPress or Drupal core files on your Pantheon site. Upload your existing site's themes as well as plugins or modules to their locations within the root directory (
code
orwp-content
, as shown below).Copy the following directories from your existing site to a matching directory in your new site's
code/wp-content
directory:mu-plugins
plugins
themes
As well as any other folders under
wp-content
that are notwp-content/uploads
.
Copy all files and folders inside the
code/sites
directory, exceptcode/sites/default/files
, from your existing site to a matching directory in your new site'scode/sites
:libraries
modules
profile
themes
vendor
sites
, excludingsites/default/files
.Refer to the "Custom and contrib parts of your Drupal project" section of Basic Directory Structure of a Drupal Project for more details.
Info:NoteYou must prepare the directory and the database if you are using Multisite and want to migrate a sub-site.
Copy the base site to a new directory.
Delete all sites, with the exception of:
sites/{sitename}
: the site you are migratingsites/all
: contains all of your site's modules and themes
Rename
sites/{sitename}
tosites/default
.
Return to the Site Dashboard on Pantheon, and you should see quite a few files ready to be committed to version control. Write a commit message such as "Import existing codebase" then click Commit.
Git
Navigate to your existing site's code directory in a local terminal. If your existing code is not already version controlled with Git, create a repository and add an initial commit:
git init git add . git commit -m "initial commit"
From the Dev environment of the Site Dashboard, set the site's Development Mode to Git:
Copy the SSH URL for the site repository. Do not copy
git clone
or the site name.The URL should look similar to the following:
ssh://codeserver.dev.{site-id}@codeserver.dev.{site-id}.drush.in:2222/~/repository.git
Add your new Pantheon site as a remote destination for your local code repository (replace
<ssh_url>
with the SSH URL copied in the previous step):git remote add pantheon <ssh_url>
Select the appropriate version of Git running on your local machine (
git --version
), then merge the codebase from your new Pantheon site with your existing site's codebase:git pull --no-rebase --squash -Xtheirs pantheon master
git pull --no-rebase --squash -Xtheirs pantheon master --allow-unrelated-histories
The output will resemble:
Squash commit -- not updating HEAD Automatic merge went well; stopped before committing as requested
If you are prompted for authentication, configure an SSH Keys.
Review your current index using
git status
, then commit all changes.git add . git commit -m "Adding Pantheon core files"
Align your local branch with its remote counterpart on Pantheon:
git pull pantheon master --no-rebase
git pull pantheon master --no-rebase --allow-unrelated-histories
Push your newly merged codebase up to your Pantheon site repository:
git push pantheon master
Go to the Code tab of your Dev environment on the Site Dashboard. You should see your site's pre-existing commit history and the most recent commit adding Pantheon's core files.
Add Your Database
The Database import requires a single .sql
dump that contains the site's content and configurations.
Create a
.sql
dump using the mysqldump utility. For example:mysqldump db_name > backup-file.sql
Enter your username and password when prompted to authenticate the command.
- You might want to consider using a terminus credential fetch to avoid entering credentials for future automation steps.
Run the command below to load the dump file back into the server:
mysql db_name < backup-file.sql
You can also use the Pantheon Dashboard to add your site's database.
Select the Dev environment in the Site Dashboard.
Select Database / Files.
Click Import and add your archive accordingly (based on file size):
If your archive is under 100MB, upload the file directly:
Navigate to the MySQL database field > click File > Choose File.
Select your local archive file > click Import.
Note: If you recently imported the database and need to re-import, refresh the page and use a new filename for the database file.
If your archive is less than 500MB, import it from URL:
Navigate to the MySQL database field.
Click URL.
Paste a publicly accessible URL for the
.sql.gz
file > click Import.Info:NoteChange the end of Dropbox URLs from
dl=0
todl=1
to import your archive correctly.
The following instructions allow you to add database archives larger than 500MBs using the command line MySQL client. You can also use a GUI client like Sequel Ace or Navicat. For more information, see Accessing MySQL Databases.
Navigate to the Pantheon Site Dashboard.
Open the Dev environment.
Click Connection Info.
Copy the Database connection string.
The Database connection string will look similar to this:
mysql -u pantheon -p{random-password} -h dbserver.dev.{site-id}.drush.in -P {site-port} pantheon
cd
into the directory containing your.sql
file in your terminal.Paste the connection string and append it with:
< database.sql
.Your command will look like:
mysql -u pantheon -p{random-password} -h dbserver.dev.{site-id}.drush.in -P {site-port} pantheon < database.sql
If you encounter a connection-related error, the DB server could be in sleep mode. To resolve this, load the site in your browser to wake it up, and try again. For more information, see Troubleshooting MySQL Connections.
The
.sql
file is imported to the Dev environment after you run the command.
Migrate Your Files
Files refer to anything within sites/default/files
for Drupal or wp-content/uploads
for WordPress, which typically includes:
- Uploaded images
- Generated stylesheets
- Aggregated scripts
Files are not under Git version control and are stored separately from the site's code. You must create and archive of your files and export it before you can upload it.
Export Your Files
Export a tar.gz
or .zip
file of your files directory:
Navigate to your WordPress site's root directory to run this command, which will create an archive file in your user's home directory:
cd wp-content/uploads
tar -czf ~/files.tar.gz .
Navigate to your Drupal site's root directory to run this command, which will create an archive file in your user's home directory:
cd sites/default/files
tar -czf ~/files.tar.gz .
Upload Your Files
You can use the Pantheon Dashboard, SFTP, or Rsync to upload your site's files.
Pantheon Dashboard
- Go to the Site Dashboard, select the Dev environment, select Database / Files, and click Import to add your archive accordingly (based on file size):
Select the Dev environment in the Site Dashboard.
Select Database / Files.
Click Import and then add your archive (based on file size) by following the steps below.
If your archive is under 100MB, upload the file directly:
Navigate to the Archive of site files field > click File > Choose File.
Select your local archive file > click Import.
If your archive is less than 500MB, import it from URL:
Navigate to the Archive of site files field > click URL.
Paste a publicly accessible URL for the archive > click Import.
Info:NoteYou must change the end of Dropbox URLs from
dl=0
todl=1
to import your archive correctly.
We recommend using the Terminus Rsync Plugin to transfer a large number of files. This allows you to avoid using multiple command line arguments and specific directory structures, which make it easy to introduce mistakes.
Rsync only transfers the new changes to the directory after the initial rsync runs. This minimizes the time a site is in an unpredictable state (or offline) during the final step of migration, and allows you to bring over only new content rather than re-copying every single file.
Run the following command to sync your current directory to Pantheon:
terminus rsync . my_site.dev:files
Run the following command if you experience interrupted transfers due to connectivity issues, which can occur when using Rsync manually.
ENV='dev' SITE='SITEID' read -sp "Your Pantheon Password: " PASSWORD if [[ -z "$PASSWORD" ]]; then echo "Whoops, need password" exit fi while [ 1 ] do sshpass -p "$PASSWORD" rsync --partial -rlvz --size-only --ipv4 --progress -e 'ssh -p 2222' ./files/* --temp-dir=../tmp/ $ENV.$SITE@appserver.$ENV.$SITE.drush.in:files/ if [ "$?" = "0" ] ; then echo "rsync completed normally" exit else echo "Rsync failure. Backing off and retrying..." sleep 180 fi done
Your files will be uploaded to your Pantheon site's Dev environment. If an error occurs during transfer, the command waits 180 seconds before continuing where it left off.
SFTP
Follow the SFTP instructions in the Large File Transfers with rsync and SFTP documentation.
rsync
Follow the Transfer Files with rsync instructions in the Large File Transfers with rsync and SFTP documentation.
Final Migration Steps
You should now have all three of the major components of your site imported into Pantheon.
Clear your caches on the Pantheon Dashboard.
Confirm that everything looks and behaves as expected.
Run the terminus site:import:complete <site_name> command to complete the import process.
Troubleshooting
fatal: Not possible to fast-forward, aborting.
This error may occur when trying to merge Pantheon's codebase into your existing repository as described earlier on this page in (step 5 of importing your code from the command line:
Not possible to fast-forward, aborting.
Depending on your Git version, you may see the following error instead:
fatal: refusing to merge unrelated histories
If you see this, it is possible your local Git configuration is disallowing non-fast-forward merges:
[pull]
rebase = TRUE
ff = only
In this case, you will want to remove ff = only
from your .gitconfig
file and try the merge command again.