이 단원에서는 Azure Storage에서 온-프레미스 또는 Azure의 가상 머신에 있는 데이터베이스로 데이터베이스 백업 파일을 복원하는 방법을 알아봅니다. 이 단원을 따르려면 4단원, 5단원, 6, 7, 8단원을 완료할 필요가 없습니다.
이 단원에서는 이미 다음 단계를 완료한 것으로 가정합니다.
원본 컴퓨터에서 데이터베이스를 만들었습니다.
Azure Blob Storage 서비스에서 SQL Server 백업 및 복원 기능을 사용하여 Azure Storage에서 데이터베이스(.bak)의 백업을 만들었습니다. 이 단계에서는 다른 SQL Server 자격 증명을 만들어야 합니다. 이 자격 증명은 스토리지 계정 키를 사용합니다.
Azure Storage 계정이 있습니다.
Azure Storage 계정으로 컨테이너를 만들었습니다.
읽기, 쓰기 및 목록 권한이 있는 컨테이너에 정책을 만들었습니다. SAS 키도 생성했습니다.
Azure Storage 통합 기능을 위해 머신에 SQL Server 자격 증명을 만들었습니다. 이 자격 증명에는 SAS(공유 액세스 서명) 키가 필요합니다.
Azure Storage에서 데이터베이스를 복원하려면 다음 단계를 수행할 수 있습니다.
SQL Server Management Studio를 시작합니다. 기본 인스턴스에 연결합니다.
표준 도구 모음에서 새 쿼리 를 클릭합니다.
다음 전체 스크립트를 복사하여 쿼리 창에 붙여넣습니다. 필요에 따라 스크립트를 수정합니다.
메모: 문을
RESTORE실행하여 Azure Storage의 데이터베이스 백업(.bak)을 다른 컴퓨터의 데이터베이스 인스턴스로 복원합니다.USE master GO -- Create a new database to be backed up. CREATE DATABASE TestDbRestoreFrom; GO USE TestDbRestoreFrom; GO CREATE TABLE Table1 (Col1 int primary key, Col2 varchar(20)); GO INSERT INTO Table1 (Col1, Col2) VALUES (1, 'string1'), (2, 'string2'); GO USE TestDbRestoreFrom; GO SELECT * from dbo.Table1; GO -- Create a credential to be used by SQL Server Backup and Restore with Azure -----Blob Storage Service. USE master; GO CREATE CREDENTIAL BackupCredential WITH IDENTITY= 'teststorageaccnt', SECRET = 'BO1nH/lWRdnc8TGPlQIXmGLWVCoEa48suYSGiAlC73+S0TX5VXo5/LCm8qiyGCYafDg4ZsueDIV3GQ5RXHaRGw==' GO -- Display the newly created credential SELECT * from sys.credentials -- Create a backup in Azure Storage. BACKUP DATABASE TestDBRestoreFrom TO URL = 'https://teststorageaccnt.blob.core.windows.net/testrestorefrom/TestDBRestoreFrom.bak' WITH CREDENTIAL = 'BackupCredential' ,COMPRESSION ,STATS = 5; GO -- Create a Shared Access Signature credential CREATE CREDENTIAL [https://teststorageaccnt.blob.core.windows.net/testrestorefrom] WITH IDENTITY='SHARED ACCESS SIGNATURE', SECRET = 'sv=2012-02-12&sr=c&si=policy_resfrom&sig=EhVpzLUXjG4ThAMLmVhrnoiCt8IfmD3BsuYiMawGzxc%3D' GO USE master; GO RESTORE DATABASE TestDBRestoreFrom FROM URL = 'https://teststorageaccnt.blob.core.windows.net/testrestorefrom/TestDBRestoreFrom.bak' WITH CREDENTIAL = 'BackupCredential', REPLACE, MOVE 'TestDBRestoreFrom' TO 'C:\Backup\TestDBRestoreFrom.mdf', MOVE 'TestDBRestoreFrom_log' TO 'C:\Backup\TestDBRestoreFrom_log.ldf'; GO
자습서의 끝: Azure Storage 서비스의 SQL Server 데이터 파일