Reply to comment
DrupalCampLA 2009 - Site Migration Basics
This session is co-presented by Nicole Bluto and Rain Breaw.
Rain will be at the Drupalchix table from 3:30 to 5:30 pm this afternoon for additional questions.
Software and Drupal Modules that will help with this session:
MAMP – http://www.mamp.info
Mac-based apache/mySQL/php setup used for running a “localhost” web environment, enabling you to build and test a site on your local machine.
XAMPP - http://www.apachefriends.org/en/xampp.html
An apache/mySQL/php + option for Windows, Linux and Mac operating systems.
Backup & Migrate Module
http://www.drupal.org/project/backup_migrate
Poormanscron Module
http://www.drupal.org/project/poormanscron
Secure Site Module
http://www.drupal.org/project/securesite
Session Outline
A. Assumptions: This session assumes that you have a drupal site in a development environment or other environment that needs to be moved.
B. Considerations: It is important to consider the target environment (where you want to move your site to) in relationship to your development environment.
- Does your development environment match your target environment?
- Linux
- Apache
- PHP the same version
- MySQL
- Same drupal version
C. The Backup and Migrate Module:
- Download the module from http://drupal.org/project/backup_migrate
- Install it onto your development site.
- Unzip the file and place it in your /sites/all/modules folder or place the zipped file in your /sites/all/modules folder and unzip it there. Discard zip file.
- Turn on the module in your modules directory. Find it at Administer →Site Building →Modules (admin/build/modules) under the “other” tab
- Save
D. Configuring The Module on your Dev Site
- Find the module configuration settings at Administer → Content Management → Backup and Migrate (admin/content/backup_migrate)
- Backup/Export database
- Default settings for table exclusions and data exclusions are usually sufficient. If you have errors, you may want to exclude certain tables. The data exclusions streamline your file size by eliminating unnecessary data. It is not recommended that you exclude any tables. You might, however, consider excluding data from all tables that are “logs,” “cache” data, “devel” data (if you are using the devel module) and “watchdog” if you are looking to decrease size or clean up excess development data for the first migration/launch.
- Backup File Name can be changed. You can use different tokens. You are provided with a list of tokens that can be used under the “replacement patterns” tab.
- Compression: You can compress the files to make them smaller or not. Your preference.
- Destination: You can choose to have it downloaded to your computer or saved to the files directory. I would recommend doing both.
- Timestamp Format is provided. If you would like a different format, it must be a PHP format string and a link to the date page for PHP is provided if you want to look it up. http://us.php.net/manual/en/function.date.php
- Restore/Import database allows you to browse your computer for a database file and use it to restore your database. You can also choose a backup from your “saved backups directory” by clicking the link at the bottom of the page. You will be able to choose from manual or scheduled backups.
- Saved Backups shows you your manual backups and your scheduled backups. You can download them, delete or restore.
- Backup Schedule allows you to choose how often to back up your database and also how many backup files to keep. These backups will live in your live files directory, so it is recommended that you also do manual backups that you keep locally (in case your entire site goes down, including all of your live files).
E. Copy your sites folder from your development environment
F. Set Up Your Target Environment
- Place a fresh Drupal download in your target environment
- Replace the “sites” folder with your copy of your sites folder from your development environment.
- In phpMyAdmin (on your live server) Create a new database
- type in a name in the create a new database field and click create
- Click privileges tab and create a new user with all privileges if necessary. Make a password for the user and add log in information. Click “go”
- Import your database
- Click the Import tab in your phpMyAdmin.
- Under Files to import, browse for your database backup
- Click “Go” in the bottom right corner of phpMyAdmin
- Alter The settings.php File
- Line #92 put in your new information in this format exactly
$db_url = 'mysql://username:password@localhost/databasename'; - NOTE: localhost may not be accurate for your specific database server. You need to know what your database server URL is, as well as if it uses a specific port. For example, your database server might be mysql.yoursitename.com – in which case “localhost” would be replaced with that name.
- Save
- Line #92 put in your new information in this format exactly
G. Navigate to your live drupal site at http://www.yoursitenamehere.com
- You should see your site up live!
- If you don’t and see a maintenance page, double check your settings.php file and make sure:
- You saved your changes
- Your changes are correct and you have the correct user name, password and database name.
- You have the right syntax (meaning: all the quotation marks, colons, semicolons, etc. are accurately placed and completed).
H. Set up Cron!
This is extremely important and often forgotten. Many of the things that Drupal does so well (site search, actions triggered by events, full use of taxonomy, and even mailings through SimpleNews or other options) depend on cron. Even backup and migrate requires Cron in order for the backups to be fully reliable.
Read about Cron here: http://en.wikipedia.org/wiki/Cron
Setting up cron properly is different on different hosts. If you cannot find easy help files for how to set cron up on your site, contact your host and they should be able to let you know what to do.
Nicole Bluto has created an easy-to-follow slideshow on setting up Cron in cpanel and on GoDaddy, which is attached at the end of this page and can be downloaded as a PDF. Instructions for Dreamhost are part of the main slideshow.
If you have no other way of setting up cron, there is also a simple drupal module to help you: Poormanscron
http://drupal.org/project/poormanscron
I. So, you want your site in a live environment but you do not want it available to the world or search engines?
There may be reasons for you to put a site into a live environment, but want to protect it from the general public and from search engines. One good reason: the site is nearly ready but your client needs to start using the awesome CMS you’ve configured to enter the content into the site!
- The primary way to do this is to use .htaccess and .htpasswd. The advantage to this method is that it is simple and does not add another module to your site. The disadvantage is that now your site editors/client need two sets of usernames/passwords – one to access the site at all, and the other to log into their account on the drupal site you have created.
- Alternatively, there is another simple drupal module that can help you with this: Secure Site
http://drupal.org/project/securesite
The advantage to this method is that your client/site editor only has to log in once, directly into their account on the site. By using Secure Site, you essentially set it up so that only users with roles of your choosing have access to the site at all. This also blocks search engine crawlers until you release the site from Secure Site. The other advantage: if your client/site editor forgets their log in information, the module gives them a field where they can request it be resent.
J. If you prefer to zip your files before downloading/uploading them:
You can use shell (Terminal, for example) to zip your site files up so that you only move them as one chunk instead of as many files at a time.
- type
ssh FTPusername@domain.tldand press return - Answer “yes” to “do you wish to continue connecting” and press return
- Type in your
FTPpasswordand press return - Type
lsand press return - Type
tar –czf name_of_file_you_want_to_create domain_directory_wantedand press return - Type
lsagain and press return, just to check in the list and make sure your new zipped file is there.
Modules to take away from this session:
Backup & Migrate - http://drupal.org/project/backup_migrate
Automate backups, create an easy administrative environment for backing up and restoring your database.
Secure Site - http://drupal.org/project/securesite
Protect your website with browser-based authentication that is tied directly to user accounts in your drupal site.
Poormanscron - http://drupal.org/project/poormanscron
A module that runs cron on your site during pre-set intervals without requiring you to set up cron on your web host.
Boost - http://drupal.org/project/boost
Static page caching for performance and scalability boost, which can also then be used to offer a static version of your site during maintenance “offline” time.
How to find us:
Nicole Bluto –
Twitter: @nbluto
Online: www.nicolebluto.com
Rain Breaw –
Twitter: @sunrainprods
Online: www.sunrainproductions.com
| Attachment | Size |
|---|---|
| Backup Migrate Session Outline OpenOffice.org format | 92.6 KB |
| Backup Migrate Session Outline PDF format | 163.12 KB |
| Backup Migrate Session Slideshow OpenOffice.org format | 783.49 KB |
| Backup Migrate Session Slideshow PDF format | 674.46 KB |
| Cron on GoDaddy & cpanel (from Nicole), PDF format | 552.1 KB |

