Geeks With Blogs

News invisible hit counter View My Stats
Technical Speaking

You need to make scheduled nightly backups using powershell or stsadm.  You would like to schedule regular backups using windows scheduled but how to create the batch files to run the powershell backup.  I had the same problem and I am showing you how to solve this:

PowerShell Command to backup SharePoint Site Collection

backup-spsite -identity http://SPServer:10001/ -path C:\Backup\Backup.bak

OR backup-spsite -identity http://SPServer:10001/ -path C:\Backup\Backup.bak –force (use force to overwrite existing file)

So, You can use backup-spsite to do http://SPServer:10001/ site backup.  For example, the follow script will start a full backup to C:\backup where you can send site collection URL and backup file name as parameter to PowerShell Script

$args[0] = http://SPServer:10001/ and

$args[1] = C:\backup\backup_site.bak

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

Save it as C:\Scripts\BackupSPSite.ps1 as Windows PowerShell script files are .ps1 files. And put the following inside your batch file to run from Windows Task Scheduler.

@echo off

SET SOURCE_SITE=http://SPServer:10001/
SET DEST=c:\backup\Backup_site.bak

powershell -command C:\Scripts\BackupSPSite.ps1  %SOURCE_SITE% %DEST%

Save it as C:\Scripts\BackupSPSite.bat run it from Task scheduler. In task scheduler, the account need to be set with admin permissions to run it properly.

You can use it to keep your daily backup of SharePoint Site. You can also do entire Farm backup using the following command in PowerShell Script

Backup-SPFarm -Directory C:\Backup -BackupMethod full

Posted on Wednesday, December 29, 2010 2:04 AM Sharepoint 2007 , SharePoint 2010 | Back to top

Comments on this post: SharePoint Backup Script using PowerShell Command

# re: SharePoint Backup Script using PowerShell Command
Requesting Gravatar...
Download the complete script from
Left by Admin on Mar 14, 2011 6:36 PM

# re: SharePoint Backup Script using PowerShell Command
Requesting Gravatar...
will this also work for sharepoint 2007 ?

I want to use it for sharepoint 2007 using powershell but i guess the powershell comdlet is not compatible with SharePoint 2007.

kindly suggest

Left by yogendra on Mar 14, 2013 7:36 PM

# re: SharePoint Backup Script using PowerShell Command
Requesting Gravatar...
Find MOSS 2007 Power shell Script at
Left by Admin on Jun 08, 2013 3:20 PM

Your comment:
 (will show your gravatar)

Copyright © MJ Ferdous | Powered by: