{"id":13551,"date":"2011-06-22T00:01:00","date_gmt":"2011-06-22T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2011\/06\/22\/use-powershell-to-back-up-your-sharepoint-farm\/"},"modified":"2011-06-22T00:01:00","modified_gmt":"2011-06-22T00:01:00","slug":"use-powershell-to-back-up-your-sharepoint-farm","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-back-up-your-sharepoint-farm\/","title":{"rendered":"Use PowerShell to Back Up Your SharePoint Farm"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\" class=\"CodeBlock\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><b><span><span style=\"font-size: 10pt\">Summary<\/span><\/span><\/b><span><span style=\"font-size: 10pt\">: Learn how to use Windows PowerShell to back up your SharePoint farm.<\/span><\/span><\/span><\/span><\/p>\n<p style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\" class=\"CodeBlock\">\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\"><img decoding=\"async\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\" \/>Hey, Scripting Guy! I&rsquo;ve heard that I can automate the backup of my SharePoint farm with a Windows PowerShell script, but it seems like it&rsquo;s a lot more complicated than just calling STSADM or <strong>Backup-SPFarm<\/strong>? What should I be including in my SharePoint farm backup script?<\/span><\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">&mdash;FJ<\/span><\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\">\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\"><img decoding=\"async\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\" \/> Hello FJ, <\/span><\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">Microsoft Scripting Guy, Ed Wilson, is here. I am so glad you asked that question. It gave me the opportunity to contact John Ferringer again because I knew this was right up his alley. <\/span><\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3157.HSG-6-22-11-1_59261CED.png\"><img decoding=\"async\" style=\"padding-left: 0px;padding-right: 0px;padding-top: 0px;border: 0px\" title=\"Photo of John Ferringer\" alt=\"Photo of John Ferringer\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3566.HSG-6-22-11-1_thumb_77242AE1.png\" width=\"197\" height=\"244\" \/><\/a><\/span><\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"color: #000000\"><span style=\"font-family: Segoe;font-size: 10pt\">John Ferringer is a senior manager consultant with Sogeti, LLC. He has more than seven years of experience administering and supporting SharePoint technologies, and he has spent more than thirteen years working in the technology consulting industry. John is certified as an MCITP and MCTS on several platforms, including Windows Server 2008, SharePoint, SCOM, and Project Server. He has coauthored the <\/span><\/span><\/span><span style=\"font-size: 10pt\"><a href=\"http:\/\/tinyurl.com\/spdr2010book\" target=\"_blank\"><span style=\"font-family: Segoe;color: #0000ff\">SharePoint 2010 Disaster Recovery Guide<\/span><\/a>.<span><span style=\"font-family: Segoe;color: #000000\"> His blog can be found at <\/span><\/span><a href=\"http:\/\/www.MyCentralAdmin.com\" target=\"_blank\"><span style=\"font-family: Segoe;color: #0000ff\">http:\/\/www.MyCentralAdmin.com<\/span><\/a><span><span style=\"font-family: Segoe;color: #000000\">, and he&#8217;s on Twitter as <\/span><\/span><a href=\"http:\/\/www.Twitter.com\/ferringer\"><span style=\"font-family: Segoe;color: #0000ff\">@Ferringer<\/span><\/a><\/span><span><span style=\"font-family: Segoe;color: #000000;font-size: 10pt\">.<\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\">\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">Protecting a SharePoint farm can be pretty challenging. It&rsquo;s one of those all too familiar IT problems that seems pretty straightforward (&ldquo;Hey, let&rsquo;s just run that Backup cmdlet and call it a day!&rdquo;)&mdash;until you start diving into it and realize that there&rsquo;s a lot more than that to getting it right. The nice thing is that we are talking about a pretty specific situation here: how to script a backup of a SharePoint farm by using SharePoint&rsquo;s own backup tools. <\/span><\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">Interestingly, the general intent and scope of SharePoint&rsquo;s backup command-line tools did not change much from the product&rsquo;s 2007 release to its 2010 release. Yes, SharePoint 2010 ships with plenty of great Windows PowerShell cmdlets, which is quite a big deal for the broader SharePoint command-line management story, but when it comes down to it, STSADM&rsquo;s Backup operation with its catastrophic options are not a whole lot different from the new <b>Backup-SPFarm<\/b> cmdlet. In addition, compatibility for STSADM was retained in SharePoint 2010, so if you already had a script that uses it, you can continue to take advantage of that investment if you want to.<\/span><\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">A Windows PowerShell script for a SharePoint backup can be pretty simple. Just call <b>Backup-SPFarm <\/b>or STSADM&rsquo;s Backup operation, wrap it in some error checking logic, save it, create a Windows Scheduled Task to run it, and you&rsquo;re good to go. If that&rsquo;s the route you want to take, SharePoint&rsquo;s backup tools still have some requirements that you need to keep in mind:<\/span><\/span><\/span><\/p>\n<ul>\n<li>\n<div style=\"line-height: 11pt;list-style-type: disc;text-indent: 0in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpFirst\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">A SharePoint 2007 or 2010 farm<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"line-height: 11pt;list-style-type: disc;text-indent: 0in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">A service account to run the Scheduled Task that calls the script (try to avoid using a named user&rsquo;s account to run the task). The account must have the following rights:<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<ul>\n<li>\n<div style=\"line-height: 11pt;list-style-type: disc;text-indent: 0in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><\/span><\/span><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">If you&rsquo;re using SharePoint 2010, it must be granted the <b>SharePoint_Shell_Access<\/b> role via the <b>Add-SPShellAdmin<\/b> CMDLET. <\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"line-height: 11pt;list-style-type: disc;text-indent: 0in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><\/span><\/span><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">If you&rsquo;re using SharePoint 2007, it must be granted local Administrator rights on the server that is running the script, and it must be an owner in SQL Server of the SharePoint databases you&rsquo;re targeting.<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"line-height: 11pt;list-style-type: disc;text-indent: 0in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><\/span><\/span><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">Granted Full Control of the directory where you&rsquo;ll be storing your backups.<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<li>\n<div style=\"line-height: 11pt;list-style-type: disc;text-indent: 0in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpLast\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">A directory for storing backups. If SharePoint and SQL Server are installed locally on the same server, this can be a path on the server&rsquo;s file system (for example, C:\\backups\\). If SharePoint and SQL Server aren&rsquo;t on the same server, this <em>must<\/em> be a shared drive with a UNC path (for example, <\/span><\/span><\/span><\/span><span style=\"font-size: 10pt\"><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe;color: #0000ff\">\\\\server\\backups<\/span><\/span><\/span><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe;color: #000000;font-size: 10pt\">).<span> <\/span>The account running the SharePoint Timer Job service and the SQL Server service account for SharePoint&rsquo;s SQL Server instance <em>must<\/em> both have full control of the directory.<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">If you want to keep it vanilla, you can stop here. However, if you want to really turn things up to eleven, I have some further suggestions for you. It&rsquo;s a bit more complex, but to me there&rsquo;s a lot more that you need to take into account when backing up SharePoint. You want to provide your environment with the most effective, thorough, and (most importantly) repeatable protection possible. You want it to work right every time, yet you need it to efficiently use your available resources to provide that consistent protection.<\/span><\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">The following is a list of items that I think are &ldquo;must haves&rdquo; for an effective SharePoint backup script that goes to eleven:<\/span><\/span><\/span><\/p>\n<blockquote>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpFirst\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><span style=\"font-family: Segoe\"><b><span style=\"line-height: 12pt\"><span style=\"font-size: 10pt\">Analyze available storage before attempting a backup. <\/span><\/span><\/b><span style=\"line-height: 12pt\"><span style=\"font-size: 10pt\">If you don&rsquo;t have the storage available to keep a backup, your script needs to be able to handle that situation gracefully and report it effectively.<\/span><\/span><\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><span style=\"font-family: Segoe\"><b><span style=\"line-height: 12pt\"><span style=\"font-size: 10pt\">Take regular backups.<\/span><\/span><\/b><span style=\"line-height: 12pt\"><span style=\"font-size: 10pt\"> My general guidance for your backup frequency would be to do them at least daily, but your requirements may vary. Remember, the more you run backups, the greater the performance impact on your farm. The less frequently you back up, the less up-to-date your backups are.<\/span><\/span><\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><b><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">Take advantage of varied backup types.<\/span><\/span><\/span><\/b><\/span><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">SharePoint allows you to perform both Full and Differential backups, so you want a script that is more heavily weighted toward Differential backups to save space, but a script that still takes regular Full backups to keep things current. <\/p>\n<p><strong>Note <\/strong>&nbsp;Differential backups capture everything that&rsquo;s changed in the target SharePoint farm, database, or site collection since the last backup, rather than including everything in the farm. Differential backups require that you first take a Full backup, so you always have to have at least one Full backup. But you also want to continue to perform regular Full backups because large numbers of Differential backups can take a long time to restore.<\/span><\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><b><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">Back up the entire farm.<\/span><\/span><\/span><\/b><\/span><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\"> This is one of those &ldquo;at a minimum&rdquo; kind of things. <\/p>\n<p>Note: If you have high-priority site collections in your farm, you may want to also include logic in the script to individually target them. (You can do this with STSADM&rsquo;s <b>Backup<\/b> operation and its <b>Site Collection<\/b> backup option or with the <b>Backup-SPSite <\/b>cmdlet).<\/span><\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><span style=\"font-family: Segoe\"><b><span style=\"line-height: 12pt\"><span style=\"font-size: 10pt\">If you&rsquo;re running SharePoint 2010, back up the farm&rsquo;s Configuration Database individually.<\/span><\/span><\/b><span style=\"font-size: 10pt\"><span style=\"line-height: 12pt\"> All of a farm&rsquo;s settings and setup information is stored in its Configuration database, and the new <strong>Backup-SPConfigurationDatabase<\/strong> cmdlet in SharePoint 2010 provides you with a nice tool to individually back up this critical resource as an additional layer of coverage for your farm. It&rsquo;s not a complete capture of your farm&rsquo;s configuration data, but it&rsquo;s a start. See <\/span><\/span><\/span><\/span><span style=\"font-size: 10pt\"><a href=\"http:\/\/sharepointinterface.com\/2010\/09\/10\/configuration-only-backup-and-restore-in-sharepoint-2010\/\" target=\"_blank\"><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe;color: #0000ff\">Configuration-Only Backup and Restore in SharePoint 2010<\/span><\/span><\/a><\/span><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe;color: #000000;font-size: 10pt\"> for a great explanation of its limitations.<\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><b><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">If you have SharePoint 2010, merge the SharePoint usage log files.<\/span><\/span><\/span><\/b><\/span><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\"> Microsoft recommends doing this, so it is at least worth considering for your script. <\/p>\n<p>Note: This can have some performance implications if you decide to merge all log files, so keep an eye on it. If it takes a long time to run, try limiting this to specific usage types.<\/span><\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><span style=\"font-family: Segoe\"><b><span style=\"line-height: 12pt\"><span style=\"font-size: 10pt\">Handle and report errors.<\/span><\/span><\/b><span style=\"line-height: 12pt\"><span style=\"font-size: 10pt\"> This may seem like a tiny detail, but trust me, when a backup fails you want to know about it. Write your scripts to handle errors, and write them to your server event log for monitoring and alerting.<\/span><\/span><\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpLast\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><span style=\"font-family: Segoe\"><b><span style=\"line-height: 12pt\"><span style=\"font-size: 10pt\">Rotate backup files. <\/span><\/span><\/b><span style=\"line-height: 12pt\"><span style=\"font-size: 10pt\">Over time, regularly generated backup files can take up a lot of space. Disk space is cheap these days, but you don&rsquo;t want a backup to fail because there&rsquo;s not enough storage to hold it, do you? Your script should retain backups for a defined number of days and either archive or delete older files to reduce your storage footprint.<\/span><\/span><\/span><\/span><\/p>\n<\/blockquote>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">Now, that is a lot to consider, and it may seem a little daunting, but I have good news for you: I have written a script that does everything previously listed and that is compatible with SharePoint 2007 and SharePoint 2010. I have posted it to the <\/span><\/span><\/span><span style=\"font-size: 10pt\"><a href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/9b99c435-8831-4c9e-a70b-1f13158ef22a\" target=\"_blank\"><span><span style=\"color: #0000ff\">TechNet Script Repository<\/span><\/span><\/a><\/span><span><span style=\"color: #000000;font-size: 10pt\">&nbsp;for your downloading pleasure, so feel free to have at it<\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"color: #000000;font-size: 10pt\"><\/span><\/span><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">A couple of notes about the script:<\/span><\/span><\/span><\/p>\n<blockquote>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpFirst\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">Be sure to review its required input parameters and settings, and select the options and items that make the most sense for your environment. <\/span><\/span><\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">Carefully consider how frequently you want to back up your environment. Understand the Recovery Point Object (RPO) of your users (how current your restored content must be) to better gauge the right setting for this.<\/span><\/span><\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">I wrote the script to be run once a day, with Full backups of the farm on a weekly basis and Differential backups the other six days of the week. This is a good general setting, but your approach will depend on your users&rsquo; Recovery Time Objectives (RTO). If you need to perform a restore quickly, you need to remember that Differential backups can take a long time to restore if you have a lot of them.<\/span><\/span><\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">Think about what else is going on in your SharePoint environment when you are planning to run this script, in addition to other systems that your SharePoint farm depends on, such as SQL Server. Backups are resource intensive, and you want to avoid any competition for resources that can cause delays or errors. I try to schedule my backups about an hour after my search crawls normally finish to ensure that there are not any conflicts, and then I run the backups between midnight and 5:00 A.M. (based on the local time for my largest group of users).<\/span><\/span><\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpMiddle\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">Document the configuration of your Scheduled Task, and store it somewhere that it can be accessed centrally.<\/span><\/span><\/span><\/span><\/p>\n<p style=\"line-height: 11pt;list-style-type: disc;text-indent: -0.25in;margin: 0in 0in 10pt\" class=\"MsoListParagraphCxSpLast\"><span style=\"color: #000000\"><span style=\"line-height: 12pt\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\">&middot;<\/span><\/span><span style=\"line-height: normal\"><span style=\"font-family: Times New Roman\"><span style=\"font-size: 7pt\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/span><\/span><span style=\"line-height: 12pt\"><span style=\"font-family: Segoe\"><span style=\"font-size: 10pt\">You must have already completed a Full backup in your environment or set the initial run of this Scheduled Task to be on the day that you selected to perform a Full backup. You cannot create a Differential backup until there is first a Full backup in the farm.<\/span><\/span><\/span><\/span><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">&nbsp;<\/span><\/span><\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2100.HSG-6-22-11-2.png\"><img decoding=\"async\" style=\"border: 0px\" title=\"Image of backing up the SharePoint farm\" alt=\"Image of backing up the SharePoint farm\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2100.HSG-6-22-11-2.png\" \/><\/a><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">&nbsp;<\/span><\/span><\/span><\/p><\/blockquote>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">Thanks John, for sharing this great script and this excellent information about backing up a SharePoint farm. <\/span><\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\"><\/span><\/span><\/span>&nbsp;<\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\">\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">FJ, that is all there is to using Windows PowerShell to back up your SharePoint farm. <\/span><\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"color: #000000\"><span style=\"font-family: Segoe;font-size: 10pt\">I invite you to follow me on <\/span><\/span><\/span><span style=\"font-size: 10pt\"><a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\"><span style=\"font-family: Segoe;color: #0000ff\">Twitter<\/span><\/a><span><span style=\"font-family: Segoe;color: #000000\"> and <\/span><\/span><a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\"><span style=\"font-family: Segoe;color: #0000ff\">Facebook<\/span><\/a><span><span style=\"font-family: Segoe;color: #000000\">. If you have any questions, send email to me at <\/span><\/span><a href=\"mailto:scripter@microsoft.com\" target=\"_blank\"><span style=\"font-family: Segoe;color: #0000ff\">scripter@microsoft.com<\/span><\/a><span><span style=\"font-family: Segoe;color: #000000\">, or post your questions on the <\/span><\/span><a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\"><span style=\"font-family: Segoe;color: #0000ff\">Official Scripting Guys Forum<\/span><\/a><\/span><span><span style=\"font-family: Segoe;color: #000000;font-size: 10pt\">. See you tomorrow. Until then, peace.<\/span><\/span><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\">\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\"><b><span><span style=\"font-family: Segoe UI\"><span style=\"color: #000000;font-size: 10pt\">Ed Wilson, Microsoft Scripting Guy<\/span><\/span><\/span><\/b><\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\">&nbsp;<\/p>\n<p style=\"line-height: 13.25pt;list-style-type: disc;margin: 0in 0in 8pt\" class=\"MsoNormal\"><span><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">&nbsp;<\/span><\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Summary: Learn how to use Windows PowerShell to back up your SharePoint farm. Hey, Scripting Guy! I&rsquo;ve heard that I can automate the backup of my SharePoint farm with a Windows PowerShell script, but it seems like it&rsquo;s a lot more complicated than just calling STSADM or Backup-SPFarm? What should I be including in [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[56,157,3,130,59,45],"class_list":["post-13551","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-guest-blogger","tag-john-ferringer","tag-scripting-guy","tag-servers","tag-sharepoint","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>&nbsp; Summary: Learn how to use Windows PowerShell to back up your SharePoint farm. Hey, Scripting Guy! I&rsquo;ve heard that I can automate the backup of my SharePoint farm with a Windows PowerShell script, but it seems like it&rsquo;s a lot more complicated than just calling STSADM or Backup-SPFarm? What should I be including in [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/13551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=13551"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/13551\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=13551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=13551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=13551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}