ioBroker.js-controller icon indicating copy to clipboard operation
ioBroker.js-controller copied to clipboard

Improve backup restore to redis

Open klein0r opened this issue 3 years ago • 1 comments

Situation:

  1. ioBroker is running on a system with redis
  2. redis is used for objects and states
  3. the system creates backups automatically (to a usb stick)
  4. the system crashed

Solution:

  1. Setting up a new iobroker installation with the installation script (curl -sLf https://iobroker.net/install.sh | bash -)
  2. Restoring the backup from the usb stick

Issue:

  1. The new iobroker installation has configured jsonl as database for objects and states
  2. The backup configuration contains redis as database

After the restore process, all information have been written to jsonl, the redis database is empty but iobroker uses the redis dabase instead of jsonl.

Tested with js-controller 4.0.21


Expected result:

The restore process recognizes, that the backup target is redis and uses that configuration of the backup before restoring the databases

or

The restore process keeps the database configuration of the current (new) installation, restores the database to that target and overrides the database configuration of the restored config (in this case from redis to jsonl). When the user wants to use redis afterwards, the iob setup custom process is required to migrate the data.

klein0r avatar May 18 '22 07:05 klein0r

In my opinion option 2 would be the better way

  1. The js-controller can save the objects and states attribute of /opt/iobroker/iobroker-data/iobroker.json before the restore process (of the current system)
  2. The backup will be restored
  3. The js-controller overrides these properties to ensure everything is working again
  4. If the config is different, the user should be informed with a warning (e.g. backup has configured redis as database, but the current system uses jsonl)
"objects": {
  "type": "redis",
  "typeComment": "Possible values: 'file' - [port 9001], redis - [port 6379], couch - [port 5984].",
  "host": "127.0.0.1",
  "port": 6379,
  "noFileCache": false,
  "maxQueue": 1000,
  "connectTimeout": 2000,
  "writeFileInterval": 5000,
  "options": {
    "auth_pass": null,
    "retry_max_delay": 5000,
    "retry_max_count": 19,
    "db": 0,
    "family": 0
  },
  "backup": {
    "disabled": false,
    "files": 24,
    "filesComment": "Minimal number of backup files, after the deletion will be executed according to backupTime settings",
    "hours": 48,
    "hoursComment": "All backups older than 48 hours will be deleted. But only if the number of files is greater than of backupNumber",
    "period": 120,
    "periodComment": "by default backup every 2 hours. Time is in minutes. To disable backup set the value to 0",
    "path": "",
    "pathComment": "Absolute path to backup directory or empty to backup in data directory"
  }
},
"states": {
  "type": "redis",
  "typeComment": "Possible values: 'file' - [port 9000], 'redis' - [port 6379].",
  "host": "127.0.0.1",
  "port": 6379,
  "connectTimeout": 2000,
  "writeFileInterval": 30000,
  "options": {
    "auth_pass": null,
    "retry_max_delay": 5000,
    "retry_max_count": 19,
    "db": 0,
    "family": 0
  },
  "backup": {
    "disabled": false,
    "files": 24,
    "filesComment": "Minimal number of backup files, after the deletion will be executed according to backupTime settings",
    "hours": 48,
    "hoursComment": "All backups older than 48 hours will be deleted. But only if the number of files is greater than of backupNumber",
    "period": 120,
    "periodComment": "by default backup every 2 hours. Time is in minutes. To disable backup set the value to 0",
    "path": "",
    "pathComment": "Absolute path to backup directory or empty to backup in data directory"
  }
},

klein0r avatar May 18 '22 07:05 klein0r