Specify the type of backup: full, differential, or transaction log. If the database is a part of an availability group, then cluster name and availability group name are used instead of server name and instance name. This is the default.īack up to the directories C:\Backup and D:\Backup.īack up to the network share \\Server1\Backup.īack up to the network shares \\Server1\Backup and \\Server2\Backup.ĭatabaseBackup creates a directory structure with server name, instance name, database name, and backup type under the backup root directory. Valueīack up to the SQL Server default backup directory. If no directory is specified, then the SQL Server default backup directory is used. Specify multiple directories by using the comma (,). If you specify multiple directories, then the backup files are striped evenly across the directories. Specify backup root directories, which can be local directories or network shares. USER_DATABASES, -AVAILABILITY_GROUP_DATABASESĪll user databases that are not in availability groupsĪll databases that have “Db” in the name, except Db1Īll databases that do not have “Db” in the name ValueĪll system databases (master, msdb, and model) All of these operations can be combined by using the comma (,). The hyphen character (-) is used to exclude databases, and the percent character (%) is used for wildcard selection. The keywords SYSTEM_DATABASES, USER_DATABASES, ALL_DATABASES, and AVAILABILITY_GROUP_DATABASES are supported. The SQL Server Maintenance Solution is free. The SQL Server Maintenance Solution is available on GitHub.
You can also download the objects as separate scripts. This script creates all the objects and jobs that you need. Downloadĭownload MaintenanceSolution.sql. DatabaseBackup is supported on SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 2014, SQL Server 2016, SQL Server 2017, SQL Server 2019, and Azure SQL Database Managed Instance. DatabaseBackup is the SQL Server Maintenance Solution’s stored procedure for backing up databases.