Jim Ehrenberg (SharePoint Pros, Inc.)

Sr. Certified SharePoint | M365 Architect | SME- MCP, Migration Expert | 2022 MVP Nominee

PowerShell

SharePoint 2013 Backup with PowerShell and Task Scheduler for beginners

An oldie but a goodie. Courtesy of Yousef Omar

______________________________

You can do Everything with PowerShell – yes everything – and SharePoint is no exception. In this post for beginners, I will show you how to create tasks for the Task Scheduler to automate your SharePoint backups with PowerShell.

First, to backup your farm, you can use the PowerShell command Backup-SPFarm. For more details on this cmdlet, refer to http://technet.microsoft.com/en-us/library/ff607881.aspx. You can use the command to backup the farm a full backup as in the following example.

Backup-SPFarm -BackupMethod Full -Directory \\MyServer\SPBackups

And to backup the farm a differential backup, you can use the command as in the following example

Backup-SPFarm -BackupMethod Differential -Directory \\MyServer\SPBackups

To create a PowerShell script file, open a notepad file and save it as *.ps1. Let’s create two files – one for the full backup and another for the diff backup.

So create two files: SPFarmFullBackup.ps1 and SPFarmDiffBackup.ps1

In the first file for the full backup, type the following text.

Add-PSSnapin “Microsoft.SharePoint.PowerShell”

Set-ExecutionPolicy -ExecutionPolicy “Unrestricted” -Force

Backup-SPFarm -BackupMethod Full -Directory \\MyServer\SPBackups

Save the file.

In the second file for the differential backup, type the following text.

Add-PSSnapin “Microsoft.SharePoint.PowerShell”

Set-ExecutionPolicy -ExecutionPolicy “Unrestricted” -Force

Backup-SPFarm -BackupMethod Differential-Directory \\MyServer\SPBackups

Save the file.

Now, follow the steps below to create the tasks for Task Scheduler to automate the execution of backup files – let’s assume we will full-backup weekly and diff-backup daily.

1 – Open Tools > Tasks Scheduler

2 – In the center pane, right-click, and click Create Basic Task

3 – Assign the task a meaningful name – such as SharePoint-BackupFullWeekly

4 – Choose “Weekly ” on the When do you want the task to start screen

5 –  Specify the parameter for the weekly task schedule

6 –  Choose “Start a program” from the what action do you want the task to perform

7 –  On the start a program screen type in the command as the screenshot below. The Task scheduler is intelligent enough to recognize that you want to run PowerShell and that you supplied arguments.

Repeat the steps above to create a task for the diff backup.

Remarks:

Good Luck!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

DIY D365

Power Platform Done Your Way

Computerworld Essential SharePoint

Sr. Certified SharePoint | M365 Architect | SME- MCP, Migration Expert | 2022 MVP Nominee

Microsoft 365 Security for IT Pros

The e-book with monthly updates!

M365 learnings

Maintaining inner peace while working on M365 products

Office 365 Weekly

Office 365 news, notes and tips

ITProMentor

Helping IT Consultants for Small & Mid-sized Businesses succeed in the Microsoft Cloud

@Microsoft365Pro

Modern Work Blog focusing on Microsoft Teams & Microsoft 365

Cloud Collaboration

a cloud blog.

Tony Rockwell - Info

sharepoinTony@info - Cloud Computing adventures

SharePains by Microsoft MVP Pieter Veenstra

Microsoft 365, Power Platform, SharePoint, Teams, Azure and Dynamics

Sarah Haase

Product Manager | Librarian | Office Apps & Services MVP | Microsoft 365 | #WomeninTech

April Dunnam - SharePoint Siren

Office 365, SharePoint, PowerApps, Flow & Technology Blog

@WonderLaura

SharePoint and Power Apps for Non-Developers

Office365world

Office365 and SharePoint development

%d bloggers like this: