Skip to content

Commit 1fd344e

Browse files
authored
Merge pull request #113161 from stevestein/sql-edge-1
SQL Edge - adding new articles
2 parents 6ce19de + 5d6cda6 commit 1fd344e

File tree

9 files changed

+1224
-0
lines changed

9 files changed

+1224
-0
lines changed
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
---
2+
title: Backup and restore databases in Azure SQL Edge Preview
3+
description: Learn about backup and restore capabilities in Azure SQL Edge Preview
4+
keywords:
5+
services: sql-database-edge
6+
ms.service: sql-database-edge
7+
ms.topic: conceptual
8+
author: SQLSourabh
9+
ms.author: sourabha
10+
ms.reviewer: sstein
11+
ms.date: 04/28/2020
12+
---
13+
14+
# Backup and Restore databases in Azure SQL Edge Preview
15+
16+
Azure SQL Edge is built on the latest versions of the Microsoft SQL Server Database Engine on Linux, providing similar backup and restore database capabilities as those available in SQL Server on Linux and SQL Server running in containers. Backup and restore component provides an essential safeguard for protecting data stored in your Azure SQL Edge databases. To minimize the risk of catastrophic data loss, its recommended that you back up your databases periodically to preserve modifications to your data on a regular basis. A well-planned backup and restore strategy helps protect databases against data loss caused by a variety of failures. Test your strategy by restoring a set of backups and then recovering your database to prepare you to respond effectively to a disaster.
17+
18+
To read more about why backups are important, please refer [Back Up and Restore of SQL Server Databases](https://docs.microsoft.com/sql/relational-databases/backup-restore/back-up-and-restore-of-sql-server-databases?view=sql-server-ver15).
19+
20+
Azure SQL Edge supports backing up and restoring from both local storage or from Azure blobs. For more information on backup to and restore from Azure Blob Storage, refer [SQL Server Backup and Restore with Microsoft Azure Blob Storage Service](https://docs.microsoft.com/sql/relational-databases/backup-restore/sql-server-backup-and-restore-with-microsoft-azure-blob-storage-service?view=sql-server-ver15) and [SQL Server Backup to URL](https://docs.microsoft.com/sql/relational-databases/backup-restore/sql-server-backup-to-url?view=sql-server-ver15).
21+
22+
## Backing up a database in Azure SQL Edge
23+
24+
Azure SQL Edge supports the same backup types as supported by SQL Server. For a complete list of the backup types supported in SQL Server, refer [Backup Overview](https://docs.microsoft.com/sql/relational-databases/backup-restore/backup-overview-sql-server?view=sql-server-ver15).
25+
26+
> [!IMPORTANT]
27+
> Databases created in Azure SQL Edge use simple recovery model by default. As such log backups cannot be performed on these databases. If there is a need to perform log backups on these databases, an administrator would need to change the database recovery model to full recovery model. For a complete list of recovery models supported by SQL Server, refer [Recovery Model Overview](https://docs.microsoft.com/sql/relational-databases/backup-restore/recovery-models-sql-server?view=sql-server-ver15#RMov).
28+
29+
### Backup to local disk
30+
31+
In the example provided below, BACKUP DATABASE Transact-SQL command to create a database backup in the container. For the purpose of this example, a new folder called "backup" is created to store the backup files.
32+
33+
1. Create a folder to for the backups. This command needs to be executed on the host where your Azure SQL Edge container is running. In the command below replace **<AzureSQLEdge_Container_Name>** with the name of Azure SQL Edge container in your deployment.
34+
35+
```bash
36+
sudo docker exec -it <AzureSQLEdge_Container_Name> mkdir /var/opt/mssql/backup
37+
```
38+
39+
2. Connect to the Azure SQL Edge instance using SQL Server Management Studio (SSMS) or using Azure Data Studio (ADS) and run the Backup database command to take the backup of your user database. In the example below, we are taking the backup of the *IronOreSilicaPrediction* database.
40+
41+
```sql
42+
BACKUP DATABASE [IronOreSilicaPrediction]
43+
TO DISK = N'/var/opt/mssql/backup/IronOrePredictDB.bak'
44+
WITH NOFORMAT, NOINIT, NAME = N'IronOreSilicaPrediction-Full Database Backup',
45+
SKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10
46+
GO
47+
```
48+
49+
3. After you run the command and if the backup of the database is successful, you'll messages similar to the following in the results section of SSMS or ADS.
50+
51+
```txt
52+
10 percent processed.
53+
20 percent processed.
54+
30 percent processed.
55+
40 percent processed.
56+
50 percent processed.
57+
60 percent processed.
58+
70 percent processed.
59+
80 percent processed.
60+
90 percent processed.
61+
100 percent processed.
62+
Processed 51648 pages for database 'IronOreSilicaPrediction', file 'IronOreSilicaPrediction' on file 1.
63+
Processed 2 pages for database 'IronOreSilicaPrediction', file 'IronOreSilicaPrediction_log' on file 1.
64+
BACKUP DATABASE successfully processed 51650 pages in 3.588 seconds (112.461 MB/sec).
65+
66+
Completion time: 2020-04-09T23:54:48.4957691-07:00
67+
```
68+
69+
### Backup to URL
70+
71+
Azure SQL Edge supports backups to both page blobs and block blobs. For more information on page blobs and block blobs, refer [Backup to Block blob vs Page blob](https://docs.microsoft.com/sql/relational-databases/backup-restore/sql-server-backup-to-url?view=sql-server-ver15#blockbloborpageblob). In the example below, database *IronOreSilicaPrediction* is being backed up to a block blob.
72+
73+
1. The first step in configuring backups to block blobs is to generate a shared access signature (SAS) token that can be used to create a SQL Server Credential on Azure SQL Edge. The script creates a Shared Access Signature that is associated with a Stored Access Policy. For more information, see [Shared Access Signatures, Part 1: Understanding the SAS Model](https://azure.microsoft.com/documentation/articles/storage-dotnet-shared-access-signature-part-1/). The script also writes the T-SQL command required to create the credential on SQL Server. The script below assumes that you already have an Azure subscription with a storage account and a storage container for the backups.
74+
75+
```PowerShell
76+
# Define global variables for the script
77+
$subscriptionName='<your subscription name>' # the name of subscription name you will use
78+
$resourcegroupName = '<your resource group name>' # the name of resource group you will use
79+
$storageAccountName= '<your storage account name>' # the storage account name you will use for backups
80+
$containerName= '<your storage container name>' # the storage container name to which you will attach the SAS policy with its SAS token
81+
$policyName = 'SASPolicy' # the name of the SAS policy
82+
83+
# adds an authenticated Azure account for use in the session
84+
Login-AzAccount
85+
86+
# set the tenant, subscription and environment for use in the rest of
87+
Select-AzSubscription -Subscription $subscriptionName
88+
89+
# Generate the SAS token
90+
$sa = Get-AzStorageAccount -ResourceGroupName $resourcegroupName -Name $storageAccountName
91+
$storagekey = Get-AzStorageAccountKey -ResourceGroupName $resourcegroupName -Name $storageAccountName
92+
$storageContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storagekey[0].Value
93+
$cbc = Get-AzStorageContainer -Name $containerName -Context $storageContext
94+
$policy = New-AzStorageContainerStoredAccessPolicy -Container $containerName -Policy $policyName -Context $storageContext -ExpiryTime $(Get-Date).ToUniversalTime().AddYears(10) -Permission "rwld"
95+
$sas = New-AzStorageContainerSASToken -Policy $policyName -Context $storageContext -Container $containerName
96+
Write-Host 'Shared Access Signature= '$($sas.Substring(1))''
97+
98+
# Outputs the Transact SQL to the clipboard and to the screen to create the credential using the Shared Access Signature
99+
Write-Host 'Credential T-SQL'
100+
$tSql = "CREATE CREDENTIAL [{0}] WITH IDENTITY='Shared Access Signature', SECRET='{1}'" -f $cbc.CloudBlobContainer.Uri.AbsoluteUri,$sas.Substring(1)
101+
$tSql | clip
102+
Write-Host $tSql
103+
```
104+
105+
After successfully running the script, copy the CREATE CREDENTIAL command to a query tool, connect to an instance of SQL Server and run the command to create the credential with the Shared Access Signature.
106+
107+
2. Connect to the Azure SQL Edge instance using SQL Server Management Studio (SSMS) or using Azure Data Studio (ADS) and create the credential using the command from the previous step. Make sure to replace the CREATE CREDENTIAL command with the actual output from the previous step.
108+
109+
```sql
110+
IF NOT EXISTS
111+
(SELECT * FROM sys.credentials
112+
WHERE name = 'https://<mystorageaccountname>.blob.core.windows.net/<mystorageaccountcontainername>')
113+
CREATE CREDENTIAL [https://<mystorageaccountname>.blob.core.windows.net/<mystorageaccountcontainername>]
114+
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
115+
SECRET = '<SAS_TOKEN>';
116+
```
117+
118+
3. The following command takes a backup of the *IronOreSilicaPrediction* to the Azure storage container.
119+
120+
```sql
121+
BACKUP DATABASE IronOreSilicaPrediction
122+
TO URL = 'https://<mystorageaccountname>.blob.core.windows.net/<mycontainername>/IronOreSilicaPrediction.bak'
123+
With MAXTRANSFERSIZE = 4194304,BLOCKSIZE=65536;
124+
GO
125+
```
126+
127+
## Restoring a database in Azure SQL Edge
128+
129+
Azure SQL Edge supports restoring from both a local disk, a network location or from an Azure Blob Storage account. For an overview of Restore and Recovery in SQL Server, refer [Restore and Recovery Overview](https://docs.microsoft.com/sql/relational-databases/backup-restore/restore-and-recovery-overview-sql-server?view=sql-server-ver15). For an overview of the simple recovery model in SQL Server, refer [Complete Database Restores (Simple Recovery Model)](https://docs.microsoft.com/sql/relational-databases/backup-restore/complete-database-restores-simple-recovery-model?view=sql-server-ver15).
130+
131+
### Restore from local disk
132+
133+
This example uses the *IronOreSilicaPrediction* backup performed in the previous example for restoration as a new database with a different name.
134+
135+
1. If the database backup file is not already present in the container, you can use the command below to copy the file into the container. The example below assumes that the backup file is present on the local host and is being copied to the /var/opt/mssql/backup folder into an Azure SQL Edge container named sql1.
136+
137+
```bash
138+
sudo docker cp IronOrePredictDB.bak sql1:/var/opt/mssql/backup
139+
```
140+
141+
2. Connect to the Azure SQL Edge instance using SQL Server Management Studio (SSMS) or using Azure Data Studio (ADS) to execute the restore command. In the example below, the **IronOrePredictDB.bak** is restored to create a new database **IronOreSilicaPrediction_2**
142+
143+
```sql
144+
Restore FilelistOnly from disk = N'/var/opt/mssql/backup/IronOrePredictDB.bak'
145+
146+
Restore Database IronOreSilicaPrediction_2
147+
From disk = N'/var/opt/mssql/backup/IronOrePredictDB.bak'
148+
WITH MOVE 'IronOreSilicaPrediction' TO '/var/opt/mssql/data/IronOreSilicaPrediction_Primary_2.mdf',
149+
MOVE 'IronOreSilicaPrediction_log' TO '/var/opt/mssql/data/IronOreSilicaPrediction_Primary_2.ldf'
150+
```
151+
152+
3. After you run the restore command and if the restore operation was successful, you'll see the messages similar to the following in the output window.
153+
154+
```txt
155+
Processed 51648 pages for database 'IronOreSilicaPrediction_2', file 'IronOreSilicaPrediction' on file 1.
156+
Processed 2 pages for database 'IronOreSilicaPrediction_2', file 'IronOreSilicaPrediction_log' on file 1.
157+
RESTORE DATABASE successfully processed 51650 pages in 6.543 seconds (61.670 MB/sec).
158+
159+
Completion time: 2020-04-13T23:49:21.1600986-07:00
160+
```
161+
162+
### Restore from URL
163+
164+
Azure SQL Edge also supports restoring a database from an Azure Storage account. Restores can be performed from either the block blobs or page blob backups. In the example provided below, the *IronOreSilicaPrediction_2020_04_16.bak* database backup file on a block blob is restored to create the database *IronOreSilicaPrediction_3*.
165+
166+
```sql
167+
RESTORE DATABASE IronOreSilicaPrediction_3
168+
FROM URL = 'https://mystorageaccount.blob.core.windows.net/mysecondcontainer/IronOreSilicaPrediction_2020_04_16.bak'
169+
WITH MOVE 'IronOreSilicaPrediction' TO '/var/opt/mssql/data/IronOreSilicaPrediction_Primary_3.mdf',
170+
MOVE 'IronOreSilicaPrediction_log' TO '/var/opt/mssql/data/IronOreSilicaPrediction_Primary_3.ldf',
171+
STATS = 10;
172+
```
173+
174+
175+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: Configure replication to Azure SQL Edge Preview
3+
description: Learn about configuring replication to Azure SQL Edge
4+
keywords:
5+
services: sql-database-edge
6+
ms.service: sql-database-edge
7+
ms.topic: conceptual
8+
author: SQLSourabh
9+
ms.author: sourabha
10+
ms.reviewer: sstein
11+
ms.date: 04/28/2020
12+
---
13+
14+
# Configure replication to Azure SQL Edge Preview
15+
16+
Azure SQL Edge instance can be configured as the push subscriber for a one-way transactional replication or snapshot replication. Azure SQL Edge instance cannot act as the publisher or the distributor for a transactional replication configuration. Merge Replication, P2P Replication, Oracle Publishing are not supported with Azure SQL Edge.
17+
18+
## **Supported configurations**:
19+
20+
- Azure SQL Edge instance must be a push subscriber for a publisher.
21+
- The publisher and the distributor can be either
22+
- An instance of SQL Server running on-premises or an instance of SQL Server running in an Azure virtual machine. For more information, see [SQL Server on Azure Virtual Machines overview](https://azure.microsoft.com/documentation/articles/virtual-machines-sql-server-infrastructure-services/). SQL Server instances must be using a version greater than SQL Server 2016.
23+
- An instance of Azure SQL Database Managed Instance. Managed Instance can host publisher, distributor, and subscriber databases. For more information, see [Replication with SQL Database Managed Instance](https://docs.microsoft.com/azure/sql-database/replication-with-sql-database-managed-instance/).
24+
25+
- The distribution database and the replication agents cannot be placed on an Azure SQL Edge instance.
26+
27+
> [!NOTE]
28+
> Attempting to configure replication using an unsupported version can result in error number MSSQL_REPL20084 (The process could not connect to Subscriber.) and MSSQL_REPL40532 (Cannot open server \<name> requested by the login. The login failed.).
29+
30+
To use all the features of Azure SQL Edge, you must be using the latest versions of [SQL Server Management Studio](https://docs.microsoft.com/sql/ssms/download-sql-server-management-studio-ssms) and [SQL Server Data Tools](https://docs.microsoft.com/sql/ssdt/download-sql-server-data-tools-ssdt).
31+
32+
## Remarks
33+
34+
- Replication can be configured by using [SQL Server Management Studio](https://docs.microsoft.com/sql/ssms/download-sql-server-management-studio-ssms) or by executing Transact-SQL statements on the publisher using either SQL Server Management Studio or [Azure Database Studio](https://docs.microsoft.com/sql/azure-data-studio/download-azure-data-studio)
35+
- Replication can only use SQL Server authentication logins to connect to an Azure SQL Edge instance.
36+
- Replicated tables must have a primary key.
37+
- A single publication on SQL Server can support both Azure SQL Edge and SQL Server (on-premises and SQL Server in an Azure virtual machine) subscribers.
38+
- Replication management, monitoring, and troubleshooting must be performed from the on-premises SQL Server.
39+
- Only push subscriptions to Azure SQL Edge are supported.
40+
- Only `@subscriber_type = 0` is supported in **sp_addsubscription** for Azure SQL Edge.
41+
- Azure SQL Edge does not support bi-directional, immediate, updatable, or peer to peer replication.
42+
- Azure SQL Edge only supports a subset of features available in SQL Server or Azure SQL Database Managed Instance, as such an attempt to replicate a database (or objects within the database) which contain one or more unsupported features will result in a failure. For example, attempting to replicate a database which contains objects with spatial data types will result in an error. For more information on features supported by Azure SQL Edge, see [Supported features of Azure SQL Edge](features.md).
43+
44+
## Scenarios
45+
46+
### Initializing reference data on an Edge instance
47+
48+
A common scenario where replication can be useful is when there is a need to initialize the edge instance with reference data which changes over time. For example, updating ML models on the Edge instance after they have been trained on an on-premises SQL Server instance.
49+
50+
1. Create a transactional replication publication on an on-premises SQL Server database.
51+
2. On the on-premises SQL Server use the **New Subscription Wizard** or Transact-SQL statements to create a push to subscription to Azure SQL Edge.
52+
3. The replicated database on Azure SQL Edge can be initialized by either using a snapshot generated by the snapshot agent and distributed and delivered by the distribution agent or using a backup of the database from the publisher. Once again, if the database backup contains objects/features that are not supported by Azure SQL Edge, the restore operation will fail.
53+
54+
## Limitations
55+
56+
The following options are not supported for Azure SQL Edge subscriptions:
57+
58+
- Copy file groups association
59+
- Copy table partitioning schemes
60+
- Copy index partitioning schemes
61+
- Copy user defined statistics
62+
- Copy default bindings
63+
- Copy rule bindings
64+
- Copy fulltext indexes
65+
- Copy XML XSD
66+
- Copy XML indexes
67+
- Copy permissions
68+
- Copy spatial indexes
69+
- Copy filtered indexes
70+
- Copy data compression attribute
71+
- Copy sparse column attribute
72+
- Copy filestream, hierarchyid or spatial data types.
73+
- Convert hierarchyid to MAX data types
74+
- Convert spatial to MAX data types
75+
- Copy extended properties
76+
- Copy permissions
77+
78+
## Examples
79+
80+
Create a publication and a push subscription. For more information, see:
81+
82+
- [Create a Publication](https://docs.microsoft.com/sql/relational-databases/replication/publish/create-a-publication)
83+
- [Create a Push Subscription](https://docs.microsoft.com/sql/relational-databases/replication/create-a-push-subscription/) by using the Azure SQL Edge server name/IP as the subscriber (for example **myEdgeinstance,1433**) and a database name on the Azure SQL Edge instance as the destination database (for example **AdventureWorks**).
84+
85+
## See also
86+
87+
- [Create a Publication](https://docs.microsoft.com/sql/relational-databases/replication/publish/create-a-publication)
88+
- [Create a Push Subscription](https://docs.microsoft.com/sql/relational-databases/replication/create-a-push-subscription/)
89+
- [Types of Replication](https://docs.microsoft.com/sql/relational-databases/replication/types-of-replication)
90+
- [Monitoring (Replication)](https://docs.microsoft.com/sql/relational-databases/replication/monitor/monitoring-replication)
91+
- [Initialize a Subscription](https://docs.microsoft.com/sql/relational-databases/replication/initialize-a-subscription)
92+
93+

0 commit comments

Comments
 (0)