Dependencies: Raspbian (ARMHF)
Validated using:
Linux raspberrypi 5.4.79-v7+ #1373 SMP Mon Nov 23 13:22:33 GMT 2020 armv7l GNU/Linux(2020-12-02-raspios-buster-armhf) using Raspberry Pi 2 Model BLinux raspberrypi 5.4.83-v8+ #1379 SMP PREEMPT Mon Dec 14 13:15:14 GMT 2020 aarch64(2021-01-11-raspios-buster-armhf) using Raspberry Pi 3 Model B+
Note: Build environment must have at least 1GB of memory & 1GB swap space. Check with swapon.
1 | sudo apt install build-essential |
For notifications the following is also necessary:
1 | sudo apt install libnotify-dev |
ARMHF Architecture (Raspbian etc)
Note: Build environment must have at least 1GB of memory & 1GB swap space. Check with swapon.
1 | git clone https://github.com/abraunegg/onedrive.git |
Uninstall
1 | sudo make uninstall |
If you are using the --confdir option, substitute ~/.config/onedrive above for that directory.
If you want to just delete the application key, but keep the items database:
1 | rm -f ~/.config/onedrive/refresh_token |
Authorize the application with your OneDrive Account
After installing the application you must authorize the application with your OneDrive Account. This is done by running the application without any additional command switches.
You will be asked to open a specific URL by using your web browser where you will have to login into your Microsoft Account and give the application the permission to access your files. After giving permission to the application, you will be redirected to a blank page. Copy the URI of the blank page into the application.
1 | [user@hostname ~]$ onedrive |
Example:
1 | [user@hostname ~]$ onedrive |
Show your configuration
To validate your configuration the application will use, utilize the following:
1 | onedrive --display-config |
This will display all the pertinent runtime interpretation of the options and configuration you are using. This is helpful to validate the client will perform the operations your asking without performing a sync. Example output is as follows:
1 | onedrive version = vX.Y.Z-A-bcdefghi |
Testing your configuration
You are able to test your configuration by utilising the --dry-run CLI option. No files will be downloaded, uploaded or removed, however the application will display what ‘would’ have occurred. For example:
1 | onedrive --synchronize --verbose --dry-run |
Note: --dry-run can only be used with --synchronize. It cannot be used with --monitor and will be ignored.
Performing a sync
By default all files are downloaded in ~/OneDrive. After authorizing the application, a sync of your data can be performed by running:
1 | onedrive --synchronize |
This will synchronize files from your OneDrive account to your ~/OneDrive local directory.
If you prefer to use your local files as stored in ~/OneDrive as the ‘source of truth’ use the following sync command:
1 | onedrive --synchronize --local-first |
Performing a selective directory sync
In some cases it may be desirable to sync a single directory under ~/OneDrive without having to change your client configuration. To do this use the following command:
1 | onedrive --synchronize --single-directory '<dir_name>' |
Example: If the full path is ~/OneDrive/mydir, the command would be onedrive --synchronize --single-directory 'mydir'
Performing a ‘one-way’ download sync
In some cases it may be desirable to ‘download only’ from OneDrive. To do this use the following command:
1 | onedrive --synchronize --download-only |
Performing a ‘one-way’ upload sync
In some cases it may be desirable to ‘upload only’ to OneDrive. To do this use the following command:
1 | onedrive --synchronize --upload-only |
Note: If a file or folder is present on OneDrive, that does not exist locally, it will be removed. If the data on OneDrive should be kept, the following should be used:
1 | onedrive --synchronize --upload-only --no-remote-delete |
Configuration
Configuration is determined by three layers: the default values, values set in the configuration file, and values passed in via the command line. The default values provide a reasonable default, and configuration is optional.
Most command line options have a respective configuration file setting.
If you want to change the defaults, you can copy and edit the included config file into your configuration directory. Valid directories for the config file are:
~/.config/onedrive/etc/onedrive
Example:
1 | mkdir -p ~/.config/onedrive |
This file does not get created by default, and should only be created if you want to change the ‘default’ operational parameters.
See the config file for the full list of options, and All available commands for all possible keys and there default values.
The default configuration file is listed below:
1 | # Configuration for OneDrive Linux Client |
OneDrive service running as a non-root user via systemd (All Linux Distributions)
In some cases it is desirable to run the OneDrive client as a service, but not running as the ‘root’ user. In this case, follow the directions below to configure the service for your normal user login.
- As the user, who will be running the service, run the application in standalone mode, authorize the application for use & validate that the synchronization is working as expected:
1
onedrive --synchronize --verbose
- Once the application is validated and working for your user, as the ‘root’ user, where
is your username from step 1 above. eg:pi 1
2systemctl enable onedrive@<username>.service
systemctl start onedrive@pi.service