Skip to content

Latest commit

 

History

History
75 lines (54 loc) · 2.84 KB

managed-backup-sp-backup-on-demand-transact-sql.md

File metadata and controls

75 lines (54 loc) · 2.84 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
managed_backup.sp_backup_on_demand (Transact-SQL)
Requests SQL Server Managed Backup to Microsoft Azure to perform a backup of the specified database.
markingmyname
maghan
randolphwest
08/22/2024
sql
system-objects
reference
smart_admin.sp_backup_on_demand
smart_admin.sp_backup_on_demand_TSQL
sp_backup_on_demand_TSQL
sp_backup_on_demand
smart_admin.sp_backup_on_demand
sp_backup_on_demand
TSQL

managed_backup.sp_backup_on_demand (Transact-SQL)

[!INCLUDE sqlserver2016]

Requests [!INCLUDE ss-managed-backup] to perform a backup of the specified database.

Use this stored procedure to perform ad hoc backups for a database configured with [!INCLUDE ss-managed-backup]. This prevents any break in the backup chain and [!INCLUDE ss-managed-backup] processes are aware and the backup is stored in the same Azure Blob storage container.

Upon successful completion of the backup, the full backup file path is returned. This includes the name and location of the new backup file resulting from the backup operation.

An error is returned if [!INCLUDE ss-managed-backup] is in the process of executing a backup of given type for the specified database. In this case, the error message returned includes the full backup file path where the current backup is being uploaded to.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

EXEC managed_backup.sp_backup_on_demand
    [ @database_name = ] 'database name'
    , [ @type = ] { 'Database' | 'Log' }
[ ; ]

Arguments

[ @database_name = ] 'database name'

The name of the database on which the backup is to be performed. The @database_name is sysname.

[ @type = ] { 'Database' | 'Log' }

The type of backup to be performed: Database or Log. The @type parameter is nvarchar(32).

Return code values

0 (success) or 1 (failure).

Permissions

Requires membership in db_backupoperator database role, with ALTER ANY CREDENTIAL permissions, and EXECUTE permissions on sp_delete_backuphistory stored procedure.

Examples

The following example makes a database backup request for the database TestDB. This database has [!INCLUDE ss-managed-backup] enabled.

USE msdb;
GO

EXEC managed_backup.sp_backup_on_demand
    @database_name = 'TestDB',
    @type = 'Database';
GO