Automating SharePoint site backup using PowerShell and windows Task Scheduler
How to use windows scheduler to automate the Backup on a daily basis
a) First load the Task
Scheduler from Start >> All Programs >> Accessories >>
System Tool>> Task Scheduler. I am using the version which
ships with windows server 2008 R2 edition, but the concept should be
same for other release.b) To create a new Task, click Create Task from the right hand side “Actions Panel”.
c) This will open a Create Task window which will have first tab as General; here we need to provide the following basic information.
General Tab
- Name of the Task like “SharePoint Backup”. A Description which is not mandatory
- Select the User Account under which the following task will run. Ensure that the user account has the necessary permissions to use the PowerShell on the SharePoint farm, permission to perform script action on the SharePoint.
- Select Run whether the user is logged in or not and tick the Do not store password checkbox. This is necessary because at the time of backup being taken you may not be logged in.
- Also enable the Run with highest privileges option. I would recommend testing the script from Task Scheduler with the option disabled and only enable if the script does not work without it.
d) In the “Triggers Tab”
- Click New and in the “New Trigger”
- In “Begin the Task” dropdown select “On a Schedule”
- Under Setting radio button choose “Daily” also choose the time at 10:00 PM (according to your wish).
- Don’t change advanced settings for now.
e) In the “Actions Tab”
- Click “New” in the Actions Tab.
- In the “New Action” window ensure the “action” is set to Start a program.
- Under settings Program/Script write “Powershell.exe”
- In Add Arguments (optional) type &'d:\Backup-SiteCollections.ps1'. Note: Wrapping the file path and name in single quotation marks allows you to specify spaces in the text.
You should now see your script in the Task Scheduler Library (if not, click Refresh in the right-hand panel). To test the script, highlight it in the console and click Run from the right-hand panel.
No comments:
Post a Comment