How to Sync Microsoft OneDrive with Linux

93 comments

  1. ESink

    Hey! I’m getting an error upon compiling:
    user:~/onedrive $ make
    dmd -g -ofonedrive -O -L-lcurl -L-lsqlite3 -L-ldl -J. src/config.d src/itemdb.d src/log.d src/main.d src/monitor.d src/onedrive.d src/qxor.d src/selective.d src/sqlite.d src/sync.d src/upload.d src/util.d
    make: dmd: Command not found
    Makefile:29: recipe for target ‘onedrive’ failed
    make: *** [onedrive] Error 127

    1. Damien

      You are missing the dlang complier (dmd) in your system. You can download and install it from here (https://dlang.org/download.html).

    2. Donald L Wilson

      I had the exact same issue on my first time running “make” after cloning the repo.
      I’m glad you asked this question it was the only real hangup that I had to deal with.

      And thanks to Damien for his quick follow-up response!!

  2. Ren

    I am having an issue with the starting onedrive at login. The part right here:

    sudo systemctl –user enable onedrive

    Returns this at the terminal:
    Failed to connect to bus: No such file or directory

    what step should I take next?

    1. Damien

      Can you run the command: export XDG_RUNTIME_DIR=/run/user/`id -u` and enable the autostart command again.

  3. Honza

    Is possible to run multiple client simultaneously? I have 1 personal and 2 bussiness account, is possible to have all 3 synchronized ?

    1. Glen

      Yes. You need to create a different configuration file for each instance. For example, you may have:
      ~/.config/onedrive
      ~/.config/onedrivebusiness1
      ~/.config/onedrivebusiness2

      Copy the config file from the build directory to each of the above 3, then modify them accordingly.

      Initialize each with:

      onedrive –synchronize
      onedrive –confdir ~/.config/onedrivebusiness1 –synchronize
      onedrive –confdir ~/.config/onedrivebusiness2 –synchronize

      Start each one from the command line, or if from rc.local with something like:

      sudo -u yourusername /usr/local/bin/onedrive –monitor 2>1 > /dev/null &
      sudo -u yourusername /usr/local/bin/onedrive –confdir ~/.config/onedrivebusiness1 –monitor 2>1 > /dev/null &
      sudo -u yourusername /usr/local/bin/onedrive –confdir ~/.config/onedrivebusiness2 –monitor 2>1 > /dev/null &

    2. Alex

      Yes it is possible – refer to the following for assistance: https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md#using-multiple-onedrive-accounts

  4. Donald L Wilson

    Very informative and descriptive article. It took me a few, but Onedrive is up and running without any issues thanks to your post!!

  5. Princeton

    Hi Damien,
    I’m running into an error while trying to install onedrive
    user:~/onedrive$ make

    cc: No such file or directory
    Error: linker exited with status 255
    Makefile:29: recipe for target ‘onedrive’ failed
    make: *** [onedrive] Error 1

    1. Geoffrey Hoffmann

      Do you have Ubuntu 18.04 Server edition? You probably don’t have the g++ package installed.

      Enter the following command into a Terminal window

      sudo apt install g++

      Then you should be good to go.

  6. abraunegg

    Hi all,

    The git clone command is referring to git clone https://github.com/skilion/onedrive.git which appears to have been abandoned and contains issues that have not been fixed.

    If you wish to use the latest code which contains numerous fixes and enhancements you need clone from here: https://github.com/abraunegg/onedrive

    @Ren – Your issue is fixed in the updated branch – it is a coding defect as to why it does not work
    @Honza – Yes it is, you need 3 separate configuration files / config directories but no issue in doing that.

    1. Keri

      Hi @abraunegg
      This git is indeed great. I am using it to sync my onedrive account, which has a fair large amount of files (~150k), and the sync is a bit slow. Is there any way of boosting it somehow?

      1. Alex

        I would suggest that you ensure you are using the latest version (2.3.3) or later as some performance enhancements were included in the last few releases.

        Also – monitor the github site for known issues and current WIP branches for fixes

  7. Gert Kruger

    I get and error when I do the Configuration part. When I run “cp ~/onedrive/config ~/ .config/onedrive/config” I get the following error: cp: target ‘.config/onedrive/config’ is not a directory

    Any help you can propose? Thanks a lot!

    1. Wim van der Veen

      @Gert Kruger There is a space too much in the command, it should read “cp ~/onedrive/config ~/.config/onedrive/config”

  8. Craig Taylor

    Hi Damien,
    I followed your instructions and onedrive was working and syncing fine. Then I changed my microsoft account password.
    I now get an authentication error:

    “error_description”: “AADSTS70000: The user could not be authenticated as the grant is expired. The user must sign in again.\r\nTrace ID: 335b3c36-b284-41e0-86a1-b2fa77f52700\r\nCorrelation ID: 251bfd43-68fa-455e-bda0-987a3c6938cc\r\nTimestamp: 2019-01-27 08:13:42Z”

    What command do I use to change my password?

    1. Damien

      Craig, the onedrive application is using token to communicate with your OneDrive account. It doesn’t store your password. You can go to “~/.config/onedrive” folder and remove the “refresh_token” file (optionally the sqlite file too). If you want, just move them to another location (instead of deleting them). Then run “onedrive” command again and it should prompt you to reauthorize access to your OneDrive account.

  9. Craig Taylor

    Hi Damien,
    I renamed the “refresh_token” and sqlite files, ran onedrive and when I entered the URI response provided by microsoft I got the following message:

    “Delta link expired, resyncing
    std.json.JSONException@/usr/lib/gcc/x86_64-linux-gnu/7/include/d/std/json.d(551): JSONValue is not an object”

    I did a bit of reseach that resulted in running the “onedrive –resync –verbose” command, then all my files started sycning.

    Everything is now all good. Thank you very much for your help – people like you make the world a better place.

    Regards
    Craig Taylor

  10. Mudassirkhan Pathan

    $ sudo systemctl –user enable onedrive
    Failed to connect to bus: No such file or directory

  11. getinmymailbox

    Thanks for this, and thanks to abraunegg for the update! This works beautifully.

    However, how do I avoid re-uploading files I’ve deleted from OneDrive itself but are stored on the local machine?

  12. Rudolf Mouthaan

    All is well until after starting onedrive and copy the onedrive url after logging in.
    After pasting and enter it saysL:
    Invalid uri. Could not initialize onedrive API

  13. Shashank

    Thanks Damien. I was able to get OneDrive working. I used the following repo.

    https://github.com/abraunegg/onedrive

    I had only one issue:

    https://github.com/abraunegg/onedrive
    Error: Failed to connect to bus: No such file or directory

    I tried your suggested cmd: export XDG_RUNTIME_DIR=/run/user/`id -u`

    I still get the same error. Since this is to only enable autostart on login. I am fine if I have to manually start the service.

    It’ll help if you can suggest on how can I deal with the error or what are the steps I can follow to manually start the service. (I guess I should use onedrive –synchronize. Correct me if I am wrong)

    Thank you for the detailed article. This was the last thing I was looking for to completely move from Windows to Ubuntu.

    1. Damien

      Instead of using systemd, you might just want to add the code onedrive --synchronize to your startup application list.

  14. Dante

    Hello Damien, I quite new in Linux, and I was installing OneDrive and after pasting the url of the white blank page into the terminal it says:

    “–synchronize or –monitor missing from your command options or use –help for further assistance”

    So the –synchronize command doesn’t work.

    What should I do?

  15. Sorin Srbu

    Hell again,

    “monitor_interval: the time interval between sync operations.

    Once you have made the changes, save and restart onedrive.”

    Restart how?
    This info needs to be added.

    1. Anbarasan

      To enable the onedrive service

      systemctl –user enable onedrive

      To start the service

      systemctl –user start onedrive

      To restart the service

      systemctl –user restart onedrive

  16. Patrick A McKinley

    Hi Damien

    I have tried this method/tool out and got semi-good results. It is syncing the folders and files I had on my OneDrive, EXCEPT it will not sync OneNote files. They are just ignored.

    Am I out of luck here? Or is there something I can do to enable OneNote….which is my primary objective in getting OneDrive to sync.

    Thanks,
    …Patrick

  17. Patrick A McKinley

    Hi Damien

    I ran `onedrive –resync –synchronize -v+` and found some entries like the following:
    This item type (Patrick’s Woodshop) is not supported

    Since this item is a OneNote file I am concluding that I will not be able to sync OneNote files with this tool.
    Do you have any further insight?

    Thank you!
    …Patrick

    1. Alex

      The onedrive client uses the OneDrive API, where as OneNote uses a totally different API as per https://docs.microsoft.com/en-us/onedrive/developer/rest-api/?view=odsp-graph-online#working-with-onenote-notebooks – using the ‘onedrive’ client to sync OneNote files is not possible.

  18. Mike

    Hi Damien!

    I’m using Linux Mint and ran into the same problem as Dante did – neither the synchronize nor the monitor commands are available. I got

    –synchronize or –monitor missing from your command options or use –help for further assistance

    No OneDrive sync will be performed without either of these two arguments being present

    What do I do to rectify this?

    1. Alex

      It is best you refer to the readme to assist with commands and configuration: https://github.com/abraunegg/onedrive/blob/master/README.md

      1. Silas

        Alex, what do you mean by this? Please elaborate.
        Is there any awas –synchronize or –monitor can be added to our command options, or something like that?

        1. Alex

          @silas
          You need to refer to https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md for the usage of the application.

  19. Phil

    Thanks for this. One point though …

    This section:
    cd onedrive
    make
    sudo make install

    … didn’t work for me out the box on Ubuntu 19.04. I had to do this instead:
    cd onedrive
    ./configure
    make
    sudo make install

  20. Julio

    Does anyone know how to sync additional folders (OneDrive – Company) into this OneDrive CLI? I’m only available to sync personal files within OneDrive, which renders it almost useless.

    Regards

    1. Alex

      This is supportes in my version. Refer to https://github.com/abraunegg/onedrive/blob/master/README.md for details

  21. Mike

    This may sound like an idiot’s question but does the client for linux encrypt data in transit like the Windows onedrive client does?

  22. Rui

    Hi Damien,

    When I run the command “onedrive”, I didn’t get the link to verify my account info. Instead, it gave “Delta link expired, resyncing” and some other staff (it ends with “Segmentation fault (core dumped)”). Do you happen to know what this might be?

    Thanks,
    Rui

    1. Alex

      If you have any issues with the client, rather than posting a comment here – please post an issue ticket here – https://github.com/abraunegg/onedrive/issues

      1. Rui

        Thank you! I got it fixed somehow. It seems the reason is that I installed before and had verified my onedrive account back then.

  23. Jampe

    Great for users with small OneDrive but I get error message in the middle of synchronizing. Enabling verbose mode I get:

    Downloading: Pictures/Camera Roll/20151017_192622.jpg
    sync.SyncException@src/sync.d(182): HTTP request returned status code 429 (Too Many Requests)
    —————-
    0x55990725491a ???
    ???:0
    0x55990724a002 ???
    ???:0
    0x559907249a72 ???
    ???:0
    0x55990739d8be ???
    ???:0
    0x55990739da2e ???
    ???:0
    0x55990739ddea ???
    ???:0
    0x55990739da2e ???
    ???:0
    0x55990739dbc0 ???
    ???:0
    0x559907248ea3 ???
    ???:0
    0x7f6662f1cb96 __libc_start_main
    ???:0
    0x559907240c99 ???
    ???:0
    0xffffffffffffffff ???
    ???:0
    onedrive.OneDriveException@src/onedrive.d(396): HTTP request returned status code 429 (Too Many Requests)
    —————-
    0x55990724e9b3 ???
    ???:0
    0x55990724df3d ???
    ???:0
    0x55990724c829 ???
    ???:0
    0x55990725556d ???
    ???:0
    0x5599072551d8 ???
    ???:0
    0x55990725446c ???
    ???:0
    0x55990724a002 ???
    ???:0
    0x559907249a72 ???
    ???:0
    0x55990739d8be ???
    ???:0
    0x55990739da2e ???
    ???:0
    0x55990739ddea ???
    ???:0
    0x55990739da2e ???
    ???:0
    0x55990739dbc0 ???
    ???:0
    0x559907248ea3 ???
    ???:0
    0x7f6662f1cb96 __libc_start_main
    ???:0
    0x559907240c99 ???
    ???:0
    0xffffffffffffffff ???
    ???:0

    1. Alex

      This is a known bug in ‘skilion’ codebase which is fixed in my fork – https://github.com/abraunegg

  24. Sergey

    sergey@sergey-inspiron-5770:~$ git clone https://github.com/abraunegg/onedrive.git
    Cloning into «onedrive»…
    remote: Enumerating objects: 62, done.
    remote: Counting objects: 100% (62/62), done.
    remote: Compressing objects: 100% (41/41), done.
    remote: Total 2698 (delta 39), reused 39 (delta 21), pack-reused 2636
    Получение объектов: 100% (2698/2698), 1.66 MiB | 1.84 MiB/s, готово.
    Определение изменений: 100% (1798/1798), готово.
    sergey@sergey-inspiron-5770:~$ cd onedrive
    sergey@sergey-inspiron-5770:~/onedrive$ make
    make: *** No targets set and no makefile found. Stop.

  25. Cris

    Hi there!
    I still get the trouble with the ./configue && make && make install. It did synchronized but I cannot set up the configuration.

    see the error below:

    checking for a BSD-compatible install… /usr/bin/install -c
    checking for pkg-config… no
    checking for dmd… dmd
    checking for curl… no
    configure: error: in `/home/taotoa/onedrive’:
    configure: error: The pkg-config script could not be found or is too old. Make sure it
    is in your PATH or set the PKG_CONFIG environment variable to the full
    path to pkg-config.

    Alternatively, you may set the environment variables curl_CFLAGS
    and curl_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.

    To get pkg-config, see .
    See `config.log’ for more details

    1. Jim

      checking for a BSD-compatible install… /usr/bin/install -c
      checking for pkg-config… no
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      This is the problem. I had the same error messages, and was confused by this red herring:

      “checking for curl… no”

      Especially since “curl” was on my ubuntu 18.04 install.

      The solution:

      sudo apt install pkg-config

      At least it worked for me. Good luck!

      1. Kevin

        Thanks! This is the one part I was missing. All works for me know. Thanks to the maketecheasier folks for the article and fixes and to Jim for the pkg-config help.

  26. Luke

    Thanks for the write-up!

    One small thing – I had to run `./configure` before being able to run `make`.

  27. Hector

    Hi!
    Thank you very much for this useful page. In my case, the manual sync works but not as a service. When running:
    systemctl status onedrive@user.service
    I get:
    jun 25 11:36:28 onedrive[14733]: There was a problem in accessing the Microsoft OneDrive service – Internet connectivity issue?
    jun 25 11:36:28 onedrive[14733]: Cannot initialize connection to OneDrive
    I’ve edited the file onedrive.service and I’ve added the details of the proxy as suggested.
    I’ve also seen in the same folder where onedrive.service is very similar files that I have not edited although they have very similar structure. The files are:
    -rw-r–r– 1 user user 395 jun 25 11:28 onedrive.service
    -rw-r–r– 1 user user 336 jun 7 08:23 ‘onedrive@.service’
    -rw-r–r– 1 user user 268 jun 7 08:23 onedrive.service.in
    -rw-r–r– 1 user user 334 jun 7 08:23 ‘onedrive@.service.in’
    Any suggestion to make the service work as expected and automatically sync all the changes?
    Thanks,

    1. Alex

      You need to pay special attention to how you are activating the user service files. Refer to https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md#onedrive-service-running-as-a-non-root-user-via-systemd

  28. Ax

    I’m running Ubuntu 18.4.2 when I ran sudo snap install –classic dmd && sudo snap install –classic dub I got this error “error: unknown flag `classic’”
    So I tried the instructions for Ubuntu 17 and all appeared to go well until I entered make and got this error “make: *** No targets specified and no makefile found. Stop.”
    I found a post where someone was having problems with make and posted this solution “./configure” I ran it and got this error.
    checking for a BSD-compatible install… /usr/bin/install -c
    checking for pkg-config… /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0… yes
    checking for dmd… no
    checking for ldmd2… no
    checking for ldc2… no
    configure: error: Could not find any compatible D compiler

    Which looks like it points back to my first error. Any suggestions?

    1. Alex

      You need to pay special attention to https://github.com/abraunegg/onedrive/blob/master/docs/INSTALL.md

      The instructions on this website above are not correct and need to be updated

  29. Brad

    Hi there,

    I’ve downloaded the onedrive files and installed dmd but when I run the “make” command it says “No targets specified and no makefile found. Stop.”

    1. Tamas

      That happens because there is no file named Makefile in that directory. To create that Makefile, you need to execute

      ./configure
      make
      sudo make install

  30. Steve

    “and grant the app permission to access your account. …. ”
    and how do you do that? Where would I start looking on Onedrive to find something that says grant the app permission?

  31. rozkoc

    Thank you, It works properly but I want to uninstall for some reasons. I couldn’t manage that. How can I remove this?

  32. Poul

    I installed snap, but it turned out to be snapd, instead.
    The rest went smoothly.
    Thank you.

  33. z0rk

    I am using a second internal HD to hold my OneDrive folder:

    sync_dir = “/media/z0rk/02/OneDrive

    Should this drive become unavailable (fail/not mounted) what would happen if onedrive is configured to monitor/synchronize changes every 5 minutes? Will it convert back to sync_dir = “~/OneDrive”? I believe not. Could somebody please confirm?

    Thanks

    1. Alex

      @z0rk
      Best to submit support questions here https://github.com/abraunegg/onedrive rather than this website.

      To answer your question, you can utilise this method: https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md#how-to-skip-directories-from-syncing

      Add a ‘.nosync’ file to the folder which you mount the drive to, then configure ‘check for nosync’ to prevent syncing if this drive becomes unavailable

  34. John

    Fantastic article, however my onedrive only ran a synch on the initial config.
    now when i run it, it refuses to communicate with the following verbose snips which i think is RC.
    My ubuntu is behind a corporate proxy but my env is set and i can browse an curl OK.
    verbose:
    Initializing the OneDrive API …
    Cannot connect to Microsoft OneDrive Service
    Reason: Failure when receiving data from the peer on handle 55A40202BDE0

    1. Alex

      @John
      You have not configured proxy correctly – refer to https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md#access-onedrive-service-through-a-proxy

  35. slowjoe007

    Thanks for the great tutorial!
    I use CentOS 7 and realized that the section for Fedora applies quite well, but misses the instruction to also install ‘gcc’. Maybe this is included in Fedora out of the box. Nevertheless, it might be helpful to also add ‘gcc’ to the list of packages that need to be present.
    In addition, I realized that I needed to enter the ‘dmd’ mode(?) on my Linux shell:
    $ source ~/dlang/dmd-2.088.0/activate
    Only after that ‘./configure’ and the ‘make’ commands ran successfully. Might be worthwhile to mention the ‘source …/activate’ command and maybe the ‘deactivate’ call at the end explicitly within your awesome tutorial.

    1. Alex

      @slowjoe007

      This website’s install details are incorrect – please refer to the following: https://github.com/abraunegg/onedrive/blob/master/docs/INSTALL.md

  36. Vinay Teja Reddy

    Works fine, but onedrive limit is 5GB so when the onedrive reached 3.9 GB and i am putting a 2 GB file in OneDrive folder and it starts syncing, beacuse there is no space left in onedrive it doesn’t tell that there is no space and it always try to upload file and wastes the bandwidth.

  37. CasaDelGato

    Since I use OneDrive for Business, this version didn’t work for me.
    I switched to using this fork: https://github.com/abraunegg/onedrive
    Handles syncing shared libraries.

  38. Carlos

    I am getting an unknown key in config file: download_only

    I did change this setting, but after reversing, I still get the same error. I can not even synchronize

    1. Alex

      @Carlos
      Do not seek support on this website. Please open a new issue for assistance here: https://github.com/abraunegg/onedrive

  39. carmal shaktan

    Thank you for this structured document. I’m using this client to backup my Jenkins configurations. I would like to run this in a mode where even if my local file is deleted , I would not wont it to reflect on my OneDrive cloud. This is so that in-case my local directory gets wiped out, I can still download the files via OneDrive. Is this feature possible ?. I’ve tried by setting the “upload-only” and “no-remote-delete” in ~/.config/onedrive/config to true but unfortunately it did not solve the problem. Please let me know what can be done.

    1. Alex

      @carmal shaktan
      Do not seek support on this website. Please open a new issue for assistance here: https://github.com/abraunegg/onedrive

  40. SG13

    I’ve been using Manjaro as of late, and loving it. I usually us terminal for most everything but decided to try useing pamac-manager with AUR and SNAP enabled. It installed all the dependencies for me. Works great and I now have easy access to the files I keep on onedrive.

  41. Jaher Pruky

    Hello,
    I ran onedrive –synchronize –resync successfully. All files and folders were said to be downloaded, but I only see empty folders in my local ~/onedrive. What has happened actually?
    Thanks,
    Japy

    1. Alex

      @Jaher Pruky
      Do not seek support on this website. Please open a new issue for assistance here: https://github.com/abraunegg/onedrive

  42. Castigo HD

    Thank you (although I shold’ve thanked last year)

    Ever since the realease of Ubuntu 18.04 I’ve been changing the OS version (full reinstall) and this is one of the first tools I install right away. Just did it again on 19.10 and it’s working like a charm, as always. Thank you again

  43. Alex

    Please can you update your website / document to remove all links to ‘Skilion’ version – this repo is unmaintained and is defunct.

    Also, your Ubuntu 18.x instructions are wrong. Please refer to https://github.com/abraunegg/onedrive/blob/master/docs/INSTALL.md

  44. Bruce

    I am trying to get this to work. I am new to Linux and compiling
    I get the following error:
    :~/onedrive$ ./configure
    checking for a BSD-compatible install… /usr/bin/install -c
    checking for pkg-config… /usr/local/bin/pkg-config
    checking pkg-config is at least version 0.9.0… yes
    checking for dmd… dmd
    checking version of D compiler… 2.090.0
    checking for curl… no
    configure: error: Package requirements (libcurl) were not met:

    No package ‘libcurl’ found

    Consider adjusting the PKG_CONFIG_PATH environment variable if you
    installed software in a non-standard prefix.

    Alternatively, you may set the environment variables curl_CFLAGS
    and curl_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.

  45. Ludo

    Hi,
    I followed the instruction in the “Configuration” part, but now everytime I try to do something it says:
    “Configuration file has errors – please check your configuration”
    Although the config file is in the /.config/onedrive directory
    What did I do wrong? Thank you!

  46. Antonius

    Well after trying out 7 different methods by other people including the abandoned onedrive-d and skillion, I hope my drive is finally working. Thank you for a well-written post.

  47. Louiseiana

    I don’t understand how the instructions of selective syncing the folder…. can someone help me with a little more detailed instructions??? Like how in creating the sync_list and creating the path (what path????)

    Does it sync only one way or both ways????

    Sorry, for any troubles. I’m new with this system :(
    Thanks in advance

Comments are closed.