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.
- Copy the file config.json.example to config.json
- destinationPath should point to the folder on Onedrive where the uploaded files need to go
- http.external and http.port are the call back settings used by the Onedrive authentication and authorization step
- Go to your Microsoft Azure AD Admin page
- Go to Azure Active Directory / App registrations and add a new registration
- Enter a Name for your new app
- 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.
- Click Register
- Copy the value from 'Application (client) ID' and use that as clientId in the config file
- Go to Certificates & Secrets
- Click + New client secret
- Enter a description and select an expiration for the new secret
- Copy the generated value use that as clientSecret in the config file
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 /
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