When it comes to SharePoint Backup, you should take a break from work and do some serious thinking. It’s really not all that easy as Microsoft makes it look. Don’t count on built-in backup to save your bacon. There is no Best Practice for backing up your SharePoint Farm. But I do have a few good advise to give out.

Before I do that, let me just set the scene. I do backups for companies that have between 100 GB. and 500 GB. of SharePoint Storage. I’m sure that companies with more than 2 TB. of SharePoint Storage, does it quite differently. They most likely use DPM or some enterprise Backup Solution. This guide is for those who don’t have that kind of budget. If you work for one of those companies, I would really like your input to how you do backups.

Trust is a fickled friend

I never trust anything digital, that I only have one copy of. I take the same approach to my backups. So I have 2 approaches to backups.

  1. Full server image backup (This is very simple. Just use Veam to take a nightly Image backup of all servers)
  2. Content and configurations backup

Content, Configuration and Service Applications Backups

I do Configurations and Service Applications backup via PowerShell and Content backup via native SQL backup. I read somewhere that PowerShell doesn’t support backing up databases above 200 GB. but I can’t seem to validate that, so if anyone knows better, feel free to educate me via the comments.

My clients like to keep their backups around for one month. That means that I keep 2 months of backup.

You can bet your car that one day they will come asking for that content that is 31 days old

Aside from this backup you could do a separate SiteCollection Backup. I don’t.. yet. On another note. Don’t listen to those bloggers out there that tell you to use the Backup-SPConfigurationDatabase cmdlet. That cmdlet is intended for inactive Farms only. Always use the Backup-SPFarm cmdlet.

SharePoint Backup – Howto

  1. Create PowerShell Script to backup all your configurations and SA in a month-by-month folderstructure
  2. Create Scheduled Task to execute that PowerShell Script
  3. Create  Maintenance Plan on your SQL Server to:
    1. Check integrity of all SharePoint Content Databases
    2. Back ’em up to a folderstructure, with one folder per database
    3. Delete backup history older than 9 weeks
    4. Delete all files older than 8 weeks

1. PowerShell Script

I found this PowerShell script to backup all your configurations and Service Applications over at My SharePoint Adventure. You should take a look at the original and see id it fits your requirements better. I’ve changed it to match some of my requirements and changed the use of Backup-SPConfigurationDatabase to Backup-SPFarm.

[ps]

==========================================================================

NAME: Backup-Config-SA.ps1

COMMENT: Script to take backup of Config and Service Applications

Date: June 16. 2013

Author: Ulrich Gerting Bojko, http://getinthesky.com

==========================================================================

Add-PsSnapin Microsoft.SharePoint.Powershell –ErrorAction SilentlyContinue

#Variables
$ThisMonth = Get-Date -Format yyyy-MM
$CleanupMonth = (Get-Date).AddMonths(-2).ToString(‘yyyy-MM’)
$logfile = "\backup\Backup\SharePoint\Log\SPFarm-Backup-" + $(Get-Date -Format dd-MM-yyyy) + ".log"
$BackupConfigFolder = "\backup\Backup\SharePoint\Config\" + $ThisMonth
$BackupSAFolder = "\backup\Backup\SharePoint\ServiceApp\" + $ThisMonth
$BackupConfigFolderClean = "\backup\Backup\SharePoint\Config\" + $CleanupMonth
$BackupSAFolderClean = "\backup\Backup\SharePoint\ServiceApp\" + $CleanupMonth
$AdminEmail = "user@domain.com"
$MailServer = "SMTPServer"
$FromAddress = "user@domain.com"
 
Write-Host "Backup Script is starting…. Please standby!"
 

Backup Farm Configuration

try
{
ac $logfile "$(Get-Date)t Clearing old configuration backups.."
Remove-Item -Recurse -Force $BackupConfigFolderClean
ac $logfile "$(Get-Date)
t Done."
ac $logfile "$(Get-Date)t Backing up SharePoint Farm Configuration.. "
[IO.Directory]::CreateDirectory("$BackupConfigFolder")
Backup-SPFarm -ConfigurationOnly -Directory $BackupConfigFolder -BackupMethod Full -Verbose -Percentage 15
ac $logfile "$(Get-Date)
t Done."
}
catch [system.exception]
{
ac $logfile "$(Get-Date)`t An error occured while backing up the farm configuration database: $."
$messageParameters = @{
Subject = "Backup Failed: Farm Configuration Database"
Body = "ERROR $
."
From = $FromAddress
To = $AdminEmail
SmtpServer = $MailServer
}
Send-MailMessage @messageParameters
}
 

Backup Service Applications

try
{
ac $logfile "$(Get-Date)t Clearing old service application backups.."
Remove-Item -Recurse -Force $BackupSAFolderClean
ac $logfile "$(Get-Date)
t Done."
ac $logfile "$(Get-Date)t Backing up SharePoint Farm Service Applications.. "
[IO.Directory]::CreateDirectory("$BackupSAFolder")
Backup-SPFarm -Directory $BackupSAFolder -BackupMethod Full -Item "Farm\Shared Services" -Verbose -Percentage 15
ac $logfile "$(Get-Date)
t Done."
}
catch [system.exception]
{
ac $logfile "$(Get-Date)`t An error occured while backing up the service application database: $."
$messageParameters = @{
Subject = "Backup Failed: Service Application Database"
Body = "ERROR $
."
From = $FromAddress
To = $AdminEmail
SmtpServer = $MailServer
}
Send-MailMessage @messageParameters
}
 
Write-Host "Back is done. Come back soon!"
[/ps]

Database Backup

Now you’ve got your configurations and service applications backed up up in an orderly fashion, lets take a look on how to backup the actual SharePoint content. There are several ways to backup your data. You could script a PowerShell backup of your SiteCollections one-by-one. I recommend doing that too. In this case, I choose database backups using the native SQL-backup. Doing SiteCollection is just Backup-SPSite. Then fill in the blanks.

Create a maintenance plan with 3 subplans.

1. Full Backup (Once every month)

  1. Schedule:
    Sql-backup-ScheduleFull
  2. Check Database Integrity:
    Select your Content DB’s
    Sql-backup-IntegrityCheck
  3. Back Up Database:
    Backup type: Full
    Select same Content DB’s as in step one
    Sql-backup-Full
  4. Maintenance Cleanup:
    Select your backup destination and delete all “bak” older than 8 weeks
    Sql-backup-MaintenanceCleanup
  5. History Cleanup:
    Sql-backup-HistoryCleanup

2. Differential Backup (once a day)

  1. Schedule:
    Sql-backup-ScheduleDiff
  2. Check Database Integrity (same settings as when doing full backups)
  3. Back Up Database:
    Backup type: Differential
    Select same Content DB’s as in step one
  4. Maintenance Cleanup:
    Select your backup destination and delete all “trn” older than 3 days
    Sql-backup-MaintenanceCleanupTRN

3. Transaction log Backup (once every hour during business hours)

  1. Schedule:
    Sql-backup-ScheduleTRN
  2. Back Up Database:
    Backup type: Transaction log
    Select same Content DB’s as before
    Sql-backup-TRN

Tweet me

That’s it. You are done. Heres some last good advise, that i’ve picked up along the way:

  • Remember to do a full recovery drill once a while to check that your backups actually works like you expect.
  • Remember to check that your backup-user has full rights to the backup folder. If not, your PowerShell backups will not toss you an error. They will just fail on restore. Learned that the hard way.
  • Always keep backup longer than your client expects. It can save the day.
  • Use “domain attached” network drives. Don’t use a NAS where you cannot login with your AD-service account. It will fail your PowerShell Restores.
  • The HP Micro server is a good choice

I hope you’ve enjoyed this post on SharePoint Backup. If you like it, please consider sharing it with your social network.