Update myDBR

New versions of myDBR are released regularly. If your server has a connection to mydbr.com, an update notification is shown when a new major version is available. It is recommended to run the updater once new versions are introduced. The new versions can contain bug fixes and new functionality. Updates are designed to keep existing report running as is.

Automatic updater using web interface

The preferred update method for myDBR is to use the built-in automatic update method. myDBR periodically checks if a new version is available and it will notify the admin user in the main page of the new versions. At any time, if you wish to update myDBR, you can invoke the update from Admin Tools -> About / Update -> Update now.... If your license has expired and you cannot see the Admin Tools-section, you can click on myDBR-logo in the top left corner to bring up the "About / Update"-dialog.

While carrying out the automatic update, myDBR replaces the application itself and updates the myDBR reporting database to include the latest changes. All the reports will be kept intact. Also, any modifications to the user settings under user-directory are kept (this includes user-specific logos, settings, etc.).

If your server is behind a proxy and is not able to contact the myDBR update server, the proxy settings can be entered in the Environment settings. If you are unable to update myDBR even with the correct proxy settings, please see that you have php_curl installed.

Update between major PHP versions (ionCube change) / Manual update

If your server does not have a connection to mydbr.com (direct or through a proxy), a manual update needs to be applied. A manual update is also required when you update the PHP version so that the required ionCube loader changes (see myDBR download page). To perform a manual update, do the following:

  • Save the myDBR configuration by mydbr_config.php (contains the login information to the database)
  • Save /mydbr/user-directory (contains your own customizations)
  • Download the myDBR zip package from https://mydbr.com/download
  • Replace the existing myDBR install with the new unzipped content of the zip-package
  • Restore the saved mydbr_config.php and the /mydbr/user-directory
  • Access myDBR through the web server

myDBR will now see the updated application and will guide through the rest of the installation through the update wizard. All your reports will stay intact.

Scripting the automatic updater

The automatic updater can also be scripted.

To get the current version as JSON, run following URL:

% curl "https://myserver.mydomain.com/mydbr/index.php?a=version&export=json"

The result for the version query will be:

{
  "version":"4.3.2",
  "build":"2534"
}

The version query URL also supports JSONP, so if you query type is jsonp and you add callback parameter to the query:

% curl "https://myserver.mydomain.com/mydbr/index.php?a=version&export=jsonp&callback=mycallback"

The result for the version query will be:

mycallback(
{
  "version":"4.3.2",
  "build":"2534",
  "key":"bfb61ab9c7"
}
);

The key will be last the 10 characters of your license. You can use this in your script to verify that the server is using the latest license.

When the update URL (see example) is called, authentication is carried out using HTTP basic access authentication. myDBR defines, by default, username 'mydbr_updater' to be used with scripted updates. This is defined in defaults.php and can be overridden in mydbr/user/defaults.php.

To activate the username (mydbr_updater) to be used in scripts, the username needs to be added to myDBR users. Usernames defined as updater-usernames are limited to the update function only and cannot, therefore, be used as normal login users.

The update URL is called using basic access authentication (replace the myserver.mydomain.com/mydbr with your own definition):

% curl -H "X-MYDBR-AUTH: 1" -u mydbr_updater:mydbr_updater_password "https://myserver.mydomain.com/mydbr/install/index.php?controller=update&action=update"

The result for the updater is a JSON object with following fields:

If there was an error in the update process, an "error" entry will be added to the JSON object. The entry has the error message that caused update to fail.

{
  "host":"myserver.mydomain.com",
  "expiration":"2015-12-22",
  "version": {
    "before_update":"4.3.2\/2534",
    "after_update":"4.4.0\/2697"
  }
}

The update URL supports also JSONP, so you can use the call in a report's JavaScript. To use JSONP-include the 'callback'-parameter to the URL.

% curl -H "X-MYDBR-AUTH: 1" -u mydbr_updater:mydbr_updater_password "https://myserver.mydomain.com/mydbr/install/index.php?controller=update&action=update&callback=mycallback"
mycallback({
  "host":"myserver.mydomain.com",
  "expiration":"2015-12-22",
  "version": {
    "before_update":"4.3.2\/2534",
    "after_update":"4.4.0\/2697"
  }
});

Scripting the license installation

The most common way of installing the license is just to copy/paste the license into the license view. However, if you have a large number of installations, you might want to script the license installation. In this case, you define one of the installations as a license server and other servers fetch their licenses from this server. To get the licenses into the license server, you can copy/paste all purchased licenses at once, if you copy the licenses under the 'Copy all licenses'-link in myDBR Shop's order HTML page (https://shop.mydbr.com/index.php?a=order&a=order&id=XXX).

To define an installation as license server (a server which will contain the latest license and serve those to other servers per request), set the server status to true in user/defaults.php and create a license server user into myDBR (by default 'license_checker', can be overridden in the defaults)-

$mydbr_defaults['license_server']['is_server'] = true;

To let the client server know the existence of the license server add the following to the client servers user/defaults.php (can be the same for all clients).

$mydbr_defaults['license_server']['server_url'] = 'https://myserver.mydomain.com/mydbr';

To issue a license retrieval call to client use syntax:

% curl -H "X-MYDBR-AUTH: 1" -u license_checker:license_checker_password "https://myclient.mydomain.com/mydbr/index.php?a=license_service&update=1"

When the call was successful, the response will be:

{"status":"ok"}

If there is a problem with the call, the response will look like:

{"success":"error" errors = {"array of errors"}}

Again, this URL also supports JSONP with the additional 'callback'-parameter to the URL.

Managing large number of installations

When managing a large number of installations, you can automate the license installing and upgrading process. You can either use scheduled report in clients to ask for new licenses and script the updates or you can use a report to manage license distribution and server updates.

Automating license distribution

A sample report running on a defined license server. It fetches the version and license information from the client servers and allows remote license distribution and version updates. With the report, you can handle a large number of servers from one interface without the need to log in to individual servers.

create procedure sp_DBR_update_license(
inVersionBuild varchar(20)
)
BEGIN

select 'dbr.css', '
.license_status {
text-align: center;
}
.license_update, .version_update {
cursor: pointer;
background-color: green;
padding: 3px 6px 3px 6px;
border-radius: 6px;
color: white;
}
.red {
background-color: red;
}
.version {
text-align:center;
}
.version .ajaxspin {
margin: auto;
}
';

select 'dbr.colclass', 'host', 'host';
select 'dbr.colclass', 'license_status', 'license_status';
select 'dbr.colclass', 'version', 'version';
select 'dbr.colclass', 'errors', 'errors';
select 'dbr.html5data', 'host', 'license_key', 'license-key';
select 'dbr.html5data', 'host', 'license_host', 'license-host';
select 'dbr.html5data', 'version', 'version_build', 'version';

select 
  concat('https://', host) as 'Installation URL[host]', 
  l.host as 'license_host',
  l.license_key,
  '' as 'Version[version]',
  '' as 'License OK[license_status]',
  inVersionBuild as 'version_build',
  '' as '[errors]'
from mydbr_licenses l
where host != 'mylicenseserver.mydomain.com';

select 'dbr.javascript',
"$(document).ready(function() {
  // Get installed versions and last 10 characters from the installed license
  $('.host').each( function() {
    var $tr = $(this).closest('tr'),
    url = $(this).text()+'/index.php?a=version&export=jsonp&callback=?';
    $.ajax({
      url: url,
      dataType: 'jsonp',
      success: function(v) {
        // Query returns 10 last characters from the license. Enough for the matching
        var $v, vb, key_ok = (v.key == $tr.find('.host').attr('data-license-key').substr(-10));
        $v = $tr.find('.version');
        vb = v.version+'/'+v.build;
        if ($v.data('version') !== vb) {
          $v.html('<span class=\"version_update\">'+vb+'</span>');
        } else {
          $v.text(v.version+'/'+v.build);
        }
        if (key_ok) {
          $tr.find('.license_status').text('OK');
        } else {
          $tr.find('.license_status').html('<span class=\"license_update\">Newer license available</span>');
        }
      },
      error: function(e, status, error) {
        $tr.find('.version').text('Unknown');
        $tr.find('.errors').text(e.status+'/'+error);
      }
    });
  });

  // Ask the installation to update the license from the license server
  $(document).on('click', '.license_update', function() {
    var url, $tr = $(this).closest('tr');
    url=$tr.find('.host').text()+'/index.php?a=license_service&update=1&callback=?';
    $.ajax({
      url: url,
      beforeSend: function(xhr) {
        xhr.withCredentials = true;
        xhr.setRequestHeader('X-MYDBR-AUTH', '1');
        xhr.setRequestHeader('Authorization', 'Basic ' + btoa('license_checker:pass'));
      },
      dataType: 'jsonp',
      success: function(r) {
        var i,e='';
        if (r.status=='ok') {
          $tr.find('.license_status').text('OK');
        } else {
          $tr.find('.license_status .license_update').addClass('red');
          for(i=0; i<r.errors.length; i++){
            e += '<div>'+r.errors[i]+'</div>';
          }
          $tr.find('.errors').html(e);
        }
      },
      error: function(e, status, error) {
        $tr.find('.errors').text(e.status+'/'+error);
      }

    });
  });

  // Ask the installation to run the updater
  $(document).on('click', '.version_update', function() {
    if (confirm('Update version?')) {
      var url, $tr = $(this).closest('tr'), $v = $tr.find('.version');
      url=$tr.find('.host').text()+'/install/index.php?controller=update&action=update&callback=?';
      $v.html('<div class=\"ajaxspin\"></div>');
      $.ajax({
        url: url,
        beforeSend: function(xhr) {
          xhr.withCredentials = true;
          xhr.setRequestHeader('X-MYDBR-AUTH', '1');
          xhr.setRequestHeader('Authorization', 'Basic ' + btoa('mydbr_updater:pass'));
        },
        dataType: 'jsonp',
        success: function(r) {
          if (r.error) {
            $v.text(r.error);
          } else {
            if (r.version.after_update) {
              $v.text(r.version.after_update);
            } else {
              $v.text('Unknown error');
            }
          }
        },
        error: function(e, status, error) {
          $tr.find('.errors').text(e.status+'/'+error);
        }
      });
    }
  });

});
";
end