Share via


Backup SharePoint Document Library Using PowerShell


Backup SharePoint Document Library Using PowerShell


Summary

Many are using third party tools for backing up SharePoint environment and few use PowerShell. This Wiki is for SharePoint admins one who backup Libraries before committing some changes.

Background

During my PowerShell session few SP admins asked me why PowerShell is not much for SharePoint? It is infact! But, at times we need to slightly change our mode of requirements

Case History

We need to back up SharePoint 2010 Library using PowerShell - If in case any error or warning occurs it should halt.

Explore Command

help Export-SPWeb

Refer this Link for more information http://technet.microsoft.com/en-us/library/ff607895%28v=office.15%29.aspx

Challenges

  1. Do not use -HaltOnWarnings by default Export-SPWeb will back up Last Major version so we can safely ignore it.
  2. We need to make new CMP file for every back up with time stamp. So not easy!

Solution

The above challenges are not correct, we should use commands logically to meet our goals. Before executing commands we should read the parameters correctly and frame the script as required. For every command use -WhatIf. Use Help every now and then.

Explore the Parameters

For the above mentioned challenges we need to focus on below parameters

  1. -HaltOnWarning
  2. -Force
  3. -IncludeVersions

Code

Export-SPWeb -Identity http://Chen.Com/SharePoint -ItemUrl "PowerShell" -path D:\Temp\Success.cmp -HaltOnWarning -IncludeVersions ALL -IncludeUserSecurity  -Verbose  

Conclusion

-HaltOnWarning Will halt if incase of any Warning occurs. -Force Will replace the backup on existing -IncludeAllVersions Choose one as required.

More Information

Help Export-SPWeb -Parameter -HaltOnWarning  

Help Export-SPWeb -Parameter -IncludeVersions

Help Export-SPWeb -Parameter -Force