February 5, 2008

How-To: Backup and Restore

Migrating a site collection from one server to another is a common task for me. Often, the development work is done on our local servers and then moved to a staging server and then to the client's production environment. I have found that the command line utility STSADM is by the far the easiest way for me to move my sites from one server to another. STSADM can be found usually under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN

For backing up my site collection I use

STSADM     -o backup

        -url http://mysitecollection/

        -filename c:\folder\myfile.dat

After copying the file to the destination server, I then run STSADM to restore the site collection on an existing web application.

STSADM    -o restore

        -url http://mydestinationwebapp/

        -filename c:\folder\myfile.dat

        -overwrite

The overwrite parameter is important to use in scenarios where you have an older backup running or you have simply created the web application along with a site collection. The overwrite parameter instructs STSADM to overwrite the site collection if it exists.

Once this operation has completed successfully you should be able to view you site on the new server. There is however a problem if the target server is on another network (as might usually be the case). When browsing on the new site, it gives you an Access Denied error. You will need to add your local credentials on the new network as the site collection administrator from the Central Administration before you will be able to browse and access the contents of your restored site collection.

Another point to note is that if you have custom webparts that you are using in your application, then these must be individually placed on the target server and you will also need to edit the web configuration file and add the details accordingly.

No comments: