The below query can be used to restore database using a .bak file stored in AWS S3 bucket
exec msdb.dbo.rds_restore_database
-- replace name with the database name
@restore_db_name='<name>',
--Replace backup s3 path with the actual path.
--Eg. prod-backups/DLProdDB-12-07-19
--In this, prod-backups is the bucket name and DLProdDB-12-07-19 is the .bak --file name
@s3_arn_to_restore_from='arn:aws:s3:::{backup s3 path}'
To check the status of the restore, use the following query –
Azure Sql Database is a fully managed relational database that provisions quickly, scales on the fly and includes built-in intelligence and security as well.
Azure Sql Database is a fully managed relational database that provisions quickly, scales on the fly and includes built-in intelligence and security as well.
Below are the steps to restore the database from .bacpac (Azure DB backup) file to .bak (SQL DB backup) file
The first step is to export the Azure DB. For this, you need to login to your Azure portal and go to SQL database in your resource group. Click Export as shown below.
After clicking on Export, you have to select the storage location and add the credentials as shown below. This process will take few minutes to finish depending on your database size.
Note: It is good to select the storage location (blob storage) in the same resource group, if you have multiple resource groups
After the export is finished, you will get the exported file as a .bacpac file in your selected storage. (In my case, it is blob storage container)
Right-click on the .bacpac file you just created and download it locally
The next step is to create .bak file from the .bacpac file you just downloaded. For this, you need to open SQL Server Management Studio (I am using SQL Server Management Studio v17.9.1). Right-click on Databases and select Import Data-tier Application.
You will see the below screen. Now, click Next.
Click on Browse and select the .bacpac file you downloaded from Azure in the previous step and click Next as shown below –
Here you can change the database name or can keep the same name as your .bacpac file. You can leave the other settings as it is and just click Next again.
Now, you can verify all the settings below and click Finish or you can click Previous and go back to the previous settings if you want to change anything.
Now you will see the progress and once it is finished, you will see the below Operation Complete screen. If there is any error, you can click on that and see what is wrong, else you will get all Success
You can see the newly restored database under the Databases folder.
The next step is to create the .bak file. For this, right-click on the new DB and select Tasks -> Back Up… as shown below –
Now, you will see the below screen. Remove the destination path that is pre-selected by clicking Remove as shown below. And then click on Add to select the path where you want to store your .bak file.
After clicking on Add, you will see the screen below. Select the destination path/folder and add the desired File name. I have added TestDB12072019.
Click OK and you will see it executing. Once 100% completed, you will see the following screen –
Thats’s it! You have created SQL Server .bak file from Azure database .bacpac file.
Now you can see the .bak file in the folder path you selected.
Please leave a comment, if you have any questions.
Interested in Cryptocurrency. Register and start investing here
Earn a side income by affiliate marketing. Learn here how to do it.
If you are looking to create a custom property editor in Umbraco
If you are looking for a way to populate a checkbox list in the content dynamically
If you are looking for a way to call an api in umbraco property editor
If you are looking for a way to populate a checkbox list with one of the document types dynamically
For this post, we are going to build a custom property editor that will populate the checkbox list with categories (added under home) using an api url.
Let’s say, we have a food website that have different categories like Healthy, Baking, Recipes, Dinner, Summer recipes, etc. We also have articles related to all these different categories.
Categories under Home –
Content with categories as checkbox list –
What is the problem?
Now the problem here is whenever a new category is added, the checkbox list for categories has to be updated manually as we have use the default checkbox list data type.
In order to fix this problem, we will create a custom property editor and use it to create the checkbox list dynamically. So whenever, a new category will be added, the checkbox list for categories will be updated automatically.
What is the solution?
Skills needed to build a Property Editor –
Umbraco BackOffice (Using ver 8.0.1 for this post)
HTML
CSS
Javascript (Optional)
Angular (Optional)
Files needed for a Property Editor –
Manifest
HTML file
Javascript file
CSS (Optional)
First, let’s create a manifest file.
{
propertyEditors: [
{
alias: "CustomCheckBoxList",
name: "Custom Checkbox list",
editor: {
view: "~/App_Plugins/CheckboxListing/checkboxlist.html",
hideLabel: false,
valueType: "STRING"
},
prevalues: {
fields: [
{
label: "Api Url",
description: "Add the API Url to get the list of items. api/{controller}/{Action}",
key: "apiUrl",
view: "textstring"
}
]
}
}
],
javascript: [
"~/App_Plugins/CheckboxListing/checkboxlist.controller.js"
]
}
Now, we have to create the Javascript file, which will contain the main logic of this property editor.
angular.module("umbraco")
.controller("CheckboxList.Controller",
function($scope, $http, assetsService) {
var newItems = [];
$scope.selectedItems = [];
var categories = function() {
return $http.get($scope.model.config.apiUrl)
.then(function(data) {
$scope.categories = data;
for (var i = 0; i < $scope.categories.data.length; i++) {
newItems.push({ id: $scope.categories.data[i].id, value: $scope.categories.data[i].name });
}
$scope.categories = newItems;
});
}
categories()
.then(function() {
$scope.$on("formSubmitting",
function(ev, args) {
if ($scope.model.value === null || $scope.model.value === undefined) {
$scope.model.value = [];
}
var selectedCategories = "";
angular.forEach($scope.selectedItems,
function(value, key) {
var itemSelected = value.selected;
var item = value.val;
selectedCategories = itemSelected === true
? selectedCategories + item + ","
: selectedCategories + "";
});
$scope.model.value = selectedCategories.replace(/(^,)|(,$)/g, "");
});
function setupViewModel() {
if ($scope.model.value === null || $scope.model.value === undefined) {
$scope.model.value = [];
}
for (var i = 0; i < $scope.categories.length; i++) {
var isSelected = $scope.model.value.includes($scope.categories[i].value);
$scope.selectedItems.push({
selected: isSelected,
key: $scope.categories[i].id,
val: $scope.categories[i].value
});
}
}
setupViewModel();
$scope.$watch("selectedItems",
function(newVal, oldVal) {
$scope.model.value = [];
for (var x = 0; x < $scope.selectedItems.length; x++) {
if ($scope.selectedItems[x].checked) {
$scope.model.value.push($scope.selectedItems[x].key);
}
}
},
true);
$scope.model.onValueChanged = function(newVal, oldVal) {
setupViewModel();
};
});
});
That’s it!! You are done with the coding part.
What’s Next?
Just rebuild your project and go to backoffice where you have to create a new data type for the categories.
Go to Settings – Right click on Data Types to create a new data type. Select datatype that we just created – Custom Checkbox List
Now, you must be thinking that what is Api Url. Ok, so this is the url of the api you will create to get the categories. I am using categories for this post. However, you can use this field to add other api urls as well to populate the checkbox list with anything you want.
Now, we will add the newly created document type to our content page.
And when you load the content again, you will see the categories populated in the checkbox list.
So now, whenever a new category will be added, the checkbox list will be auto-populated with the new one.
Note: It is good to create a datatype like this before you actually create a content as later on if you delete and update a property in your content, you have to update the data associated as well which could be a complex task sometimes.
Interested in Cryptocurrency. Register and start investing here
Earn a side income by affiliate marketing. Learn here how to do it.