Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

sircuri/onedrive.js

Repository files navigation

Onedrive.js

This is a very limited implementation of the OneDrive API. It only supports uploading files (single or a folder recursivly).

There was a need to be able to backup files to Onedrive during the night from my Ubuntu server and Raspberry PI.

Prepare

  1. Copy the file config.json.example to config.json
  2. destinationPath should point to the folder on Onedrive where the uploaded files need to go
  3. http.external and http.port are the call back settings used by the Onedrive authentication and authorization step

Register application with Microsoft

  1. Go to your Microsoft Azure AD Admin page
  2. Go to Azure Active Directory / App registrations and add a new registration
  3. Enter a Name for your new app
  4. Enter a Redirect URI for your app to call back to. ie: http://localhost:8000

Note: A redirect may be http://localhost:port. Otherwise it must be a HTTPS url. Any other URI is not allowed.

  1. Click Register
  2. Copy the value from 'Application (client) ID' and use that as clientId in the config file
  3. Go to Certificates & Secrets
  4. Click + New client secret
  5. Enter a description and select an expiration for the new secret
  6. Copy the generated value use that as clientSecret in the config file

Usage

NodeJS is required to run this application

To upload a single file file.ext from /var/backups folder:

node ./lib/index.js upload -f config.json -w /var/backups -d /file.ext

To upload all the files from /var/backups folder:

node ./lib/index.js upload -f config.json -w /var/backups -d /

Docker

In the config.json file the http.port must be set to 8001 and the http.external must be set to the URI accessible.

docker run -i --rm --user=root:root -v /location/config.json/is:/config -v /var/backups:/workdir -p 8001:8001 sircuri/onedrive -d /file.ext

There is also a docker image created for running on a Raspberry. Use the following tag sircuri/onedrive:latest-pi

About

Onedrive Node JS Upload client

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published