BVersluis Posted December 17, 2022 Share Posted December 17, 2022 (edited) I am a new user of Unraid and Docker and was looking for an alternative to Synology Cloud Sync, which I used to keep all my family's Onedrive files as harcopy on my previous NAS (multiple accounts). I was therefor not looking for an app like Duplicati/Duplicay to spread my files even further over the cloud, but to get my files back from the cloud and keep them synchronized. For this purpose I decided to run the Onedrive Client for Linux in a separate docker container for different Onedrive accounts on my Unraid install, which seems to work quite well. Below my beginners guide for how to set this up with docker compose following this guide. Requirements: Docker compose installed Dynamix File Manager installed (helpful) Step 1: In the Unraid WebUI open the terminal and type ‘id username’ for every user with onedrive account you want to install a Onedrive container for and write down the UID and GID for these users. Step 2: Add a share called ‘onedrive’ (or choose your own name). Optionally enable cache, select preferred disk(s) and decide if you want to export the share. Step 3: If you are planning to use multiple containers/accounts, create subfolders for every user as well in the just created onedrive folder (/onedrive/userA, /onedrive/userB, etc.). Do this before running the container later on. Step 4: Create a ‘onedrive’ folder under /mnt/user/appdata/ and again create subfolders (userA, userB etc.) for different users Step 5: Go to the Docker tab, scroll down to Compose and press ‘Add new stack’ Step 6: Type a project name (for example Onedrive-userA) and press ‘OK’ and again ‘OK’ after success Step 7: Click on the cog-wheel of the new created stack and press ‘Edit stack’ followed by ‘Compose file’ Step 8: Past in the composer file below: version: "3.7" services: onedrive: image: driveone/onedrive:latest container_name: Onedrive-userA stdin_open: true # docker run -i tty: true # docker run -t restart: unless-stopped environment: - ONEDRIVE_UID=1001 - ONEDRIVE_GID=100 volumes: - /mnt/user/appdata/onedrive/userA:/onedrive/conf/ - /mnt/user/onedrive/userA:/onedrive/data Step 9: Before saving, make the following changes to the composer file: · Change the container name in a name of your liking, for example Onedrive_UserA, Onedrive_UserB. · Change the UID and GID to the correct values for the user, as found in step 1 · Under volumes change the path left from the colon to the correct config and data folder (so ‘/mnt/user/appdata/onedrive/userA’ and ‘/mnt/user/onedrive/userA’ if the example above has been followed. Don't touch the values right from the colon. · Optionally, if you created your custom network for docker containers, you can add the network settings below and change 'nameofyournetwork' to the name of your network. Otherwise a new network (container_name_default) is created. Example: version: "3.7" services: onedrive: image: driveone/onedrive:latest container_name: Onedrive-userA stdin_open: true # docker run -i tty: true # docker run -t restart: unless-stopped environment: - ONEDRIVE_UID=1001 - ONEDRIVE_GID=100 volumes: - /mnt/user/appdata/onedrive/userA:/onedrive/conf/ - /mnt/user/onedrive/userA:/onedrive/data networks: - proxy networks: proxy: external: true name: nameofyournetwork Step 10: Press ‘save changes’ Step 11 (optional): If you want to add an icon to your docker container (otherwise you’ll see a questionmark), press the cog-wheel again, select ‘edit stack’ and select UI labels. On the internet find a link to the icon of your choosing (for example from Onedrive’s wiki) and past the link in this field. This can be done later on as well (by updating the stack). Press ‘OK’ when done. Step 12: Press ‘Compose up’ and press ‘Done’ when it is done. A new container is now created and running, but the Onedrive Client still needs to be connected to your Microsoft account with the following steps: Step 13: Stop the new container Step 14: In the right upper corner of the docker page, switch over from ‘Basic view’ to ‘Advanced view’. Now you can see the Container ID for your newly made container (for example 72409c107bd0). Copy this number. Step 15: Open the Unraid terminal and enter: docker start your_container_id --interactive Use right mouse and paste to paste your container ID in the terminal. Step 16: After entering the command and pressing enter, the container starts in an interactive mode and a link to Microsoft is shown in the terminal. You open this link by clicking on it and log in with the Microsoft credentials of the onedrive account you want to add. If successful, a blank page is shown. Copy the full address of this page and past it (right mouse and paste) in the terminal as the response URL and press enter. If the link is accepted, the client immediately starts downloading your files. Step 17: You can close the terminal, restart the container and everything should be working from now on. Step 18: Repeat step 5-17 for every account you want to add. For some reason you need to select a different Icon URL for every new container you want to add. In case you encounter permission errors when trying to access your downloaded files when using onedrive multiple accounts, check the solution below by Cholzer: Edited March 18, 2023 by BVersluis Additional information 1 1 Quote Link to comment
renegade5150001 Posted December 25, 2022 Share Posted December 25, 2022 Hey, thanks for this! I'm gonna give this a try. For the docker compose did you use the 'Docker Compose Manager' from Community applications>? thx Quote Link to comment
BVersluis Posted December 25, 2022 Author Share Posted December 25, 2022 Hey, yes, that's the one. Succes. Quote Link to comment
PeterPan Posted January 15, 2023 Share Posted January 15, 2023 (edited) Hi! in step 16 it downloads a file which is empty if I open it with a text editor. I login and it just wants to download a file... any ideas? Edit: Safari issue Edited January 15, 2023 by PeterPan Quote Link to comment
Bluppylein Posted January 17, 2023 Share Posted January 17, 2023 Thanks this i have search :). Why it give not one drive app directly on unRAID? 🙂 1 Quote Link to comment
PeterPan Posted January 22, 2023 Share Posted January 22, 2023 The great CA Maintainer BVersluis just uploaded a great working application. Just search in the shop 🙂 1 Quote Link to comment
deepbellybutton Posted January 23, 2023 Share Posted January 23, 2023 I would love to see this working with bpozdena/OneDriveGUI web interface as well. Any plans for that or a quick rundown on how to do it now if not? Great tool and thanks! John Quote Link to comment
BVersluis Posted January 24, 2023 Author Share Posted January 24, 2023 22 hours ago, deepbellybutton said: I would love to see this working with bpozdena/OneDriveGUI web interface as well. Any plans for that or a quick rundown on how to do it now if not? Great tool and thanks! John No, sorry I have no plans for that at the moment... 1 Quote Link to comment
Guo Jiacheng Posted January 25, 2023 Share Posted January 25, 2023 How can I change the new created file permission to 755? Right now, to share between users, I have repeatedly change new synced file permission to 755. The default permission is 500 ? Quote Link to comment
isaacgrant85 Posted January 25, 2023 Share Posted January 25, 2023 Currently having what I expect is the same issue. Look forward to hearing the answer! Quote Link to comment
BVersluis Posted January 26, 2023 Author Share Posted January 26, 2023 (edited) On 1/25/2023 at 4:10 AM, Guo Jiacheng said: How can I change the new created file permission to 755? Right now, to share between users, I have repeatedly change new synced file permission to 755. The default permission is 500 ? Yes, default is 500. Every Unraid user with his/her own UID has only access to his/her files Onedrive by default. If one Unraid user has multiple Onedrive accounts, you could use the same UID and have access to all files, but by default only the owner of the files (container) has access. To my knowledge - and my Docker knowledge is very limited - there is no easy way to change this in docker (in combination with mounted volumes). Depending on your needs, one 'solution' could be to create an Unraid user (UID) for all Onedrive accounts you want to share files between and use this account to access your files. Perhaps this might be of help. Edited January 26, 2023 by BVersluis Quote Link to comment
isaacgrant85 Posted January 30, 2023 Share Posted January 30, 2023 Looking into the docs for the app on github, there does appear to be a solution y creating a config file. I have created this file in the config directory as mapped in the docker config, but when opening the console and running "onedrive --display-config" it doesn't appear to show as seems it may have another path mapped? Is this an issue anoyone else has come across? This is actually of more benefit to me, not just for the permissions, but by also excluding some directories from sync Output: # onedrive --display-config onedrive version = v2.4.23 Config path = /root/.config/onedrive Config file found in config path = false Config option 'sync_dir' = /root/OneDrive Config option 'enable_logging' = false Config option 'log_dir' = /var/log/onedrive/ Config option 'disable_notifications' = false Config option 'min_notify_changes' = 5 Config option 'skip_dir' = Config option 'skip_dir_strict_match' = false Config option 'skip_file' = ~*|.~*|*.tmp Config option 'skip_dotfiles' = false Config option 'skip_symlinks' = false Config option 'monitor_interval' = 300 Config option 'monitor_log_frequency' = 6 Config option 'monitor_fullscan_frequency' = 12 Config option 'read_only_auth_scope' = false Config option 'dry_run' = false Config option 'upload_only' = false Config option 'download_only' = false Config option 'local_first' = false Config option 'check_nosync' = false Config option 'check_nomount' = false Config option 'resync' = false Config option 'resync_auth' = false Config option 'cleanup_local_files' = false Config option 'classify_as_big_delete' = 1000 Config option 'disable_upload_validation' = false Config option 'bypass_data_preservation' = false Config option 'no_remote_delete' = false Config option 'remove_source_files' = false Config option 'sync_dir_permissions' = 700 Config option 'sync_file_permissions' = 600 Config option 'space_reservation' = 52428800 Config option 'application_id' = Config option 'azure_ad_endpoint' = Config option 'azure_tenant_id' = common Config option 'user_agent' = Config option 'force_http_11' = false Config option 'debug_https' = false Config option 'rate_limit' = 0 Config option 'operation_timeout' = 3600 Config option 'sync_root_files' = false Selective sync 'sync_list' configured = false Config option 'sync_business_shared_folders' = false Business Shared Folders configured = false Config option 'webhook_enabled' = false Quote Link to comment
BVersluis Posted January 31, 2023 Author Share Posted January 31, 2023 7 hours ago, isaacgrant85 said: Looking into the docs for the app on github, there does appear to be a solution y creating a config file. I have created this file in the config directory as mapped in the docker config, but when opening the console and running "onedrive --display-config" it doesn't appear to show as seems it may have another path mapped? Is this an issue anoyone else has come across? This is actually of more benefit to me, not just for the permissions, but by also excluding some directories from sync Output: # onedrive --display-config onedrive version = v2.4.23 Config path = /root/.config/onedrive Config file found in config path = false Config option 'sync_dir' = /root/OneDrive Config option 'enable_logging' = false Config option 'log_dir' = /var/log/onedrive/ Config option 'disable_notifications' = false Config option 'min_notify_changes' = 5 Config option 'skip_dir' = Config option 'skip_dir_strict_match' = false Config option 'skip_file' = ~*|.~*|*.tmp Config option 'skip_dotfiles' = false Config option 'skip_symlinks' = false Config option 'monitor_interval' = 300 Config option 'monitor_log_frequency' = 6 Config option 'monitor_fullscan_frequency' = 12 Config option 'read_only_auth_scope' = false Config option 'dry_run' = false Config option 'upload_only' = false Config option 'download_only' = false Config option 'local_first' = false Config option 'check_nosync' = false Config option 'check_nomount' = false Config option 'resync' = false Config option 'resync_auth' = false Config option 'cleanup_local_files' = false Config option 'classify_as_big_delete' = 1000 Config option 'disable_upload_validation' = false Config option 'bypass_data_preservation' = false Config option 'no_remote_delete' = false Config option 'remove_source_files' = false Config option 'sync_dir_permissions' = 700 Config option 'sync_file_permissions' = 600 Config option 'space_reservation' = 52428800 Config option 'application_id' = Config option 'azure_ad_endpoint' = Config option 'azure_tenant_id' = common Config option 'user_agent' = Config option 'force_http_11' = false Config option 'debug_https' = false Config option 'rate_limit' = 0 Config option 'operation_timeout' = 3600 Config option 'sync_root_files' = false Selective sync 'sync_list' configured = false Config option 'sync_business_shared_folders' = false Business Shared Folders configured = false Config option 'webhook_enabled' = false The config path you map during setup is the (user) location were the Microsoft account details will be saved and is not the same as the root location (root/.config/onedrive) where that configuration file should be saved. I just tried using the method Abraunegg describes here and you can make this working, but I don't know if these changes are preserved during container updates. In the current situation, if you remove the container but leave the config (and data) folder, everything will work again directly if you reinstall the container and choose the same config and data location as before. This won't be the case for changes made within the container below. Even though the config file works as intended, the permission issues you mentioned before will probably not be solved for all users by changing the permissions in the config file. To add the config file to your container: 1. Start the container and open the container console 2. Go to the root directory (cd /root/) 3. In order to be able to edit to get the config file and edit the config file in the container, you have to install wget and nano by entering and approving the following commands: apt-get update apt-get install nano apt-get install -y wget 4. Use the following commands from Abrauneggs documentation to create the correct folder, download the config file and open the config file in Nano to make the necessary changes: mkdir -p ~/.config/onedrive wget https://raw.githubusercontent.com/abraunegg/onedrive/master/config -O ~/.config/onedrive/config nano ~/.config/onedrive/config 5. Make the changes you want in Nano, safe and restart the container for the changes to take effect. With the --display-config function after restart you can check if everything works. Quote Link to comment
cholzer Posted February 7, 2023 Share Posted February 7, 2023 On 1/31/2023 at 4:48 PM, BVersluis said: To add the config file to your container: 1. Start the container and open the container console 2. Go to the root directory (cd /root/) 3. In order to be able to edit to get the config file and edit the config file in the container, you have to install wget and nano by entering and approving the following commands: apt-get update apt-get install nano apt-get install -y wget 4. Use the following commands from Abrauneggs documentation to create the correct folder, download the config file and open the config file in Nano to make the necessary changes: mkdir -p ~/.config/onedrive wget https://raw.githubusercontent.com/abraunegg/onedrive/master/config -O ~/.config/onedrive/config nano ~/.config/onedrive/config 5. Make the changes you want in Nano, safe and restart the container for the changes to take effect. With the --display-config function after restart you can check if everything works. I tried that but these changes do not survive a docker restart. In fact you even have to reinstall nano again after restarting the docker. Here is how I fixed the permission issue: 1. stop the onedrive docker 2. go to the folder you selected for the "Configuration:" of the docker 3. download the original config file from here https://raw.githubusercontent.com/abraunegg/onedrive/master/config 4. remove the # ONLY infront of the settings you want to change, and change the setting accordingly (i.e. sync_dir_permissions = "777" and sync_file_permissions = "777") 5. do not touch any of the other settings you dont want to change! 6. (optional) delete the items.sqlite3, items.sqlite3-wal and all your allready synced files to start fresh 6. start the docker 7. all newly synced files will have their permissions set to drwxrwxrwx / -rwxrwxrwx Quote Link to comment
Braulio Dias Ribeiro Posted February 19, 2023 Share Posted February 19, 2023 On 1/22/2023 at 3:40 PM, PeterPan said: The great CA Maintainer BVersluis just uploaded a great working application. Just search in the shop 🙂 I tried install this app but I'm with this error. ERROR: Microsoft OneDrive API returned an error with the following message: Error Message: Timeout was reached on handle 5562906E6550 Quote Link to comment
BVersluis Posted February 20, 2023 Author Share Posted February 20, 2023 19 hours ago, Braulio said: I tried install this app but I'm with this error. ERROR: Microsoft OneDrive API returned an error with the following message: Error Message: Timeout was reached on handle 5562906E6550 Here you can read more on possible causes for timeout errors at Abraunegg's github. Quote Link to comment
cloudstrife Posted March 16, 2023 Share Posted March 16, 2023 (edited) This is awesome! Worked right away and downloading everything from my two onedrive accounts @BVersluis Edited March 17, 2023 by cloudstrife Quote Link to comment
Jabberwocky Posted January 24 Share Posted January 24 (edited) Thank you so much for this guide! Worked straight away and currently downloading everything Will need to play around a bit to see how it will behave, if i share the synced onedrive folder on the local LAN and access it from my regular pc. But i suppose that's how you have it running, too? Edited January 24 by Jabberwocky Quote Link to comment
BVersluis Posted January 24 Author Share Posted January 24 Yes, that should work. I'm actually no longer using the linux client. I was missing some other synology apps as well and since I found a guide at this forum to install DSM as a VM, I'm running DSM on my unraid server and started using the Synology cloud sync again. Quote Link to comment
Jabberwocky Posted February 8 Share Posted February 8 Shared the synced onedrive share with smb in the local network and it's working fine so far. Just wondering, is the Synology cloud sync more stable than running onedrive directly on unraid in the docker container? Or simply to have all apps in one place? One more question - is there a way to set the update interval for onedrive? Currently it will scan the onedrive folder every 300 seconds (5min) for changes. As i dont need to run constantly in the background, once per day (i.e. at midnight) would be enough in my setup. Quote Link to comment
BVersluis Posted February 8 Author Share Posted February 8 I have never had stability issues with neither cloud sync or the linux client, but cloud sync is more user friendly, easy to sync multiple accounts (and not only for onedrive). Disadvantage is that as it is running as a VM, only the VM has access to the content of the Vdisks and you need the VM to be running att all time to access the files on your network. DSM doesn't use that many resources when idle, so no problem for me. I used the 'user-scripts' plugin to run the docker container for only 1 hour each night. I don't know if these options are available within the client (synology cloud sync has). Quote Link to comment
Jabberwocky Posted February 8 Share Posted February 8 (edited) Hmm i agree, a nice user interface to sync to different services would be really nice to have. I currently don't have that many services running locally so an extra VM to run DSM just to run CloudSync feels a bit like an overhead. But good to hear, that you used the "user-scripts" plugin - starting & stopping the docker container with a script was my next idea, too As a beginner with scripting, I assume your script looked something like this? #!/bin/bash #Start Docker docker start Onedrive_User1 #Delay before issuing Stop sleep 2h #Stop Docker docker stop Onedrive_User1 Edited February 22 by Jabberwocky Quote Link to comment
Jabberwocky Posted February 10 Share Posted February 10 So after a few runs the script works nicely with a cron based schedule. I found this website helpfull when it comes to the cron schedule: https://crontab.guru/ Really nice to have the logfile right next to the script so there is no need for searching on the CLI Quote Script Starting Feb 08, 2024 16:23.29 Full logs for this script are available at /tmp/user.scripts/tmpScripts/onedrive_schedule/log.txt Onedrive_User1 Onedrive_User1 Script Finished Feb 08, 2024 17:23.32 Full logs for this script are available at /tmp/user.scripts/tmpScripts/onedrive_schedule/log.txt Script Starting Feb 09, 2024 00:00.01 Full logs for this script are available at /tmp/user.scripts/tmpScripts/onedrive_schedule/log.txt Onedrive_User1 Onedrive_User1 Script Finished Feb 09, 2024 01:00.04 Full logs for this script are available at /tmp/user.scripts/tmpScripts/onedrive_schedule/log.txt Script Starting Feb 10, 2024 00:00.01 Full logs for this script are available at /tmp/user.scripts/tmpScripts/onedrive_schedule/log.txt Onedrive_User1 Onedrive_User1 Script Finished Feb 10, 2024 01:00.08 Full logs for this script are available at /tmp/user.scripts/tmpScripts/onedrive_schedule/log.txt Another option would be to create two scripts - one for starting and one for stopping the docker container but i just leave it in one script for now. Quote Link to comment
Rkarmark Posted February 22 Share Posted February 22 Quote sync started but HI. so followed all the guide, and it is logging in and sync can be started,+ But the files of the full sync are not shown anywhere, not in download dir.... they are just downloaded to nowhere.... Any ideas? Quote Link to comment
Jabberwocky Posted April 20 Share Posted April 20 Just changed my OneDrive Password so the access token in the OneDrive installation was not accepted anymore. In the logs it showed up as: ERROR: Microsoft OneDrive API returned an error with the following message: Error Message: HTTP request returned status code 400 (Bad Request) Error Reason: AADSTS70000: The user could not be authenticated as the grant is expired. The user must sign in again. Trace ID: XXXXXXX Correlation ID: XXXXXXX Timestamp: 2024-04-20 09:07:31Z ERROR: Microsoft OneDrive API returned an error with the following message: Error Message: HTTP request returned status code 401 () Error Reason: Access token is empty. Error Timestamp: 2024-04-20T09:07:31 API Request ID: XXXXXX ERROR: Check your configuration as your refresh_token may be empty or invalid. You may need to issue a --reauth and re-authorise this client. The old token can be removed / archived like this (adjust the path to the token accordingly to match your setup) mv /mnt/user/appdata/onedrive/username/refresh_token /mnt/user/appdata/onedrive/username/refresh_token.backup Afterwards start the re-authorization at STEP 13 of the guide again Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.