Created
August 17, 2017 07:55
-
-
Save matejskubic/c6fae79a36d583df7e8674296b8cb6cd to your computer and use it in GitHub Desktop.
Backup SQL DB to azure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @dbToBackup as sysname = 'AxDB' | |
DECLARE @container as nvarchar(50) = lower(HOST_NAME()) | |
DECLARE @file as nvarchar(100) = @dbToBackup + N'_' + FORMAT(GETDATE(), N'yyyy-MM-dd_hhmmss') + N'.bak' | |
DECLARE @destUrl as nvarchar(500) = N'https://storageaccount.blob.core.windows.net/' + @container + N'/' + @file | |
PRINT @destUrl | |
BACKUP DATABASE @dbToBackup TO | |
URL = @destUrl | |
WITH NOFORMAT, NOINIT, NAME = N'Ax-Full Database Backup', NOSKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10 | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See (https://gist.github.com/matejskubic/dc1aabb5d3578a53fa32d14fc8ddcf38) for creation SQL Credention for SAS