Technical Speaking

Trying to make life easier for SharePoint people
posts - 58, comments - 60, trackbacks - 2

My Links

News


MJ Ferdous

MJ Ferdous is an IT professional from 7 years ago.

He is Technical Project Manager of Congral LLC, USA and SharePoint Consultant as well. He has industry level experience on SharePoint Server (MOSS 2007/2010) and did lots of Presentation & workshop on SharePoint.

He did work in OT Group SPA,Italy as SharePoint Consultant. He did lot of international projects during his professional life. For example: Software development for Internet Banking Portal, TCI on Canadian tourism sector, Rockwell MES solution for international pharmaceuticals companies and so on. He is the author of several technical article.

He is also Technical Author of DevMedia Group(Mrbool.com) as well as owner & modaretor of several groups of sharepoint and asp.net.. Looking for a Offshore Development partnership.............. in ASP.Net & Sharepoint 2007,2010.

invisible hit counter View My Stats

Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

Blogs [MVP]

My Articles

My Others Link

Public Speaking

Wednesday, December 29, 2010

SharePoint Backup Script using PowerShell Command

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 | Feedback (1) | Filed Under [ Sharepoint 2007 SharePoint 2010 ]

Powered by: