PowerShell script to back up a SharePoint 2010 Site Collection with a unique (date/time) filename

This PowerShell script will backup a SharePoint 2010 (Host Header URL) Site Collection to a single .BAK file with a date and time filename.

Replace the following with your own values:
bkupLoc = NTFS share that .BAK file will be written to.
sitecoll = the URL of your site collection (I’m using it for a HHURL site collection).

Add-PsSnapin Microsoft.SharePoint.Powershell
#Backup location
$bkupLoc = “\\server\share\myscbkupfolder\
#Date
$adate =get-date
#Site collection location
$sitecoll = “http://mysitecoll.mydomain.com
#daily filename
$bkupfile = $bkupLoc+”{0:ddMMMyyyyhhmm}”-f$adate+”.bak”
Backup-SPSite -Identity $sitecoll -Path $bkupfile

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: