Skip to content

pryv/pryv-account-backup

Repository files navigation

Pryv.io account backup

Simple script to backup your Pryv.io data

Script Usage

Prerequisites: Node 18 or newer (required since 0.4.0 — uses native FormData + fs.openAsBlob).

In your terminal, run the following commands:

git clone https://github.com/pryv/pryv-account-backup.git to download the script

cd pryv-account-backup to go in the script folder

npm install to download required dependencies

npm start to launch the backup script.

This will ask you for the service-info url, username and password of the Pryv account you wish to back up.

You can finally choose to backup also trashed data as well as attachment files.

Format

Your data will be downloaded in ./backup/{apiEndpoint}/

This downloads the following in JSON format:

  • Public profile
  • Accesses
  • Streams
  • Events
  • Account Info
  • Audit log (audit_logs.json) — every audited operation on the subject (added in 0.3.0)
  • Webhooks per access (webhooks.json, keyed by accessId) — added in 0.3.0

As well as the following in binary files:

  • Attachment files (when includeAttachments: true)
  • High-frequency series data points (hf-data/<eventId>.json, one per series:* event) — added in 0.3.0

Finally, a per-file integrity manifest is written to manifest.json — sha256 of every other file in the backup, plus tool version + ISO generation timestamp. A third party reading the backup tarball can re-hash each file and compare to detect truncation, corruption, or tampering mid-flight. The manifest.verify(rootDir, cb) helper does this programmatically.

Running conditions

The operation might take a while in case the data size is substantial. Please, leave requests here

As a package

It is also possible use the backup function in your code.

Add the following to your package.json: "pryv-backup":"git+ssh://git@github.com:pryv/pryv-account-backup.git"

then use it as following:

const backup = require('pryv-backup');

const settings = {
      service: SERVICE_INFO_URL,
      username: USERNAME  
      password: PASSWORD,  
      includeTrashed: true, // default: false  
      includeAttachments: true // default: false
    };  
settings.backupDirectory = new backup.Directory(apiEndPoint);  

backup.start(settings, function (err) {
      if (err) {
        // manage error
      }
      // ...
});

## (Experimental) Restore Streams and Events to another account

npm start restore <path to backup dir>

Contribute

Prerequisites: Node v8+

Install dependencies: npm install

Run tests: npm run test

License

MIT License as included

About

Simple script to backup your Pryv.io data

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors