Archive for Uncategorized

SharePoint 2010 PowerShell Backup and Restore

I was asked to make a copy of a Site Collection on the production server and put it on the development server with the subsites and permissions intact. These steps did the trick using these scripts (thanks to Brad Schacht’s Blog for this):

Backup-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]

  • Force – Include this if you want to override a backup with the same name
  • NoSiteLock – Will prevent the site from going to Read Only mode while the backup is being taken. A small warning, if someone changes content on the site while the backup is being created and according to Microsoft “might lead to possible data corruption”
  • UseSQLSnapshot – A database snapshot will be taken before the backup begins and the backup will be done off the snapshot. The advantage is that changes can be made to the site while the backup process is running without fear of corruption. The snapshot will be deleted automatically when the backup is completed. You don’t need to specify the -NoSiteLock parameter when using this method

Restore-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-DatabaseServer DatabaseServerNameHere] [-DatabaseName ContentDatabaseNameHere] [-HostHeader HostHeaderHere] [-Force] [-GradualDelete] [-Verbose]

  • DatabaseServer – Specify the server for the content database
  • DatabaseName – Specify the name of the content database
  • HostHeader – URL of the Web application that will hold the host-named site collection
  • Force – Overwrite the site collection if it exists
  • GradualDelete – Recommended for site collections over 1 Gig in size, existing data is marked as deleted and gradually removed over time by a job rather than all at once to reduce the performance hit of deleting large amounts of data


  1. To Backup site 
    1. Use Remote Desktop to log into production server
      1. Login with the Service Account (farm admin account that has access to content databases)
    2. Create a folder on the e: drive to put backup file
      1. (Note: it is best practice not to put backup files on the c: drive)
    3. Open ‘SharePoint 2010 Management Shell’
    4. Create backup script in Notepad, then copy and paste it in:

Backup-SPSite -Identity http://yourProductionServer/sites/yourSite
-Path e:\SiteBackups\yourSite.bak

  1. To Restore site
    1. Use Remote Desktop to log into development server
      1. Login with the Service Account (farm admin account that has access to content databases)
    2. Create a folder on the e: drive to put backup file
    3. Copy and paste .bak file from production server Remote Desktop window (e: drive) to development server Remote Desktop window (e: drive)
    4. Open ‘SharePoint 2010 Management Shell’
    5. Create restore script in Notepad, then copy and paste it in:

Restore-SPSite “http://yourDevServer/sites/yourSite”
-Path e:\SiteBackups\yourSite.bak

Note 1: it is best practice to run Backup and Restore scripts after hours because of the site logs, and because the site will be locked (read only) during the backup. Although there are some alternatives available, such as the [-UseSqlSnapshot] and [-NoSiteLock] paramaeters…

Backup-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]

See the Backup-SPSite technet page for details on these parameters.

Note 2: The difference between Backup-SPSite and Export-SPWeb

  1. Workflows are included when you use the Backup_SPSite cmdlet
  2. SPSite targets Site Collection objects
  3. SPWeb targets sites (subsites), list and library objects

MOSS 2007 Document Library PDF Upload Error-File Size Issue

Problem: I have a MOSS 2007 farm (on Windows 2008 Service Pack 2) that is 5 years old, and i’ve never had problems uploading a PDF document until [Today]. My freaking Document Library wouldn’t let me upload a pdf that is 44 MB in size. The default file size limit for web applications is 50 MB. I changed the limit to 500 MB in Central Administration, but it still wouldn’t upload!

Solution: I found a couple blogs that said this is a MS bug for MOSS 2007 farms on Windows 2008, and that the solution is to add this code below to the web.config file. I did it and it worked for me.

  • Remote into WFE
  • Open IIS 7
  • Right-click on site in question (Extranet39979 in my case), click ‘Explore’
  • This will open up a window at this location: inetpub\wwwroot\wss\VirtualDirectories\Extranet39979 and you should see your web.configuration file
  •  Make copy of web.configuration file
  • Open web.configuration file in Notepad and paste this code at the end of the file after the <> tags:
      <requestLimits maxAllowedContentLength="52428800"/>


      <proxy autoDetect="true" />

        <requestLimits maxAllowedContentLength="52428800"/>

    <location path="_vti_bin/ReportServer/ReportServiceAuthentication.asmx">
          <allow users="*" />
<spSolutions><dataZoom><providers /></dataZoom></spSolutions>

SharePoint 2010 SPD Workflow if Date is Empty

Problem 1: I need to build a SPD workflow where If ‘completed date’ is empty and ‘status’ field is ‘completed’, then fill in ‘completed date’ field with ‘modified’ field (‘when an item is created’, and ‘when an item is changed’).

Problem 2: SPD Workflows do NOT have the ‘is empty’ option on date fields. Whaaaattt?


  • In Step 1, use the ‘Set Workflow Variable’ action to create a variable called ‘CompletionDate’. Set this variable to Current Item:Completed Date, Return field as: As String.
  • Then in Step 2 you will have a string variable that has the ‘is empty’ option …. see picture below:


SharePoint Retracting Job Runs Indefinitely

This week I tried to retract the mosstraining.wsp solution because we never used this solution, and I am cleaning up our MOSS 2007 server in preparation for the upgrade to Sharepoint 2010, but it retracted forever! I went to Central Administration > Operations > Solution management, clicked on the mosstraining.wsp file, then clicked on the ‘Retract Solution’ button. I followed the steps and advice in the microsoft documentation which states that you must retract the solution before you can remove/delete it. I also remember reading somewhere that the retraction process can take a while, so I went to lunch. After lunch the solution was still retracting. The next morning I found that the server had crashed, and after restarting, the solution was still…. retracting!

Thank God that I found MJs blog post before I pulled out all my hair!

Although i have tried manually and through stsadm/code the solution retraction never completes and gives the status as retracting forever. i have jotted down some workarounds that might work when Solution deployment hungs while deploying a solution :

1. Run execadmsvcjobs that will forcefully run the timer jobs
stsadm -o execadmsvcjobs
2. Delete the existing timer job for the retraction and retry retracting
From UI central admin -> operations -> Time Job Definitions ->click on timer job and delete. For the timer jobs that do not have the delete option enabled stsadm utility can be used,
stsadm -o deletesptimerjob -title -id
3. To get the job id for the timer try the following stsadm -o enumssptimerjobs
4. If running out of options then stop retracting and delete the solution using override
stsadm -o deletesolution -filename -override

  • I tried MJ’s first suggestion, stsadm -o execadmsvcjobs, but it didn’t help.
  • I tried his second suggestion, I went to Central Administration and deleted the existing timer job for the solution.
  • Then I went straight to suggestion number four and nuked it, stsadm -o deletesolution -mosstraining.wsp -override, and it was gone! Thanks MJ!