Archived video

This video is archived and won't be updated. We're keeping it online for now as a courtesy.

Alternate resources: 

Importing a Site into Pantheon

Video loading...

  • 0:00
    Manage Drupal Sites with Pantheon Importing a Site into Pantheon Addison Berry
  • 0:09
    So let's talk about importing a site into Pantheon
  • 0:12
    instead of creating a new site from scratch. What do you do when you have an existing site
  • 0:17
    that you want to bring into the Pantheon service?
  • 0:22
    In this lesson what we're going to do is we're going to get an overview
  • 0:26
    of how the importing with Pantheon works. We'll talk about the components of a site.
  • 0:30
    We'll review the import processes. There's more than one way
  • 0:34
    to import a site into Pantheon. And then we'll look at ways to create
  • 0:40
    the site archive that you would need to then later import into Pantheon.
  • 0:46
    So your base components of a site—you have 3 things that you need to have to create a Drupal site.
  • 0:53
    You have your codebase, which is core, custom, contrib. That's all the actual code,
  • 0:59
    modules, projects that you download. The database—once you start building your site
  • 1:04
    you create your database that has your content and some configuration.
  • 1:07
    And then, of course, you have your files folder, and this is anything
  • 1:11
    that's under sites/default/files. So things that you upload for using a file field,
  • 1:16
    but also if you have image styles or you're generating your stylesheets for your theme
  • 1:21
    and that kind of a thing. All of that stuff is happening in your files directory.
  • 1:26
    Now to do an import in Pantheon you have a few things that you need to keep in mind
  • 1:33
    for this to work properly for you. First of all, Drupal must be in the root directory.
  • 1:38
    We'll talk a little bit more about creating archives in a minute.
  • 1:42
    But when you create the archive, Drupal has to be in that root directory.
  • 1:45
    You can't have it buried under user name, sites, public HTML. You can't have all these directories
  • 1:52
    to just sort of nest it in. You want to have Drupal in the top level directory
  • 1:57
    for the archive that you're going to be importing. You also need to have your files
  • 2:01
    located at sites/default/files. That's where it's expecting to find them,
  • 2:05
    and when it's putting the site together, it's going to look for those files there
  • 2:10
    in order for it to work. And we can talk about other ways of dealing with files
  • 2:15
    if that's not the case, and they're very advanced ways. But for your basic import,
  • 2:19
    that's what you want to have. Now it's also important to understand
  • 2:23
    the size restrictions you're going to have with Pantheon.
  • 2:26
    So if you have your entire site archive, which is all three of those components—
  • 2:31
    right?—so your code, your database, and your files directory.
  • 2:35
    If all of that is less than 100 MB, pretty small site, then you can just use the dashboard UI
  • 2:41
    and actually upload, just like a regular upload form. If the file is up to 500 MB
  • 2:48
    in size, then instead of actually uploading through that UI, because that will take a long time,
  • 2:54
    you can actually enter a remote URL. So you would upload the file
  • 2:59
    somewhere on the Internet. You can use something like Dropbox
  • 3:02
    or some other server. And then once you have that file location,
  • 3:06
    you would give that file location to Pantheon, and then it could pull the file over
  • 3:10
    and go ahead and get you set up that way. If your site archive—
  • 3:14
    if all three of those components combined is greater than 500 MB,
  • 3:17
    then you are probably going to want to sync those components over
  • 3:24
    instead of just trying to upload them. And this just has to do with uploads
  • 3:28
    taking a long time on the Internet, and that can create hiccups.
  • 3:31
    So you would create a new site, and then you would sync your database,
  • 3:36
    your files, and your codebase over using other tools, which we'll look at here in a second.
  • 3:41
    So our basic import process—basically this is for sites that are under 500 MB—
  • 3:48
    kind of your standard backup process, as it were in a sense.
  • 3:52
    You're going to put the source site into maintenance mode
  • 3:54
    so that changes aren't happening while you create the archive.
  • 3:57
    You want to clear all your Drupal caches. You don't need that stuff in there
  • 4:01
    to take up space. You're going to export the Drupal site archive.
  • 4:05
    And then you would just import it again via the UI—the Pantheon dashboard—
  • 4:10
    or you can use a Pantheon tool called Terminus,
  • 4:14
    which will be a terminal command line tool that you can use
  • 4:17
    to instantiate the import. And we'll be looking at those in a lot more detail later.
  • 4:23
    The key here, of course, is creating that site archive to start with. So when we talk about creating
  • 4:30
    a site archive, what we're talking about is getting all of those various components together
  • 4:34
    into one place so that you can import them. There are 2 ways of handling
  • 4:39
    file uploads essentially in Pantheon. One is creating a single file—
  • 4:45
    a single site archive file. And you can do that with Backup and Migrate module,
  • 4:49
    or you can use Drush with the archive-dump command.
  • 4:53
    Both of those will give you one file that contains the codebase, the database,
  • 4:58
    and the files directory in one file. That makes it super easy and simple
  • 5:02
    to figure out what's going on when you go to import it.
  • 5:06
    Alternatively in Pantheon you can also do it in 3 files.
  • 5:11
    So you separate your exports for each of those 3 components
  • 5:15
    and then you can upload those individually in UI or using Terminus.
  • 5:20
    To create separate exports for those things, normally the tools you would use
  • 5:25
    would be mysqldump to create a database dump. You can also do this through the UI
  • 5:30
    in something like phpmyadmin. And then you want to compress the files
  • 5:35
    because you want to get them as small as possible for your code and for your files.
  • 5:39
    And so the standard command line tool for compressing those things is tar.
  • 5:43
    So using these tools and whichever makes sense or you're most comfortable with
  • 5:49
    would be how you would just create a site archive of files that you can then upload.
  • 5:53
    Now, for a more advanced process—we have those 2 ways of getting files uploaded.
  • 6:00
    If you have more advanced needs, you can also do syncing instead of actual uploading.
  • 6:08
    So in this import process, which is something you would definitely need to use
  • 6:14
    if something's greater than 500 MB. You can also, of course, use this
  • 6:18
    for any site that you want. So it's a tool that's available to you.
  • 6:24
    Most of the time people only use it for larger sites. In this instance what you do
  • 6:27
    is you actually would create a new site like you've done previously
  • 6:30
    in Pantheon, and then you would actually sync those raised components
  • 6:34
    to that new site and sort of update it using various command line tools
  • 6:38
    that won't get as hung up with the download/upload thing that happens on the Internet.
  • 6:45
    So for the database, you can use MySQL command line
  • 6:50
    to sync the databases between your existing site and the new Pantheon site you've created.
  • 6:55
    For files you can use rsync. So that will grab files and move them across to the new site.
  • 7:01
    For code, if you have your code in Git, you can just use Git
  • 7:08
    to actually put that code up into your Pantheon site.
  • 7:11
    The new site will have been created with a basic Drupal site.
  • 7:15
    You can replace that by pushing your own Git code into that repository.
  • 7:20
    And this is one of those things that using Git to sort of replace what Pantheon creates for you
  • 7:27
    out of the box, again, is useful for large sites if you have a lot of stuff going on in the codebase.
  • 7:32
    But also if you have an alternate upstream, if you have different code,
  • 7:36
    or if you want to retain the Git history you had previously—like you don't want to start
  • 7:40
    with a brand new fresh slate on Pantheon—that's when you would want to use Git
  • 7:45
    and make sure you push your existing Git code up into Pantheon.
  • 7:49
    Those are the various ways that you can import into Pantheon.
  • 7:55
    As you see it's very flexible. It gives you a lot of different options
  • 7:58
    depending on your needs. In this lesson, we reviewed the components of a site—
  • 8:02
    so your database, your codebase, and your files.
  • 8:08
    And then we talked about these import processes, and essentially you have
  • 8:12
    kind of 3 different ways of doing this. You have a single file archive.
  • 8:17
    So put everything into just one single file and you will import that file.
  • 8:21
    Or you can split those files into 3 separate files
  • 8:25
    for each component and then upload those individually.
  • 8:28
    Or you can create a new site and then sync your data from your existing site
  • 8:34
    into the new Pantheon site to get everything just the way that you want it.
  • 8:37
    So the key here is to know what tools you're going to need to use to create
  • 8:43
    your site archive, and when you come to import, how you're going to be able
  • 8:48
    to import those things. And largely that's going to depend on the actual size of your site.
  • 8:55
    And additionally it could just depend on the tools you have available and the needs that you have
  • 9:00
    that you want to use. Pantheon's flexible enough to let you do it
  • 9:04
    however it is that you need to do it.

Importing a Site into Pantheon


In the last tutorial we created a new site from scratch on Pantheon. What if you already have a site that you want to move to Pantheon though? In this tutorial we'll provide an overview of how to import your site into Pantheon. We'll discuss what the various parts of a site are that you need to work with, and some important points about what Pantheon expects. We'll also discuss the different methods you can use to import your site and the guidelines for which method to use, especially when working with large Drupal sites.

Sponsored by Pantheon

Log in or sign up to download companion files.
Additional resources: