This app provides a capability to backup a RethinkDB instance. Data is dumped to a compressed archive. This app can attach to a file synchronization service (e.g. rClone) and initate a request to copy dumps to a remote store.
The system is configured to initiate a backup when changes are made to the RethinkDB factoid database document table:
- A
documentis added - A
document'sstatusfield is updated topublic - A
documentwithstatus = publicis updated (//TODO)
Each backup request can be configured to occur with a given delay (default is 3 hours). When a backup is scheduled, further requests are ignored during this period enabling the system to aggregate or 'batch' changes.
A built-in webserver provides the following HTTP endpoints:
/: list the database dumps (naming convention<DB_NAME>_dump_<DATETIME>.tar.gz)/backup: initiate a backup (requiresapiKeyas URL param, when configured)/<dump name>: download a database dump
- NodeJS (>=14.16.0 LTS)
You must also have access to a running instance of RethinkDB and a file synchronization service like rClone.
-
Clone this remote
git clone https://github.com/PathwayCommons/rethinkdb-backup.git
-
Install packages
cd rethinkdb-backup npm install -
Run the app
npm run start
-
Point your browser at http://localhost:3000/
The following environment variables can be used to configure the server:
General:
NODE_ENV: the environment mode; eitherproductionordevelopment(default)BASE_URL: used for logging currentlyPORT: the port on which the server runs (default3000)LOG_LEVEL: minimum log level; one ofinfo(default),warn,errorDUMP_DIRECTORY: name of the directory where database dumps are placed (archives)DUMP_PATH: the url path prefix to addAPI_KEY: the API key for protected endpoints (i.e./backup)
Database:
DB_NAME: name of the db (defaultfactoid)DB_HOST: hostname or ip address of the database host (defaultlocalhost)DB_PORT: port for the database host (default:28015)DB_USER: the db userDB_PASS: the db passwordDB_CERT: the path to the certificate if db uses TLS
Backup:
DUMP_DATE_FORMAT: format for the date stamp used in naming the zipped archive - i.e.${DB_NAME}_dump_<date stamp>.tar.gz(defaultyyyy-MM-dd_HH-mm-ss-SSS)BACKUP_DELAY_MIN: the time to wait before triggering a backup (default180)
Sync Service:
SYNC_ENABLED: Use the Sync service (defaulttrue)SYNC_HOST: Sync service host name (defaultlocalhost)SYNC_PORT: Port that the sync service is bound to (default5572)SYNC_LOGIN: User name for authentication.SYNC_PASSWORD: Password for authentication.SYNC_CMD: Sync service commmand to execute (for rClone itssync/copy)SYNC_SRC: A remote name string e.g. "drive:src" for the sourceSYNC_DST: A remote name string e.g. "drive:dst" for the destination
Images are maintained on Docker Hub.
- Make sure the linting is passing:
npm run lint - Bump the version number with
npm version, in accordance with semver. Theversioncommand innpmupdates bothpackage.jsonand git tags, but note that it uses avprefix on the tags (e.g.v1.2.3). - For a bug fix / patch release, run
npm version patch. - For a new feature release, run
npm version minor. - For a breaking API change, run
npm version major. - For a specific version number (e.g. 1.2.3), run
npm version 1.2.3. - Push the release:
git push origin --tags