Friday, 2 October 2015

Windows Task Scheduler SharePoint Backup Script

Create Windows PowerShell script

    Add-PSSnapin Microsoft.SharePoint.PowerShell 
    backup-spsite -identity $args[0] -path $args[1] -force

Create Batch Script to execute PowerShell script

    @echo off
    SET SOURCE_SITE=http://SPFarm:20045/ 
    SET DEST=C:\backup\Backup_site.bak
    echo "backup Started at" %DATE% >> C:\ backup\Log.txt
    powershell -command C:\Scripts\BackupSPSite.ps1  %SOURCE_SITE% %DEST%
    echo "Backup completed successfully at %DEST%" on %DATE% >> C:\ backup\Log.txt
    @echo on

Run Batch Script to execute PowerShell script

  • Run batch script to check successful backup and log creation at c:\backup.
  • Now run it from the Windows Task Scheduler. :)

No comments:

Post a Comment