GAC and Inetpub virtual directory backup

Dec 1, 2009 at 11:08 PM

Jesper,

Thank you providing the excellent script for the SharePoint Environment Data Protection.

One question: Will this script help to backup GAC Folder and Inetpub --> virtual directories also without doing the Full Farm backup.

Please can you help

Thank you

 

Dec 9, 2009 at 9:09 AM

No it doesn't but if you need it then add this to the XML, to the site id=1 (there's no need to turn it on for other site IDs)

	<wwwrootpath>c:\inetpub\wwwroot</wwwrootpath>
	<wwwrootbackup>0</wwwrootbackup>
	<gacbackup>0</gacbackup>

Then add this to the script.

First into the part where the options are loaded add this:

  $gacbackup = $item.gacbackup
  $gac = $env:windir+"\assembly"
  $wwwrootbackup = $item.wwwrootbackup
  $wwwrootpath = $item.wwwrootpath

and then before the end of that foreach add this (before the last } charachter) add this. Btw I tested it only on Windows 2003, not 2008!

# ---
# --- IIS wwwrooot backup if wwwrootbackup=1
# ---
If ([string]::Compare($wwwrootbackup, "0", $True))
{
  $jobreport = logging("Starting backup of WWWROOT to "+$backupdestination+"\"+$backupfilename+"-wwwroot"+$guid+".zip")
  if(test-path $backupdestination)
  {
    if(test-path $wwwrootpath)
    {
      gi $wwwrootpath  | out-zip $backupdestination"\"$backupfilename"-WWWRoot-"$guid".zip" $_
      [DateTime]::Now.ToString() + ": WWWRoot backup Done! File name is $backupdestination\$backupfilename-wwwroot$guid.zip" >> "$backupdestination\log.txt"
    }
    else
    {
      $jobstatus = "Error"
      $jobreport = logging("Error: The WWWRoot Path doesn't exist for site id "+$id)
    }
  }
  else
  {
    $jobstatus = "Error"
    $jobreport = logging("Error: The backupdestination Path doesn't exists for site id "+$id)
  }
}
else
{
  $jobreport = logging("Skipping backup of WWWRoot "+$wwwrootpath)
}



# ---
# --- GAC backup if gacbackup=1
# ---
If ([string]::Compare($gacbackup, "0", $True))
{
  $jobreport = logging("Starting backup of GAC to "+$backupdestination+"\"+$backupfilename+"-gac"+$guid+".zip")
  if(test-path $backupdestination)
  {
    if(test-path $gac)
    {
      gi $gac  | out-zip $backupdestination"\"$backupfilename"-GAC"$guid".zip" $_
      [DateTime]::Now.ToString() + ": GAC backup Done! File name is $backupdestination\$backupfilename-gac$guid.zip" >> "$backupdestination\log.txt" 
      start-sleep 60
    }
    else
    {
      $jobstatus = "Error"
      $jobreport = logging("Error: The GAC Path doesn't exist for site id "+$id)
    }
  }
  else
  {
    $jobstatus = "Error"
    $jobreport = logging("Error: The backupdestination Path doesn't exists for site id "+$id)
  }
}
else
{
  $jobreport = logging("Skipping backup of GAC "+$gac)
}

 

You must be aware that windows zip doesn't store NTFS permissions and use external app like winrar or something else if you need it. I just wanted the files and especially web.config files to be saved with the backup. Also don't get false safety feeling from the GAC backup. It is definitely better to have the solutions installation files stored and documented.