> For the complete documentation index, see [llms.txt](https://help.qtech.co.nz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/backup-and-restart.md).

# Backup, restart and disaster recovery

Restart the DATRAN VI server safely, start the services in the right order, check it is logging afterwards, back up the right files, and restore a TBD.

A step by step guide on how to manually restart individual services and/or how to restart the entire DATRAN Tree Base Server. The SCADA server should be regarded as a mission-critical system. From time to time we receive requests for support after unexpected restarts of DATRAN services and consequentially SQL Server apparently failing to log telemetry data. Frequently, the cause of an unexpected restart is the result of a Windows update that occurs out of normal business hours.

{% hint style="info" %}
**Applies to:** DATRAN VI, from QTech's Restarting Procedure v1.6, Restarting Services, and SQL Recommendations application notes. The V6.78 installer creates a new dependency chain such that ADO does not start until DVG starts and ADO is now a delayed start by default: see [Upgrade to DATRAN VI V6.78](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/install/upgrade-to-v6-78.md#service-start-order).
{% endhint %}

## Plan a restart

Use this procedure when the server is restarted (hardware restart), when services are restarted (DATRAN VI services or MSSQL services) or for software upgrades (Windows updates or DATRAN VI updates).

1. **Record it:** the reason for the restart, the date and time of the restart, the person doing the restart, and the date and time the restart was completed.
2. **Inform** Management and Operations that a restart is pending.
3. **Confirm** which services are operational and licensed at that stage.
4. **Restart** the server and note the reason when prompted.
5. **Check** it's working (below). Once everything has been confirmed and verified, close all applications, and inform Management and Operations that the restart has been successful.

## Start the services in the right order

Start DATRAN Services after SQL Server has restarted, in this order:

1. DATRAN Tree Base Server (TBServ)
2. DATRAN Derived Value Generator (DVG). Wait for 3 to 5 minutes for the activity to die down and the odometer to be counting steadily.
3. DATRAN ADO Database Connectivity. Wait for it and the DVG to settle. There may be lots of activity that may appear to freeze the DVG as some ADO queries execute. Especially seems to be those associated with Waste Water Overflow calculations.
4. The other DATRAN services (order does not matter for the rest of the services). Whilst not required, Operators may choose to start communications to the telemetry network last (e.g. QComms).
5. For systems using QTech OPC-UA Server with HMIs such as InTouch, restart DATRAN services in the following order: DATRAN, then OPC-UA Server, then OI Gateway, then InTouch.

The restarting procedure can be executed through DATRAN VI, however it is recommended that the procedure is executed via the Windows **Services** applet.

### Stop the services

* **One service:** if you wish to restart a single service (excluding DATRAN Tree Base Server, DATRAN Derived Value Generator and DATRAN ADO Database Connectivity) you can do this by right clicking the service and clicking **Stop**.
* **All services:** If you wish to restart all of the services it is important that **DATRAN Tree Base Server** is stopped first. Stopping DATRAN Tree Base Server should also stop all other running DATRAN services (due to the dependencies). If stopping DATRAN Tree Base Server does not stop the other DATRAN services, it is worthwhile to check the dependencies which can be done by right clicking the service and going into properties, then clicking the dependencies tab.

### Set up dependencies

Each service is configured in the Windows Services applet to include a dependency such that the service will not start until the core DATRAN service (TBSERV) starts. It is also suggested to add DATRAN Derived Value Generator (DVG) to ensure database logging and other functions work as intended. This can be done in one of two methods: using Command Prompt or using the Registry Editor. The V6.78 installer creates a new dependency chain such that ADO does not start until DVG starts and ADO is now a delayed start by default.

![The Dependencies tab of the DATRAN Tree Base Server service, listing the services that depend on it](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FDKw08tLzjzuxS66QLaKS%2Ftree-base-server-dependencies.png?alt=media)

Run Command Prompt as an administrator and enter the following commands:

```
sc config ADODCM depend= TBSERV/DVG
sc config [service name] depend= ADODCM
```

The service that is being changed replaces `[service name]` in the command, and any other services can be added at the end using a forward slash (/) as a separator. Or, navigate to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\[service name]` from the Registry Editor (regedit) and modify the `DependOnService` value. Add each service you require (such as DVG) with each entry on a new line.

We recommend that appropriate delays on service starts, especially for the ADO service, be included in the service configuration with dependencies added to check that SQL Server is ready.

## After a restart: check it is working

1. **Services:** confirm that all required services have started correctly: DATRAN VI services (depending on what services are licensed) and the Microsoft SQL service (if SQL logging is utilised).
2. **Site comms:** open DATRAN Browser and confirm communication with outstations. In Diagnostics, select the categories QTech Comms: Comms, QTech Comms: Comms Err and QTech Comms: Diagnostic.
3. **Supervisor:** open DATRAN Supervisor and confirm operation. Open the Site List and the Alarm List and check them.
4. **Trending:** Open DATRAN Trending and confirm operation. Check that latest data is displayed.
5. **Logging to SQL Server:** turn on ADO Database Connectivity: Diagnostic, Execute and LogNodes, and Historical Data Interface: AdoDCM, AdoDCM Error and AdoDCM Execute. Ensure that data from the outstations are being written to SQL Server with no errors.
6. **In SQL Server:** check that the data displayed reflects the current date/time. See [Check that data is being logged](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/sql-server.md#check-that-data-is-being-logged).
7. **RTU logs:** after a restart, historical RTU data logs should be retrieved during operational checks and checked in the SQL database. If the passage of time is too great there is a risk of data holes in the SQL point data as the logs will eventually be overwritten at the RTU.

If it seems that there is no link between DATRAN VI and the SQL Server, restart DATRAN VI Services. If the date stamp of data displayed in the tables does not match the date stamp of data sent from DATRAN VI to the SQL Server, restart the SQL Server, wait for at least 30 minutes, and then check again. See [Trending shows no new data](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/troubleshooting/no-new-data.md).

## Recommendations

* **Turn off automatic updates and automatic restarts** on the computers or virtual machines running the DATRAN services and/or SQL Server, as this can cause DATRAN services to start out of order which can affect connectivity with the SQL Server.
* **Monitor TBServ and the DVG.** Because other DATRAN services will stop working if either TBSERV or DVG crashes, it is recommended to have Microsoft Windows monitor these services and send an alert to the system administrator if issues arise so critical data isn’t lost.
* **Use Mission Critical.** The Mission Critical flag is part of every DATRAN service. It is used to perform an action if that service stops. The Server Manager handles the mission critical checking.
* **Keep diagnostic logs as insurance.** As an insurance policy, we suggest that both the ADO and HDI diagnostics are turned on to capture log data as it is retrieved. In DATRAN Diagnostics, under **Log To Disk**, tick ADO Database Connectivity: Execute and SqlError, and Historical Data Interface: AdoDCM Error, AdoDCM Execute and RawDG (plus InSqlCM Error and Execute if you use InSQL). Then double-click **Server Manager** and, on the diagnostic options tab, set **keep for** to about 14 days and the file size to 50 MB or more. The diagnostic logs are written to disk and can be used to reconstruct point data if necessary. Be aware that sufficient available disk space is required to store the logs. If you find that you need to recover log data from disk then please contact QTech.

## Avoid a disaster

By disaster we mean loss of a TBD file, failure of a DATRAN system without knowledge of operators or inability to rebuild a failed system quickly.

* Set up the **automatic backup** by Server Manager, and make back-ups to tape or other media of the TBD files that are produced by Server Manager.
* Set up Server Manager **Mission Critical** Checking. If a DATRAN Service fails an operator could be paged.
* Using the Windows service manager, set up each service to **automatically restart** when they fail.
* Set up a **watch-dog system** by sending the Server Manager Heart Beat to an RTU. The RTU would ring an operator using an auto-dialler or send an SMS message using a cellular SMS modem.
* Take **regular drive images** of the DATRAN machine and store them in a safe place. With these, any identical hardware can be re-imaged and up and running quickly.
* Set up **system alarms** that will be triggered when system parameters are getting near their limits: low hard disk space; too many nodes in DATRAN VI or the TBD file is over a certain size; alarms related to SQL Server where this is used to store historical data; and alarms alerting the operator to a failure of any of the DATRAN services. For V6.78, add [persistent queue alarms](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/persistent-queues.md#alarms-to-set-up).
* Get an [alarm when the database stops logging](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/sql-server.md#get-an-alarm-when-the-database-stops-logging).

## What to back up

| Back up                      | Usually found in                                                              |
| ---------------------------- | ----------------------------------------------------------------------------- |
| The TBD file                 | `Datran\Data` in the DATRAN program folder                                    |
| Server Manager's TBD backups | `Datran\Backup`                                                               |
| Any SQL database data files  |                                                                               |
| DLP and ASM files            | `Datran\DLP` and `Datran\ASM`                                                 |
| HMI files                    | Any HMI configuration files for GUI applications such as InTouch or DATRANVue |

There is no need to back up application files as these can all be reloaded from the DATRAN VI CD. Software updates are available to all SMA holders via the QTech website.

## Restore a backup TBD

If when viewing a system using DATRAN Browser it is noticed that data is missing it is likely that the data in the DATRAN Server has been corrupted. Sometimes an unplanned (forced) shutdown of the computer can also cause TBD file corruption if the file was being written at the time the power was removed. The only thing that can be done is to load a back up of the TBD file:

1. Stop DATRAN Services, if they are currently running. This can be done from DATRAN Browser, or the Windows Services Control (services.msc). If using Windows Services Control, the easiest way is to stop Tree Base Server as all other services have a dependency on this and will also stop automatically.
2. Once the services have stopped, rename the TBD file you suspect is corrupt to something obvious. The default location of the TBD file is `Datran\Data`.
3. Copy your back-up TBD file into the `Datran\Data` directory and rename it so that it has the file name the corrupt one originally had before you renamed it.
4. Select **Start Services** from the **Server** menu in DATRAN Browser. Alternatively, services.msc can be used to start all the services one at a time.
