Migrating Drupal 7 Sites to Pantheon

It is best to migrate a site manually to Pantheon.  They do offer an automatic migration now, but it is best to do this more granular as it causes less problems.  

Follow the instructions along here https://pantheon.io/docs/migrate-manual to manually migrate to Pantheon. 

Old Server

If you have SSH Access

  1. SSH into the server
  2. Create a folder one up from the web root, call it BACKUP
  3. Run the following:

    cd /path/to/BACKUP
    tar czf backup.tgz /path/to/drupal_site/
    cd /path/to/drupal_site/
    drush sql-dump > /path/to/BACKUP/database.sql
    1. Note, sometimes the sites have a ginormous file directory.  It is best to exclude the files directory in this case and SFTP or rsync the files down.  To exclude a directory:

      tar czf backup.tgz /path/to/drupal_site/ --exclude "/path/to/drupal_site/sites/default/files"
    2. If drush isn't installed, you can install it or run this for the DB

      cd /path/to/drupal_site/
      cat sites/default/settings.php (grab the database connection settings)
      mysqldump -u USERNAME -p'PASSWORD' DATABASENAME > /path/to/BACKUP/database.sql
  4. Exit out of the server and run this locally.

    scp USERNAME@IP-ADDRESS:/path/to/BACKUP/backup.tgz ~/Downloads
    scp USERNAME@IP-ADDRESS:/path/to/BACKUP/database.sql ~/Downloads


If you don't have SSH Access

This process is much slower, prepare to wait a long time.

  1. To grab the code and files via SFTP and download them locally
  2. Grab the Database with backup & migrate

Alternatively, if the server has backups, use those and see if they have what you need.

Code


  1. Basically you want your code base to look like this going into pantheon:

    ├── includes
    ├── index.php
    ├── misc
    ├── modules
    ├── profiles
    ├── scripts
    ├── sites
        └── all
           ├── modules
           └── themes
        └── default
           └── settings.php
    └── themes
  2. Usually the best way to migrate a site it to create 2 folder locally:
    1. Core: which contains the above structure
    2. Extra: which has all the files and folders that don't fall into the above structure paradigm
  3. Once you have this site up, git clone your new repo down that you created.
    1. Copy in the sites/all folders that was split up form above, push that up.
  4. Then you have to decide what from the extra folder you have to put in
    1. typically put back in all the libraries in sites/all
    2. Should move any files or file typically in core to sites/default and symlink
      1. This is a case by case basis

Database

If the database tar is less than 100MB, then use the GUI database import function

If not, unzip it, grab the mysql connection string from your pantheon dashboard, and run this command:

mysql -u pantheon -p{random-password} -h dbserver.dev.{site-id}.drush.in -P {site-port} pantheon < /path/to/database.sql


Files

If the file tar is less than 100MB, then use the GUI files import function.

If not, unzip it, grab the full SFTP connection string from your dash and do the following:

  1. Remove the sftp -o Port=2222 at the beginning of the connection string
  2. Add this to the beginning rsync -rlvz --size-only --ipv4 --progress -e 'ssh -p 2222' /path/to//files/
    1. Remember to change the actual path to your files
  3. Add this to the end of the string  :files/
  4. Your string should look like this:

    rsync -rlvz --size-only --ipv4 --progress -e 'ssh -p 2222' /path/to/files/ PANTHEON-ENV.PANTHEON-SITE@appserver.PANTHEON-ENV.PANTHEON-SITE.drush.in:files/
    1. Note: Pantheon has a script on their Migration page, I have never tried it, but this does basically the same thing.


Pantheon configurations

pantheon.yml defines PHP version, Drush version, protected paths, nested docroot, and Quicksilver platform hooks. Items such as Nginx configuration or Varnish settings are not editable.

See https://pantheon.io/docs/pantheon-yml on how to change these and here is an example pantheon.yml.

Security Updates

You can't use Drush to apply security updates to a Drupal 7 site on Pantheon.

If you are not using Composer, you may need to pull in security updates through the upstream. Pantheon requires a Pressflow based Drupal 7 distribution which can be applied by pulling in upstream changes from the Drops 7 distribution:  https://github.com/pantheon-systems/drops-7 

If git gives an error preventing you from "merging unrelated histories", you may need to use this command to pull the upstream changes for a security update:

git pull --no-rebase --squash -Xtheirs drops-7-upstream master --allow-unrelated-histories

The command above is the same one used (except the remote is to the Drops-7 upstream instead of Pantheon) when initially migrating to Pantheon if you opted to preserve pre-existing git history (https://pantheon.io/docs/migrate-manual). 

Lando

Lando can be a shortcut for migrating sites that require manual migration. Lando can also be helpful if you only have a copy of the database and files, and don't have access to the old server to publish the site archive over a remote URL. 

Follow the instructions for creating a Pantheon recipe here: https://docs.lando.dev/config/pantheon.html#getting-started.

Then you can use the lando push command to push files which will rsync the files to the correct directory in your site on Pantheon.