STANAG On Demand  Version 1.1.4
Scripts

Stanag On Demand Server Scripts** is a set of maintenance utilities for the StanagOnDemand server.

When no specific instructions are provided, the script obtains configuration information from the config.json file located in the sibling directory **./data** The following info is automatically extracted:

  • Database connection string
  • Video folder

This info can be overridden by the explicit arguments provided to the script.

Modes of operation

  • Backup
  • Restore
  • Export mission(s)
  • Import mission(s)

Script arguments

Short Command Command Description
-m –mode Modes: Backup or Restore DB / Export or Import mission
-u –uri DB Uri
-r –root Root folder for export / import. There may be one or more missions in that folder.
-c –collections Collection array to export. Comma separated. All by default
-d –drop Drop every collection from the target database before restoring the collection. Default: true
-v –video Video folder location. If specified 'none', video is not backed up / restored
–missions When in the Mission export or import mode, provide missionId. Multiple (comma or space separated) missions can be provided.
–exportDbOnly Export DB only. Skip video. Default - false.
–version Script version

Backup

Backup script will perform the following actions:

  • Extract the DB collections and copy them to db sub-folder of the supplied root
  • Copy missions assets found in videos to the video sub-folder of the supplied root
  • Copy config.json file found in data folder to the supplied root

    Usage:*

node index.js -m backup -r c:/tmp/backup/

For simplicity, the default script configuration can be run as a Windows batch file. The Output directory should be supplied with a parameter.

backup.bat**

backup c:/tmp/backup

Restore

Restore script will perform the following actions:

  • Import DB collections into the MongoDB from the supplied root/db
  • Copy missions assets found in the video sub-folder of the supplied root to videos destination (either specified in data/config.json or provided explicitly)
  • Copy config.json file found in root to data Server's folder

Note, by default, the document collections that exists in the DB will be dropped and the missions will be overwritten.

Usage:*

node index.js -m restore -r c:/tmp/backup/

For simplicity, the default script configuration can be run as a Windows batch file. The Input (archive) directory should be supplied with a parameter.

restore.bat**

restore c:/tmp/backup

Export mission

You can export one or more missions at once. Missions are exported as directories, containing assets and relevant db information.

Export* script will perform the following actions:

  • Extract Mission's DB collections and copy them to db sub-folder of the supplied root
  • Copy missions assets found in videos to the supplied root

    Usage:*

For single mission (by MissionId)

node index.js -m export --missions 5bc6e9de4b75ae3ef0383023 -r c:/tmp/backup/

Or using batch file:

export 5bc6e9de4b75ae3ef0383023 c:/tmp/backup

The resulting archive should look something like this:

tmp/
├── /backup/
│ ├── 5bc6e9de4b75ae3ef0383023/
│ ├── db
│ ├── mymission.m3u8
│ ├── mymission0000.ts
│ ├── mymission0001.ts
│ ├── mymission0002.ts
│ ├── mymission0003.ts

For multiple missions (by MissionId)

node index.js -m export --missions 5bc6e9de4b75ae3ef0383023,5bc70d124b75ae3ef038315a,5bdab6623c4cf92f646d0b93 -r c:/tmp/backup/

The resulting archive should look something like this:

tmp/
├── /backup/
├── 5bc6e9de4b75ae3ef0383023/
│ ├── db
│ ├── mymission.m3u8
│ ├── mymission0000.ts
│ ├── mymission0001.ts
│ ├── mymission0002.ts
│ ├── mymission0003.ts
├── 5bc70d124b75ae3ef038315a/
│ ├── db
│ ├── mymission2.m3u8
│ ├── mymission20000.ts
│ ├── mymission20001.ts
│ ├── mymission20002.ts
│ ├── mymission20003.ts
... ...

Import mission

Import** script will perform the following actions:

  • Import DB collections
  • Copy missions assets to the video folder (under sub-folder missionId)

The location of video assets is taken from the server's configuration file

Usage:*

For single mission import provide the name of the backed up mission folder.

node index.js -m import -r c:/tmp/backup/5bc6e9de4b75ae3ef0383023

Or using batch file:

import c:/tmp/backup/5bc6e9de4b75ae3ef0383023

For importing multiple missions (from one folder) provide the path to the folder

For example, as depicted below, the folder c:/tmp/backup contains 4 exported missions:

tmp/
├── /backup/
│ ├── 5bc70d124b75ae3ef038315a
│ ├── 5bc8586e4b75ae3ef0383651
│ ├── 5bc8586e4b75ae3ef0383856
│ ├── 5bc8586e4b75ae3ef0383968

So, to import all missions, just provide a folder location as a –root argument:

node index.js -m import -r c:/tmp/backup/
Untitled 1




 Copyright 2018,    IMPLEOTV SYSTEMS LTD