Importing Existing Websites into Aegir

Events happening in the community are now at Drupal community events on www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

Aegir 0.4 Notes

No time to revise whole page...much of the stuff below the "--Older Stuff--" is probably still valid. See the process here: http://drupal.org/node/908524#comment-3472038

-------- Older Stuff ---------

Moving existing websites to be hosted under Aegir is very straightforward, and will then give you the full power of Aegir for future upgrades and so on - just as if the site had been created on Aegir in the first place.

In these steps I'm assuming that you've set up a shiny new server with Aegir on, and are wanting to import sites from a completely different old server.

Option A. Importing just the sites directory

If you already have a platform setup on Aegir with EXACTLY the same codebase as your existing site, then you don't need to transfer the entire old codebase - you can just transfer the sites/example.com directory. However, you also need to make sure any dependencies on contrib modules are met on the new codebase. In general it is better to import the entire old codebase, and then migrate it in Aegir to reduce the number of platforms you have - see Option B below.

However, if you really want to just import the site directory, here's how:

1. Transfer the files

Copy the 'sites/example.com' directory from your old server to the new Aegir server (if it was sites/default before it needs to be moved to sites/example.com. See section below).

To do this, fist create a tarball of the site on the old server. Within the sites/example.com directory type:
tar -zcvf example.com.tar.gz * .htaccess

Note: If you fail to include .htaccess in your tarball, when you create a site from your new platform, you will only be able to access the site's front page. You will get a 404 error trying to access any other page because Aegir will not have included the Rewrite rules from .htaccess in the platform's configuration.

Then, on the new server you can create a directory for it in the codebase you want to put it under:

cd sites
mkdir example.com
cd example.com
wget http://example.com/example.com.tar.gz
tar -zxvf example.com.tar.gz

Instead of using wget you could of course use FTP to get the file in place.

Once the file is unpacked, check the ownership and group of each file by using ls -l. It should be either 'aegir:aegir' or 'aegir:www-data'. Change it if necessary.

In particular, the files you've uploaded via modules like imagecache, upload, profile pics etc need to have their ownership changed:
sudo chown -R aegir $platform/sites/*/files

2. Transfer the Database

Note: This step is not necessary if you are moving your site from one directory on your server (e.g., /var/www/html) to a newly created Aegir directory on the same server (e.g., /var/aegir).
Make a backup of the database on your old server (Backup and Migrate module is good for this, or you can use phpmyadmin or your favourite MySQL management tool. It's a good idea to truncate the cache, search and watchdog tables first to reduce the size of the database (Backup and Migrate does this for you).
On your new server, manually create a new database and upload the .sql file from your backup.
Then create the mysql user that your site accesses the database as, and grant it all permissions on that database except 'GRANT'.

3. Verify In Aegir

In the Aegir web interface click on the name of the platform you have added your site to (it's in the first sidebar). Then select the Verify tab and click the verify button.
Aegir will now re-verify the platform, in the process of which it will discover your new site, import the site, and then verify it.
Once it's done this (after a few cron runs) the tasks should turn green (if not, see 'Troubleshooting' below). At this point, go to your site's address in the browser and check around to see that it has worked. Pay particular attention to any links in node content that pointed to paths referencing /sites/default if your site was not part of a multisite setup. Aegir will not go through all your database and update all URLs, so some images or links may be broken. This will need to be done manually.

It's a good idea to clear the caches, and you may need to get imagecache to rebuild its thumbnails if you use it.

Option B. Importing the entire codebase

This way of importing sites is the safest - bringing across the entire codebase. This makes sure you bring any dependencies, contrib modules etc, in exactly the same version and configuration that is in the database for the site.

1. Transfer the codebase

Create a tarball of the codebase on the old server. Within the drupal root directory type:
tar -zcvf example.com.tar.gz * .htaccess

See Note above regarding inclusion of .htaccess in tarball.

Then, on the new server you can create a directory for it in the codebase you want to put it under:

mkdir drupal-6.12
cd drupal-6.12
wget http://example.com/example.com.tar.gz
tar -zxvf example.com.tar.gz

Instead of using wget you could of course use FTP to get the file in place.

Once the file is unpacked, check the ownership and group of each file by using ls -l. It should be either 'aegir:aegir' or 'aegir:www-data'. Change it if necessary.

In particular, the files you've uploaded via modules like imagecache, upload, profile pics etc need to have their ownership changed:
sudo chown -R aegir $platform/sites/*/files

If your site previously resided in sites/default you need to move it because aegir ignores the default directory, and each site needs its own directory with the correct domain:

mv sites/default sites/example.com

If you do this, you may need to also update your filepath's stored in the files table by running the following query on your database
-- update files db table
UPDATE files SET filepath = REPLACE(filepath, "sites/default", "sites/example.com");

2. Transfer the Database

Note: This step is not necessary if you are moving your site from one directory on your server (e.g., /var/www/html) to a newly created Aegir directory on the same server (e.g., /var/aegir).
Make a backup of the database on your old server (Backup and Migrate module is good for this, or you can use phpmyadmin or your favourite MySQL management tool. It's a good idea to truncate the cache, search and watchdog tables first to reduce the size of the database (Backup and Migrate does this for you).
On your new server, manually create a new database and upload the .sql file from your backup.
Then create the mysql user that your site accesses the database as, and grant it all permissions on that database except 'GRANT'.

3. Setup Platform in Aegir

In the Aegir web interface click on 'Create Content' (it's in the first sidebar) and 'Platform'. Enter the name you want to use for the platform (eg 'Drupal 6.12 import'), and the path to the platform on the server (eg '/var/aegir/platforms/drupal-6.12')
Aegir will now verify the platform.
Once it's done this the task should turn green (click through to the homepage to refesh and check. If not, see 'Troubleshooting' below).

4. Import and Verify Sites In Aegir

In verifying your codebase, Aegir will automatically detect any websites in the sites directory. It will then import these, and verify them all. After a few cron runs you should see all these tasks turn green.
At this point, go to your sites' addresses in the browser and check around to see that it has worked. Pay particular attention to any links in node content that pointed to paths referencing /sites/default if your site was not part of a multisite setup. Aegir will not go through all your database and update all URLs, so some images or links may be broken. This will need to be done manually.

It's a good idea to clear the caches, and you may need to get imagecache to rebuild its thumbnails if you use it.

5. Migrate To Another Platform

Now that you have your sites under Aegir's control you can take advantage of its power, and easily migrate them to another platform. In this case you might want to migrate them to Drupal 6.13 to perform the upgrade. For details on how to do this see:http://groups.drupal.org/node/24993

Troubleshooting

For those who are migrating existing sites that live with their files in the sites/default folder things can get tricky, however you can follow this tutorial and successfully get things moved over rather easily: http://palma-seo.com/content/moving-single-drupal-install-default-direct....

For the moment, check the FAQ here: http://groups.drupal.org/node/24854
More troubleshooting info will be available soon

Aegir hosting system

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: