Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
I recently worked with a client who said that they had had trouble implementing incremental backup and restore for their stateful services, so I was set to the task to build a sample that would do both a full and incremental backups to Azure blob storage.
I fully expect great improvements to happen in Service Fabric in the coming months regarding backup and restore, but for now, the customer needed to get moving.
I've posted the Visual Studio solution on GitHub for you to look at if you are needing something like this:
https://github.com/larrywa/blogpostings/tree/master/SFBackup
I am using Visual Studio 2017 15.3.3 with the Service Fabric SDK v2.7.198.
Here are some notes for the code you'll find in the sample. I've put as many comments as seem logical within the code, but more description is always better.
Stateful1.cs
Getting a list of the blobs in blob storage that make up the backup
Looping through each blob and downloading/extracting it to your hard drive (in a folder you specify).
Once unzipped, deleting the zip file from your hard drive
Returning the root directory under which you have the unzipped full backup plus all incremental backups. The correct structure of a full + incremental backup should look like:Backup Folder (the root folder)/
Next, the RestoreAsync command is called which looks at your root backup directory, then cycles through the full backup and incremental backups to do the restore. The root directory is then deleted after a restore.
Settings.xml
AzureBackupStore.cs
So, how do you run this application?
When you start running the app, you can set breakpoints in various places to see how it runs, but for me, I let it go through a few backups and write down where I ended up at on the count (from the diagnostics window). Then approximately half way in the middle of another count run, I will execute the PS script. it will take a few seconds to trigger the restore.
The way the app is written is that when you trigger a restore, it does the restore and then after the restore, the next backup is a full backup etc. Something you will notice though as you do restores is that the service (the particular partition), will seem to freeze while the restore is taking place. This is because a 'restore' is expected to be a disaster recovery situation where the service partition would not normally be available. Other partitions may still be running, but not the one being restored.
Hope this helps you in your backup and restore efforts!
Please sign in to use this experience.
Sign in