Moving Your Site to a New Server

From time to time someone at The Admin Zone will ask how to easily move a site from one server to another. While this article will explain how to do this if your site is hosted on a Windows server it can easily be applied when moving from Windows to Linux, Linux to Windows or Linux to Linux. Moving your site to a new server is not all that hard. With this article I will attempt to make a move easy for you.

Getting everything ready to transfer and transferring the files.

Login to the server. Put a new index page up letting your users know you are moving the site. The best way to do this is to create a new directory and configure your server to serve pages from the new directory. If you sites are in wwwroot then create a new directory out of wwwroot and configure IIS to serve pages out of it.

Use a zip utility and compress the wwwroot dir. After you have that done the best thing to do is start the transfer of the zip to the new server. Use FTP or connect server to server with RDP. At this point you’re better off using FTP. Once the transfer starts you can move on the next task.

Shutdown mysql. Once it is shutdown head into the mysql directory and zip the data dir. If you don’t have access to the data dir because you are on a shared server you can use mysqldump to dump the databases.
To dump all the databases open a command box and give this command.

mysqldump -u[username] -p[password] –all-databases > C:\path\to\save\mysql.mysql

Depending on the size of your database this can take some time. Once the dump completes zip it and start the transfer to the new server. This the most time consuming part of the whole process if you have large databases. While this step is in progress you can create the xml files with IIS manger for you sites and transfer them over. If you use Apache transfer your httpd.conf file.

IIS Manager has a feature to save your site configuration to file. This handy to transfer all the meta data to the new server. While you are waiting for the files to transfer open IIS Manager. Right click your website and select Tasks > Save Configuration to File. Select where you want it saved and use .xml as the extension. If you have several website do the same for all of them. Also do this for your FTP sites and if you created any custom AppPools do the same to save them. Once that is done zip them all up and transfer to the new server. If your using Apache transfer httpd.conf. . Once you have the xml files transfered connect to the new server. Even if the mysql transfer isn’t complete transfer isn’t complete login to the new server anyway and continue to the next section.

Setting everything up on the new server.

If all your files have transfered then great. If you mysql files are still transfering that’s ok. You can still setup the websites.
Extract the wwwroot files on the new server into where you want to serve your pages from. Make sure to keep the directory structure the same as what is was on the old server. Once that is done extract the configuration xml files into any working dir.
Open IIS manager, right click Websites and select new > website from file. Use the browse button to navigate to the xml file for the websites and click read file. It will show you websites. Click Import. This will setup your websites with the same metadata of the old server. Do the same for your FTP sites and AppPools. IIS is now ready to server your pages. If you are using Apache extract the files into Apache webroot and overwrite httpd.conf with the one you transfered.

Next thing to do is to set up your database. If your database is still transfering have yourself a cup of coffee. Nothing you can do but wait at this point. Unless of course if you run your own DNS then you should use this time to set up the DNS. Don’t change the DNS at the registrar until all files have transfered and are setup. DNS propagates fairly fast, within a few minutes, and the last thing you want is to start serving pages on the new server if everything isn’t there.

Once the database is transfered extract the zip. Shutdown mysql. Overwrite the current mysq\data dir with the one you just extracted. If you transfered a mysqldump file then leave mysql running and run this command.

mysql -u[user] -p[password] < C\path-to-extracted-dump\mysql.mysql

Again depending on the size of the dump file this could take a while. Once that completes open a browser on the server and check localhost to make sure everything is working. Make sure mysql is running first.

If your paths on the old server are different on the new server, say your wwwroot was in D: instead of C:, then right click each website in IIS manager and correct the home directory path.
If your site shows up on localhost with no errors then change your DNS to point to the new IP. You’re all done.

Leave a Reply

Be the First to Comment!

Notify of