dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


Backup-DbaDatabase

Performs a backup of a specified type of 1 or more databases on a SQL Server Instance.

These backups may be full, differential or transaction log backups.

More features coming soon!

Screenshots

Examples

This will perform a full database backup on the databases HR and Finance on SQL Server Instance Server1 to Server1’s default backup directory

Backup-DbaDatabase -SqlInstance Server1 -Databases HR, Finance

This will perform a full Copy Only database backup on the databases HR and Finance on SQL Server Instance Server1 striping the files across the 2 fileshares, creaing folders for each database.

Backup-DbaDatabase -SqlInstance Server1 -Databases HR,Finance -Type Full -BackupDirectory \server2\backups

Backs up every database in a normal start on localhost\sqlexpress2016, striping the backups across d:\backups and e:\backups for improved performance. Each DB has it’s own folder under each of the backup paths

Get-DbaDatabase -SqlInstance localhost\sqlexpress2016 -Status Normal -Exclude tempdb | Backup-DbaDatabase -Type diff -BackupDirectory d:\backups

Author

This command was created by Stuart Moore. You can find Stuart on Twitter and his blog.

Get-Help

From PowerShell, execute Get-Help Backup-DbaDatabase -Detailed for more information on this function.

Source Code

Want to see the source code? View Backup-DbaDatabase.ps1 on GitHub
 

Related commands