restore

Restore from a backup file created with the new_backup function.

Before using this function the following list of requirements must be must be fulfilled:

  • The user performing the restore must have FULL privileges on the@thingsdb scope.
  • No (non-empty) collections may exists. Use collections_info() and del_collection(..) to check and remove existing collections.
  • No modules may exists. Use modules_info() and del_module(..) to check and remove existing modules.
  • No tasks may exists in the @thingsdb scope. Use tasks() and task(..).del() to check and remove existing tasks.
  • All nodes must be online and ready. If this is not the case, then either remove the node or wait for the node to become ready. Use nodes_info() to check for the status of the nodes.
  • When having multiple nodes, all committed changes must be stored as well. Function nodes_info() shows both the committed_change_id and stored_change_id for all nodes. This is not a requirement when using a single node.

After running this function, all existing users and tokens will be overwritten, including the user performing the restore unless the take_access argument will be set to true. In both cases it is required to re-authenticate to ThingsDB after the restore is completed.

This function generates a change.

Function

restore(filename, [options])

Arguments

Argument Type Description
filename str Tar file containing the backup, usually a file ending with .tar.gz.
options thing (optional) A thing with optional options.

Options

Option Type Description
take_access bool When true, the users and tokens will not be restored and all associated tasks will be cleared. The user performing the restore will be granted full access to all scopes. Default is false.
restore_tasks bool When true, the tasks will be also be restored. If false or when take_access is set to true, all the tasks will be cleared. Default is false.

The options take_access and restore_tasks cannot both be set to true.

Return value

Returns nil when successful.

Example

Restore from a backup file

restore('/tmp/backup.tar.gz', {
    take_access: true,
    restore_tasks: false,
});

Return value in JSON format

null