automatic scheduling of sharepoint 2010 backup

Asked By Jayanarayan
08-Sep-10 04:50 AM
Earn up to 0 extra points for answering this tough question.
hi friends

does anyone know how to take automatic backup of sharepoint 2010 using power shell scripts?? i have created a power shell script by copying the backup command. then call this script inside a batch file. put this batch file into windows scheduler which will do the desired job. i need the exact steps. i studied in internet that it is possible. but he has not given any steps. please help me. also when i run a batch file i dont see the output on screen. how to display the output on screen?? if anyone knows the solution please let me know.

  re: automatic scheduling of sharepoint 2010 backup

Anand Malli replied to Jayanarayan
08-Sep-10 05:19 AM
hi jaynarayan,



Step 1: Create a .ps1 file

To run a .ps1 script from the task scheduler, you must pass it as a parameter to powershell.exe.

  1. Run Notepad.
  2. Type or paste the following script into a blank document:

  3. Windows PowerShell

  4. Backup-SPSite 
    Backup-SPSite -Identity <SPSitePipeBind> -Path <String> [-AssignmentCollection<SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-NoSiteLock <SwitchParameter>] [-UseSqlSnapshot <SwitchParameter>] [-WhatIf [<SwitchParameter>]][<CommonParameters>]

  5. Save the file as AutoBackup.ps1. Be sure to select All Files under Save as type.
  6. By default, the file should be saved in your user profile folder (for example, C:\Users\myLogon\AutoBackup.ps1).

  7. To verify that the script works:
  8. Run an elevated PowerShell window.
  9. Type the location of the script. For example:         C:\Users\myLogon\AutoBackup.ps1


Step 2: Create a task in Windows Task Scheduler

The following procedure describes how to create a task on the head node that runs the AutoBackup.ps1 script every day at 6:00 AM.

To create a task in Windows Task Scheduler that runs AutoBackup.ps1 every day

  1. Log on to the head node as a user with administrative permission.
  2. Click Start, point to Administrative Tools, then click Task Scheduler.
  3. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
  4. In Task Scheduler, in Actions, click Create Task. The Create Task dialog box appears.

  5. In the General tab:
  6. In Name, type: AutoBackup

  7. Select the Run whether user is logged on or not radio button.
  8. Select the Run with highest privileges check box.
  9. In the Trigger tab:
  10. Click New. The New Trigger dialog box appears.
  11. Select the Daily radio button. 
  12. Set the start time to 6:00 AM.
  13. Click OK.
  14. In the Actions tab:
  15. Click New. The New Action dialog box appears.
  16. In Settings, in Program/Script, type:
  17. powershell.exe
  18. In Add arguments, type the following, where C:\Users\myLogon\AutoBackup.ps1 is the location of the script that you want to run:
  19. -command “C:\Users\myLogon\AutoBackup.ps1”
  20. Click OK.
  21. In the Create Task dialog box, click OK. When prompted, enter your password.

  22. Verify that the new task works:
  23. In Task Scheduler, in the navigation pane, select Task Scheduler Library.
  24. In the view pane, right-click AutoBackup, then click Run.
I hope u got all the steps required...

cheerssss...:)

  re: automatic scheduling of sharepoint 2010 backup

Jayanarayan replied to Anand Malli
08-Sep-10 05:39 AM
thank you very much  Daivagna

i will try it and let you know.

  re: automatic scheduling of sharepoint 2010 backup

Jayanarayan replied to Anand Malli
08-Sep-10 05:40 AM
thank you very much  Daivagna

i will try it and let you know. also how to know the output of that batch file. pls indicate failure or success after the batch file is executed. it will be easy to find out in future.
  re: automatic scheduling of sharepoint 2010 backup
Jayanarayan replied to Anand Malli
13-Sep-10 02:34 AM
hi deivagna
i tried your script . the task says completed successfully. but when i goto backup folder i don't see any backup folders. pls help me

jayanarayan
  re: automatic scheduling of sharepoint 2010 backup
Anand Malli replied to Jayanarayan
13-Sep-10 02:40 AM
Hi Jayanarayan

append following code snippet @ the end of your powershell script file.

trap [System.Exception]
  {  
    return $("Error: " + $_.Exception.Message);
  }


it will catch if any exception is being raised & display the message on the script..

I hope it will solve your query for success or failure....
  re: automatic scheduling of sharepoint 2010 backup
Jayanarayan replied to Anand Malli
13-Sep-10 03:22 AM
ok. but the backup files and folders are not present. what to do for that?
  re: automatic scheduling of sharepoint 2010 backup
sunardareswar replied to Jayanarayan
05-Jul-11 05:35 AM
Hi Sir,

The script for the Automatic Scheduling is working for me.But can u Tell me how can i restore that back up file again into my new web Application

With Regards,
Annaji.Mantha
  re: automatic scheduling of sharepoint 2010 backup
bharath radhekrishna replied to Jayanarayan
05-Jul-11 06:30 AM
Hi Jayanarayan,

To work Open the scheduler with administrator privileges.

bye
  re: automatic scheduling of sharepoint 2010 backup
Jayanarayan replied to Jayanarayan
05-Jul-11 07:01 AM
hi

you can similarly create the restore script and put in task scheduler. it will automatically restore to the corresponding location.
Create New Account