Below are the sample commands that run on SharePoint Management Shell.
BackUp Site Collection
Backup Site Collection using SharePoint PowerShell
Backup-SPSite -Identity <SiteCollectionGUIDorURL> -Path <BackupFile>[-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]
This parameter is necessary. This parameter represents the site from which you need to take backup. We can use any one of them (ID or Site URL).
Site URL Example :<SiteCollectionGUIDORURL> will replace by ( http://something1:6060/ ) or " 01234567-89ab-cdef-0123-456789abcdef" .
This parameter is necessary. This parameter requires relative path from where you can save the backup file. In addition, backup file extension should be like this (.bak)
Backup Path Example : <BackupFile>will replace by ("C:/site.bak")
This parameter is optional. But when you need to overwrite existing backup file you can use this parameter.
This parameter is optional. Specifies the site collection to remain read and write during the backup. Ordinarily, when you backup site collection it will prevent user for read and write, which means, during backup user will no longer have access to a particular site. This is the default behavior. But if you want to let them, user can read and write site (Backup Site), then we use this parameter. In addition, it will cause corruption in backup.
This parameter is optional. This parameter creates a snapshot of SQL database when starting backup. Moreover, this snapshot will be removed automatically after backup finishes or completes. This will allow user to use site during backup and they have rights for reading and writing. It is not necessary to specify the NositeLock parameterwhenspecifying the SQLSnapShotparameter .
Some Examples with and without parameters
Backup-SPSite http://server_name/sites/site_name -Path C:/Backup/site_name.bak
Restore Site Collection
Restore site collection using PowerShell.
This parameter is necessary. This parameter represent the site from whomfrom which you want to restore. We use any one of them (URL).
<SiteCollectionURL> will replace by (http://something1:6060/)
This parameter is necessary.This parameter require value is at which, you have save in the directory. Moreover, backup file extension should be like this (.bak)
Backup Path Example : <BackupFile> will replace by ("C:/site.bak")
Restore-SPSite -Identity http://CreatNewSiteCollection -path C:/TestBackup.bak
This is the optional parameter. This is name of database server where site collection resides. Moreover , database server name should be correct. It is not necessary to specify name. Instead of not using database name, SharePoint will take care of it by own.
This is the optional parameter. Furthermore, it is necessary to specify.
ContentDatabaseName parameter when specifying DatabaseServerName .
This parameter is optional. But when you need to overwrite existing backup file. You can use this parameter.
Specifies that the site collection being overwritten with the Force parameter should be gradually deleted over time by a timer job instead of all at once, which reduces its impact on SharePoint 2010 Products and SQL Server performance. This option is recommended for large site collections.
A valid URL assigned to the Web application by using alternate access mapping, such as:
Restores a site collection as a host-named site collection instead of a path-based site collection. When the HostHeaderWebApplication parameter is present, the value of the Identity parameter is the URL of the host-named site collection and the value of the HostHeaderWebApplication parameter is the URL of the Web application that will hold the host-named site collection
Hope you understand. If you have any query please contact me. I would love to answer your query.