Presentation is loading. Please wait.

Presentation is loading. Please wait.

Thank You! Local PASS Community & Sponsors!. Restoring a SQL Server database from Azure Blob Storage (200-level) Randolph

Similar presentations


Presentation on theme: "Thank You! Local PASS Community & Sponsors!. Restoring a SQL Server database from Azure Blob Storage (200-level) Randolph"— Presentation transcript:

1 Thank You! Local PASS Community & Sponsors!

2 Restoring a SQL Server database from Azure Blob Storage (200-level) Randolph West @rabryst r@ndolph.ca

3 Meet The Contestants Azure Blob Storage No Local Backups Service Level Agreement Recovery Time Objective

4 Pop Quiz, Hotshot What do you do?

5 To The Cloud! Restore from Azure Blob Storage! TO THE CLOUD!

6 How Backups Work: A Refresher  TechNet article by Paul Randal  Understanding SQL Server Backups: https://goo.gl/OlSAEl https://goo.gl/OlSAEl Paul Randal / TechNet Magazine

7 How Backups Work: A Refresher (2)  Full Recovery Model  Full Backup (transactionally-consistent point in time)  Differential Backup (yes, affected by full backups)  Transaction Log Backup (no, not affected by full backups)  Supports point-in-time recovery.

8 How Backups Work: A Refresher (3)  Full Recovery Model with Differential and Log Backups Paul Randal / TechNet Magazine

9 How Backups Work: A Refresher (4)  Bulk-Logged Model  Does not support point-in-time recovery  Simple Recovery Model  Full Backup (transactionally-consistent point in time)  Read more from Paul Randal: http://goo.gl/LeIQpv http://goo.gl/LeIQpv

10 SQL Server Backup Using Azure Blob Storage  SQL Server 2012 SP1 Cumulative Update 2 and later  Requires extra credentials  Supported by Ola Hallengren’s Maintenance Solution  The Curious Incident of the Infinite Lease in the Night Time.

11 Demo  Set up Azure Blob Storage account and credentials  SQL Server backup to Azure:  built-in method  Ola Hallengren’s method.

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32 Demo  Set up Azure Blob Storage account and credentials  SQL Server backup to Azure:  built-in method  Ola Hallengren’s method.

33 Is there a better way?  Back up any SQL Server database to Azure Blob Storage  Download only the files needed to restore the latest backup  All you need to know is the database name  Gratis.

34 Leverages Ola Hallengren’s Maintenance Solution  https://ola.hallengren.com/sql-server-backup.html https://ola.hallengren.com/sql-server-backup.html  Known Naming Convention:  SERVER$INSTANCE_DB_TYPE_yyyyMMdd_HHmmSS.bak  Used by thousands of DBAs all over the world  No need to use built-in Azure backup method.

35 What About Other Backup Methods?  Anything goes:  strong naming convention, including a DB name and date and time  Code your own:  It’s free!

36 SQL Server Backup Using Blob Storage Redux  Introducing the AzureBlobStorageSync tool  Custom expiration date for backup files  Uses naming convention from known backup solutions.

37 SQL Server Backup Using Blob Storage Redux (2)  No file lease, easier maintenance  Quickly parse tens of thousands of files  DOES NOT NEED TO RUN ON THE DATABASE SERVER!  Already being used in a production environment.

38 Demo  SQL Server backup to Azure using AzureBlobStorageSync.

39 AzureBlobStorageSync Configuration File

40 AzureBlobStorageSync Connection Settings <add name="StorageConnectionString" connectionString= "DefaultEndpointsProtocol=https;AccountName=motorfinity ;AccountKey= " />

41 AzureBlobStorageSync Configuration File

42 AzureBlobStorageSync Sample Output AzureBlobStorageSync version 1.0.0.0 Copyright (c) 2015 Randolph West. All rights reserved. Fetching list of files on local machine... Fetching list of items in Azure Blob Storage... Starting file comparison... Uploading file [demo.bak] Deleting file [JUPITER\demo\FULL\JUPITER_demo_FULL_20140114_163153.bak]

43 That’s Cool, But What About Restoring?  AzureBlobStorageRestore  Downloads only the required files, and generates a SQL restore script.

44 Demo  Restore SQL Server backup using AzureBlobStorageRestore.

45 AzureBlobStorageRestore Configuration File

46 AzureBlobStorageRestore Sample Output AzureBlobStorageRestore version 1.0.0.0 Copyright (c) 2015 Randolph West. All rights reserved. Fetching list of items in Azure Storage... Number of items found in Azure Container: 10913 Starting file review... Downloading file [MF_MIB/FULL/WIN_MF_MIB_FULL_20150623_000016.bak] Downloading file [MF_MIB/DIFF/WIN_MF_MIB_DIFF_20150623_070002.bak] Downloading file [MF_MIB/LOG/WIN_MF_MIB_LOG_20150623_070003.bak] Downloading file [MF_MIB/LOG/WIN_MF_MIB_LOG_20150623_071501.bak] Downloading file [MF_MIB/LOG/WIN_MF_MIB_LOG_20150623_073004.bak] Downloading file [MF_MIB/LOG/WIN_MF_MIB_LOG_20150623_074501.bak]

47 AzureBlobStorageRestore T-SQL Restore Script -- Cloud Storage Restore Script, to restore -- ABSR_MF_MIB. Generated on 2015-06-22 23:55:53 USE [master]; GO IF DB_ID('[ABSR_MF_MIB]') IS NOT NULL ALTER DATABASE [ABSR_MF_MIB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GO

48 AzureBlobStorageRestore T-SQL Restore Script (2) DECLARE @fullBackup NVARCHAR(MAX) = N'D:\SQLData\Backup\MF_MIB\FULL\WIN- OS2G5MRT4UH_MF_MIB_FULL_20150623_000016.bak'; DECLARE @path NVARCHAR(255) = N'D:\Temp\_ABSR_'; DECLARE @template NVARCHAR(MAX) = N' RESTORE DATABASE [ABSR_MF_MIB] FROM DISK = N''D:\SQLData\Backup\MF_MIB\FULL\WIN- OS2G5MRT4UH_MF_MIB_FULL_20150623_000016.bak'' WITH {%MOVE%} REPLACE, NOUNLOAD, NORECOVERY, STATS = 5;';

49 AzureBlobStorageRestore T-SQL Restore Script (3) DECLARE @FileListInfo TABLE (…); DECLARE @sql NVARCHAR(MAX) = N'', @i INT, @x INT = 1; DECLARE @header NVARCHAR(MAX) = 'RESTORE FILELISTONLY FROM DISK = ''D:\SQLData\Backup\MF_MIB\FULL\WIN- OS2G5MRT4UH_MF_MIB_FULL_20150623_000016.bak'''; INSERT INTO @FileListInfo EXEC (@header);

50 AzureBlobStorageRestore T-SQL Restore Script (4) RESTORE DATABASE [ABSR_MF_MIB] FROM DISK = N'D:\SQLData\Backup\MF_MIB\FULL\WIN- OS2G5MRT4UH_MF_MIB_FULL_20150623_000016.bak‘ WITH MOVE N'MF_MIB' TO N'D:\Temp\_ABSR_MF_MIB.mdf', MOVE N'MF_Audit' TO N'D:\Temp\_ABSR_MF_Audit.ndf', MOVE N'MF_MIB_log' TO N'D:\Temp\_ABSR_MF_MIB_log.ldf', REPLACE, NOUNLOAD, NORECOVERY, STATS = 5;

51 AzureBlobStorageRestore T-SQL Restore Script (5) RESTORE DATABASE [ABSR_MF_MIB] FROM DISK = N'D:\SQLData\Backup\MF_MIB\DIFF\WIN- OS2G5MRT4UH_MF_MIB_DIFF_20150623_070002.bak' WITH FILE = 1, NOUNLOAD, REPLACE, NORECOVERY, STATS = 5; GO RESTORE LOG [ABSR_MF_MIB] FROM DISK = N'D:\SQLData\Backup\MF_MIB\LOG\WIN- OS2G5MRT4UH_MF_MIB_LOG_20150623_070003.trn' WITH FILE = 1, NOUNLOAD, REPLACE, NORECOVERY, STATS = 5; GO

52 AzureBlobStorageRestore T-SQL Restore Script (6) RESTORE DATABASE [ABSR_MF_MIB] WITH RECOVERY; GO ALTER DATABASE [ABSR_MF_MIB] SET MULTI_USER; GO DBCC CHECKDB ([ABSR_MF_MIB]) WITH ALL_ERRORMSGS, NO_INFOMSGS, DATA_PURITY; GO

53 How Does It Work?  Written in C# with standard Azure Storage DLL  Requires.NET Framework 4.x  DOES NOT NEED TO RUN ON THE DATABASE SERVER  UNC path to backups, can run on any network-connected machine  Test restores can be run independently.

54 Summary Of This Thing I Made  Free!  MIT License  Available right now on GitHub:  https://github.com/bornsql/azureblobstoragesync https://github.com/bornsql/azureblobstoragesync

55 Storage Wars  Amazon S3 support  Sync and Restore with the same ease as Azure Blob Storage  Network support  Sync and Restore with a network file share  Introducing:  CloudStorageSync  CloudStorageRestore  Now you can back up to all three at the same time:  Geo-redundant, highly distributed database backups.

56 Call Me, Maybe  Ask your questions  Email: r@ndolph.ca  Twitter: @rabryst  Complete your evaluation form, please! Images from freeimages.com, unsplash.com and technet.microsoft.com


Download ppt "Thank You! Local PASS Community & Sponsors!. Restoring a SQL Server database from Azure Blob Storage (200-level) Randolph"

Similar presentations


Ads by Google