Skip to content

Commit

Permalink
Merge pull request #92 from MicrosoftDocs/main
Browse files Browse the repository at this point in the history
9/5/2024 AM Publish
  • Loading branch information
Taojunshen authored Sep 5, 2024
2 parents ca4c673 + 85e0756 commit c99f47c
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 136 deletions.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ms.author: tomcassidy
author: tomvcassidy
ms.service: azure-service-fabric
services: service-fabric
ms.date: 07/14/2022
ms.date: 08/23/2024
---

# On-demand backup in Azure Service Fabric
Expand All @@ -15,7 +15,7 @@ You can back up data of Reliable Stateful services and Reliable Actors to addres

Azure Service Fabric has features for the [periodic backup of data](service-fabric-backuprestoreservice-quickstart-azurecluster.md) and the backup of data on a need basis. On-demand backup is useful because it guards against _data loss_/_data corruption_ because of planned changes in the underlying service or its environment.

The on-demand backup features are helpful for capturing the state of the services before you manually trigger a service or service environment operation. For example, if you make a change in service binaries when upgrading or downgrading the service. In such a case, on-demand backup can help guard the data against corruption by application code bugs.
The on-demand backup features are helpful for capturing the state of the services before you manually trigger a service or service environment operation. For example, if you make a change in service binaries when upgrading or downgrading the service. In such a case, on-demand backup can help guard the data against corruption by application code bugs.
## Prerequisites

- Install Microsoft.ServiceFabric.Powershell.Http Module for making configuration calls.
Expand Down Expand Up @@ -46,17 +46,17 @@ On-demand backup requires storage details for uploading backup files. You specif

You can configure the periodic backup policy to use a partition of a Reliable Stateful service or Reliable Actor for extra on-demand backup to storage.

The following case is the continuation of the scenario in [Enabling periodic backup for Reliable Stateful service and Reliable Actors](service-fabric-backuprestoreservice-quickstart-azurecluster.md#enabling-periodic-backup-for-reliable-stateful-service-and-reliable-actors). In this case, you enable a backup policy to use a partition and a backup occurs at a set frequency in Azure Storage.
The following case is the continuation of the scenario in [Enabling periodic backup for Reliable Stateful service and Reliable Actors](service-fabric-backuprestoreservice-quickstart-azurecluster.md#enabling-periodic-backup-for-reliable-stateful-service-and-reliable-actors). In this case, you enable a backup policy to use a partition, and a backup occurs at a set frequency in Azure Storage.

#### Powershell using Microsoft.ServiceFabric.Powershell.Http Module
#### PowerShell using Microsoft.ServiceFabric.Powershell.Http Module

```powershell
Backup-SFPartition -PartitionId '974bd92a-b395-4631-8a7f-53bd4ae9cf22'
```

#### Rest Call using Powershell
#### Rest Call using PowerShell

Use the [BackupPartition](/rest/api/servicefabric/sfclient-api-backuppartition) API to set up triggering for the on-demand backup for partition ID `974bd92a-b395-4631-8a7f-53bd4ae9cf22`.

Expand All @@ -73,23 +73,26 @@ Use the [GetBackupProgress](/rest/api/servicefabric/sfclient-api-getpartitionbac
You can request on-demand backup for a partition of a Reliable Stateful service or Reliable Actor. Provide the storage information as a part of the on-demand backup request.


#### Powershell using Microsoft.ServiceFabric.Powershell.Http Module
#### PowerShell using Microsoft.ServiceFabric.Powershell.Http Module

```powershell
Backup-SFPartition -PartitionId '974bd92a-b395-4631-8a7f-53bd4ae9cf22' -AzureBlobStore -ConnectionString 'DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>;EndpointSuffix=core.windows.net' -ContainerName 'backup-container'
Backup-SFPartition -PartitionId '974bd92a-b395-4631-8a7f-53bd4ae9cf22' -ManagedIdentityAzureBlobStore -FriendlyName "AzureMI_storagesample" -BlobServiceUri 'https://<account-name>.blob.core.windows.net' -ContainerName 'backup-container' -ManagedIdentityType "VMSS" -ManagedIdentityClientId "<Client-Id of User-Assigned MI>"
# Use Optional parameter `ManagedIdentityClientId` with Client-Id of User-Assigned Managed Identity in case of multiple User-Assigned Managed Identities assigned to your resource, or both SAMI & UAMI assigned and we need to use UAMI as the default, else no need of this paramter.
```

#### Rest Call using Powershell
#### Rest Call using PowerShell

Use the [BackupPartition](/rest/api/servicefabric/sfclient-api-backuppartition) API to set up triggering for the on-demand backup for partition ID `974bd92a-b395-4631-8a7f-53bd4ae9cf22`. Include the following Azure Storage information:

```powershell
$StorageInfo = @{
ConnectionString = 'DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>;EndpointSuffix=core.windows.net'
ContainerName = 'backup-container'
StorageKind = 'AzureBlobStore'
StorageKind = "ManagedIdentityAzureBlobStore"
FriendlyName = "AzureMI_storagesample"
BlobServiceUri = "https://<account-name>.blob.core.windows.net"
ContainerName = "backup-container"
ManagedIdentityType = "VMSS"
ManagedIdentityClientId = "<Client-Id of User-Assigned MI>" # Use Optional parameter `ManagedIdentityClientId` with Client-Id of User-Assigned Managed Identity in case of multiple User-Assigned Managed Identities assigned to your resource, or both SAMI & UAMI assigned and we need to use UAMI as the default, else no need of this paramter.
}
$OnDemandBackupRequest = @{
Expand All @@ -106,7 +109,7 @@ You can use the [GetBackupProgress](/rest/api/servicefabric/sfclient-api-getpart

### Using Service Fabric Explorer
Make sure Advanced Mode has been enabled in Service Fabric Explorer settings.
1. Select the desired partitions and click on Actions.
1. Select the desired partitions and select on Actions.
2. Select Trigger Partition Backup, and fill in information for Azure:

![Trigger Partition Backup][0]
Expand All @@ -117,19 +120,19 @@ Make sure Advanced Mode has been enabled in Service Fabric Explorer settings.

## Tracking on-demand backup progress

A partition of a Reliable Stateful service or Reliable Actor accepts only one on-demand backup request at a time. Another request can be accepted only after the current on-demand backup request has completed.
A partition of a Reliable Stateful service or Reliable Actor accepts only one on-demand backup request at a time. Another request can be accepted only after the current on-demand backup request has been completed.

Different partitions can trigger on-demand backup requests at a same time.
Different partitions can trigger on-demand backup requests at the same time.


#### Powershell using Microsoft.ServiceFabric.Powershell.Http Module
#### PowerShell using Microsoft.ServiceFabric.Powershell.Http Module

```powershell
Get-SFPartitionBackupProgress -PartitionId '974bd92a-b395-4631-8a7f-53bd4ae9cf22'
```
#### Rest Call using Powershell
#### Rest Call using PowerShell

```powershell
$url = "https://mysfcluster-backup.southcentralus.cloudapp.azure.com:19080/Partitions/974bd92a-b395-4631-8a7f-53bd4ae9cf22/$/GetBackupProgress?api-version=6.4"
Expand All @@ -152,7 +155,7 @@ On-demand backup requests can be in the following states:
FailureError :
```
- **Success**, **Failure**, or **Timeout**: A requested on-demand backup can be completed in any of the following states:
- **Success**: A _Success_ backup state indicates that the partition state has backed up successfully. The response provides _BackupEpoch_ and _BackupLSN_ for the partition along with the time in UTC.
- **Success**: A _Success_ backup state indicates that the partition state has backed up successfully. The response provides _BackupEpoch_ and _BackupLSN_ for the partition along with the time in UTC.
```
BackupState : Success
TimeStampUtc : 2018-11-21T20:00:01Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ms.author: tomcassidy
author: tomvcassidy
ms.service: azure-service-fabric
services: service-fabric
ms.date: 08/23/2024
ms.date: 07/14/2022
---

# Restoring backup in Azure Service Fabric
Expand Down Expand Up @@ -58,22 +58,30 @@ If an entire Service Fabric cluster is lost, you can recover the data for the pa

For the following example, assume that the lost cluster is the same cluster that's referred to in [Enabling periodic backup for Reliable Stateful service and Reliable Actors](service-fabric-backuprestoreservice-quickstart-azurecluster.md#enabling-periodic-backup-for-reliable-stateful-service-and-reliable-actors). In this case, `SampleApp` is deployed with backup policy enabled, and the backups are configured to Azure Storage.

#### Powershell using Microsoft.ServiceFabric.Powershell.Http Module
#### PowerShell using Microsoft.ServiceFabric.Powershell.Http Module

Replace `account-name` with your storage account name.

```powershell
Get-SFBackupsFromBackupLocation -Application -ApplicationName 'fabric:/SampleApp' -AzureBlobStore -ConnectionString 'DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>;EndpointSuffix=core.windows.net' -ContainerName 'backup-container'
Get-SFBackupsFromBackupLocation -Application -ApplicationName 'fabric:/SampleApp' -ManagedIdentityAzureBlobStore -BlobServiceUri "https://<account-name>.blob.core.windows.net" -ContainerName 'backup-container' -ManagedIdentityType "VMSS" -FriendlyName "AzureMI_storagesample" -ManagedIdentityClientId = "<Client-Id of User-Assigned MI>"
# Use Optional parameter `ManagedIdentityClientId` with Client-Id of User-Assigned Managed Identity in case of multiple User-Assigned Managed Identities assigned to your resource, or both SAMI & UAMI assigned and we need to use UAMI as the default, else no need of this paramter.
```

#### Rest Call using Powershell
#### Rest Call using PowerShell

Execute a PowerShell script to use the REST API to return a list of the backups created for all partitions inside the `SampleApp` application. The API requires the backup storage information to list the available backups.

```powershell
$StorageInfo = @{
ConnectionString = 'DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>;EndpointSuffix=core.windows.net'
ContainerName = 'backup-container'
StorageKind = 'AzureBlobStore'
StorageKind = "ManagedIdentityAzureBlobStore"
FriendlyName = "AzureMI_storagesample"
BlobServiceUri = "https://<account-name>.blob.core.windows.net"
ContainerName = "backup-container"
ManagedIdentityType = "VMSS"
ManagedIdentityClientId = "<Client-Id of User-Assigned MI>" # Use Optional parameter `ManagedIdentityClientId` with Client-Id of User-Assigned Managed Identity in case of multiple User-Assigned Managed Identities assigned to your resource, or both SAMI & UAMI assigned and we need to use UAMI as the default, else no need of this paramter.
}
$BackupEntity = @{
Expand Down Expand Up @@ -156,26 +164,29 @@ You also need to choose a destination partition in the alternate cluster as deta

If the partition ID on alternate cluster is `1c42c47f-439e-4e09-98b9-88b8f60800c6`, you can map it to the original cluster partition ID `974bd92a-b395-4631-8a7f-53bd4ae9cf22` by comparing the high key and low key for _Ranged Partitioning (UniformInt64Partition)_.

For _Named Partitioning_, the name value is compared to identify the target partition in alternate cluster.
For _Named Partitioning_, the name value is compared to identifying the target partition in alternate cluster.

#### Powershell using Microsoft.ServiceFabric.Powershell.Http Module
#### PowerShell using Microsoft.ServiceFabric.Powershell.Http Module

```powershell
Restore-SFPartition -PartitionId '1c42c47f-439e-4e09-98b9-88b8f60800c6' -BackupId 'b0035075-b327-41a5-a58f-3ea94b68faa4' -BackupLocation 'SampleApp\MyStatefulService\974bd92a-b395-4631-8a7f-53bd4ae9cf22\2018-04-06 21.10.27.zip' -AzureBlobStore -ConnectionString 'DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>;EndpointSuffix=core.windows.net' -ContainerName 'backup-container'
Restore-SFPartition -PartitionId 1c42c47f-439e-4e09-98b9-88b8f60800c6 -BackupId b0035075-b327-41a5-a58f-3ea94b68faa4 -BackupLocation 'SampleApp\MyStatefulService\974bd92a-b395-4631-8a7f-53bd4ae9cf22\2018-04-06 21.10.27.zip' -ManagedIdentityAzureBlobStore -BlobServiceUri "https://<account-name>.blob.core.windows.net" -ContainerName "backup-container" -ManagedIdentityType "VMSS" -FriendlyName "AzureMI_storagesample" ManagedIdentityClientId "<Client-Id of User-Assigned MI>"
```

#### Rest Call using Powershell
#### Rest Call using PowerShell

You request the restore against the backup cluster partition by using the following [Restore API](/rest/api/servicefabric/sfclient-api-restorepartition):

```powershell
$StorageInfo = @{
ConnectionString = 'DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>;EndpointSuffix=core.windows.net'
ContainerName = 'backup-container'
StorageKind = 'AzureBlobStore'
StorageKind = "ManagedIdentityAzureBlobStore"
FriendlyName = "AzureMI_storagesample"
BlobServiceUri = "https://<account-name>.blob.core.windows.net"
ContainerName = "backup-container"
ManagedIdentityType = "VMSS"
ManagedIdentityClientId = "<Client-Id of User-Assigned MI>"
}
$RestorePartitionReference = @{
Expand All @@ -193,12 +204,12 @@ Invoke-WebRequest -Uri $url -Method Post -Body $body -ContentType 'application/j
You can track the progress of a restore with TrackRestoreProgress.

> [!NOTE]
> When using Powershell to restore partition, if backuplocation has '$', escape it using '~'
> When using PowerShell to restore partition, if backuplocation has '$', escape it using '~'
>
### Using Service Fabric Explorer
You can trigger a restore from Service Fabric Explorer. Make sure Advanced Mode has been enabled in Service Fabric Explorer settings.
1. Select the desired partitions and click on Actions.
1. Select the desired partitions and select on Actions.
2. Select Trigger Partition Restore and fill in information for Azure:

![Trigger Partition Restore][2]
Expand All @@ -213,7 +224,7 @@ For _data loss_ or _data corruption_, backed-up partitions for Reliable Stateful

The following example is a continuation of [Enabling periodic backup for Reliable Stateful service and Reliable Actors](service-fabric-backuprestoreservice-quickstart-azurecluster.md#enabling-periodic-backup-for-reliable-stateful-service-and-reliable-actors). In this example, a backup policy is enabled for the partition, and the service is making backups at a desired frequency in Azure Storage.

Select a backup from the output of [GetBackupAPI](service-fabric-backuprestoreservice-quickstart-azurecluster.md#list-backups). In this scenario, the backup is generated from the same cluster as before.
Select a backup from the output of [GetBackupAPI](service-fabric-backuprestoreservice-quickstart-azurecluster.md#list-backups). In this scenario, the backup is generated from the same cluster as before.

To trigger the restore, choose a backup from the list. For the current _data loss_/_data corruption_, select the following backup:

Expand All @@ -234,14 +245,14 @@ FailureError :
For the restore API, provide the _BackupId_ and _BackupLocation_ details. The cluster has backup enabled so the Service Fabric _Backup Restore Service (BRS)_ identifies the correct storage location from the associated backup policy.


#### Powershell using Microsoft.ServiceFabric.Powershell.Http Module
#### PowerShell using Microsoft.ServiceFabric.Powershell.Http Module

```powershell
Restore-SFPartition -PartitionId '974bd92a-b395-4631-8a7f-53bd4ae9cf22' -BackupId 'b0035075-b327-41a5-a58f-3ea94b68faa4' -BackupLocation 'SampleApp\MyStatefulService\974bd92a-b395-4631-8a7f-53bd4ae9cf22\2018-04-06 21.10.27.zip'
```

#### Rest Call using Powershell
#### Rest Call using PowerShell

```powershell
$RestorePartitionReference = @{
Expand All @@ -258,20 +269,20 @@ Invoke-WebRequest -Uri $url -Method Post -Body $body -ContentType 'application/j
You can track the restore progress by using TrackRestoreProgress.

> [!NOTE]
> When using Powershell to restore partition, if backuplocation has '$', escape it using '~'
> When using PowerShell to restore partition, if backuplocation has '$', escape it using '~'
>
## Track restore progress

A partition of a Reliable Stateful service or Reliable Actor accepts only one restore request at a time. A partition only accepts another request after the current restore request is completed. Multiple restore requests can be triggered on different partitions at the same time.

#### Powershell using Microsoft.ServiceFabric.Powershell.Http Module
#### PowerShell using Microsoft.ServiceFabric.Powershell.Http Module

```powershell
Get-SFPartitionRestoreProgress -PartitionId '974bd92a-b395-4631-8a7f-53bd4ae9cf22'
```

#### Rest Call using Powershell
#### Rest Call using PowerShell

```powershell
$url = "https://mysfcluster-backup.southcentralus.cloudapp.azure.com:19080/Partitions/974bd92a-b395-4631-8a7f-53bd4ae9cf22/$/GetRestoreProgress?api-version=6.4"
Expand Down Expand Up @@ -300,7 +311,7 @@ The restore request progresses in the following order:
```
3. **Success**, **Failure**, or **Timeout**: A requested restore can be completed in any of the following states. Each state has the following significance and response details:
- **Success**: A _Success_ restore state indicates a regained partition state. The partition reports _RestoredEpoch_ and _RestoredLSN_ states along with the time in UTC.
- **Success**: A _Success_ restore state indicates a regained partition state. The partition reports _RestoredEpoch_ and _RestoredLSN_ states along with the time in UTC.
```
RestoreState : Success
Expand Down
Loading

0 comments on commit c99f47c

Please sign in to comment.