Restore SQL database from .bak file stored in AWS S3 bucket

A Sql Database can be restored using .bak file

A Sql Database can be restored using .bak file

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


--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 –

exec msdb.dbo.rds_task_status @db_name='<name>'

For more info, click here

Restore Azure Database (.bacpac) file to SQL Server (.bak) file

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

  1. 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.

  2. 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

  3. 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)

  4. Right-click on the .bacpac file you just created and download it locally

  5. 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.

  6. Click on Browse and select the .bacpac file you downloaded from Azure in the previous step and click Next as shown below –

  7. 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.

  8. 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.

  9. 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

  10. You can see the newly restored database under the Databases folder.

  11. 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 –

  12. 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.

  13. 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.

  14. 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.

Disclosure: We use affiliate links to monetize our content.  We may receive a commission on products or services that you purchase through clicking on links within this blog.

Convert PHP script to JavaScript

Convert PHP script to JavaScript

  • Add the “base-reality/php-to-javascript”: “>=0.0.3” to your project’s composer.json file:

    “require”:{ “base-reality/php-to-javascript”: “0.1.16” }

    Or the latest tagged version. The dev master should only be used for development, not production.\
  • Include the Composer SPL autoload file in your project: require_once(‘../vendor/autoload.php’);

    Call the converter:
 $phpToJavascript = new PHPToJavascript\PHPToJavascript();
   $phpToJavascript->addFromFile($inputFilename); $jsOutput =

$jsOutput will now contain an auto-generated Javascript version of the PHP source file.

Create a custom property editor in Umbraco

Build a custom property editor that will populate the checkbox list with categories using an api url.

Umbraco User’s Guide

This post is helpful in following scenarios –

  • 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: [

Now, let’s add the HTML file

<div ng-controller="CheckboxList.Controller">
    <ul class="unstyled">
        <li ng-repeat="category in selectedItems">
            <label class="checkbox">
                <input type="checkbox" name="checkboxlist"

Now, we have to create the Javascript file, which will contain the main logic of this property editor.

        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 < $; i++) {
                            newItems.push({ id: $[i].id, value: $[i].name });
                        $scope.categories = newItems;
                .then(function() {
                        function(ev, args) {
                            if ($scope.model.value === null || $scope.model.value === undefined) {
                                $scope.model.value = [];
                            var selectedCategories = "";

                                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);
                                selected: isSelected,
                                key: $scope.categories[i].id,
                                val: $scope.categories[i].value


                        function(newVal, oldVal) {
                            $scope.model.value = [];

                            for (var x = 0; x < $scope.selectedItems.length; x++) {
                                if ($scope.selectedItems[x].checked) {

                    $scope.model.onValueChanged = function(newVal, oldVal) {

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.

Countdown timer in Javascript

Code to create a timer till a specific datetime.

Below is the code to create a timer till a specific datetime.

For this sample, the deadline is 5/16/2021 11:26:00

<html xmlns="">
<head runat="server">
    <script language="javascript">

     function getTimeRemaining(endtime) {
      var d = new Date();
      var t = endtime.getTime() - d.getTime(); 

      var seconds = Math.floor((t / 1000) % 60);
      var minutes = Math.floor((t / 1000 / 60) % 60);
      var hours = Math.floor((t / (1000 * 60 * 60)) % 24);
      var days = Math.floor(t / (1000 * 60 * 60 * 24));
      return {
        'total': t,
        'days': days,
        'hours': hours,
        'minutes': minutes,
        'seconds': seconds

   function initializeCountdown(id, endtime) {
    var clock = document.getElementById(id); 
    var daysSpan = clock.querySelector('.days');
    var hoursSpan = clock.querySelector('.hours');
    var minutesSpan = clock.querySelector('.minutes');
    var secondsSpan = clock.querySelector('.seconds');

   function updateTimer() {
        var t = getTimeRemaining(endtime);
        daysSpan.innerHTML = t.days;
        hoursSpan.innerHTML = ('0' + t.hours).slice(-2);
        minutesSpan.innerHTML = ('0' + t.minutes).slice(-2);
        secondsSpan.innerHTML = ('0' + t.seconds).slice(-2);

        if ( <= 0) {

     var timeinterval = setInterval(updateTimer, 1000);

    window.onload = function () {
     var deadline = new Date("5/16/2021 11:26:00"); // The datetime of the 
     initializeCountdown('clockdiv', deadline);

<form id="form1" runat="server">
<div id="clockdiv">
  <div style="float:left;">
    <span class="days"></span>
  <div style="float:left;">
    <span class="hours"></span>
  <div style="float:left;">
    <span class="minutes"></span>
  <div style="float:left;">
    <span class="seconds"></span>

Output –

%d bloggers like this: