Previously, I wrote an article on how to use OneDrive on Linux. However, since then, there have been significant changes in the installation process, so I’ve updated the article with the latest information. The new method simplifies the setup and improves performance.
You can find the OneDrive client here:
https://github.com/abraunegg/onedrive
I’ve left the old article at the bottom for reference, so feel free to compare the old and new procedures. By understanding the differences, you may gain a deeper understanding of how to use OneDrive on Linux.
Steps to Use OneDrive on Ubuntu 24.04
Install Required Dependencies
First, install the necessary packages:
sudo apt update
sudo apt install build-essential
sudo apt install libcurl4-openssl-dev libsqlite3-dev pkg-config git curl
sudo apt install libnotify-dev # If you want to enable notification support
Install and Activate the D Language Compiler
Since the OneDrive client is written in the D programming language, you’ll need to install the DMD compiler:
curl -fsS https://dlang.org/install.sh | bash -s dmd
You will see a message similar to the following:
Downloading https://dlang.org/d-keyring.gpg
######################################################################## 100.0%
Downloading https://dlang.org/install.sh
######################################################################## 100.0%
gpg: Directory ‘/home/mamu/.gnupg’ has been created
gpg: Keybox ‘/home/mamu/.gnupg/pubring.kbx’ has been created
gpg: /home/mamu/.gnupg/trustdb.gpg: Trust database has been created
The latest version of this script was installed as ~/dlang/install.sh.
It can be used to install further D compilers.
Run ~/dlang/install.sh –help for usage information.
Downloading and unpacking https://downloads.dlang.org/releases/2.x/2.109.1/dmd.2.109.1.linux.tar.xz
######################################################################## 100.0%
Using dub 1.38.1 shipped with dmd-2.109.1
Run source ~/dlang/dmd-2.109.1/activate in your shell to use dmd-2.109.1.
This will set up PATH, LIBRARY_PATH, LD_LIBRARY_PATH, DMD, DC, and PS1.
Run deactivate later on to restore your environment.
Important Point
Pay close attention to the message that appears at the end.
Run `source ~/dlang/dmd-2.109.1/activate` in your shell to use dmd-2.109.1.
This is the command to activate the DMD compiler. However, the version number (2.109.1) may vary depending on when it was installed.
Activating the DMD Compiler
Check the installed version of DMD
Enter the following command in the terminal:
ls ~/dlang
This command will display the files and folders in the ~/dlang
directory.
Example output:
d-keyring.gpg dmd-2.109.1 install.sh
The folder starting with dmd-
indicates the installed version of DMD.
Activating DMD
To activate DMD without worrying about the version number, use a wildcard (*
):
source ~/dlang/dmd-*/activate
This will automatically select the folder starting with dmd-
in the ~/dlang
directory and activate the DMD compiler. Alternatively, if you want to activate the latest version, use the following command:
source $(ls -d ~/dlang/dmd-* | sort -V | tail -n 1)/activate
This will activate the DMD compiler.
Note: If you skip this step, you will encounter errors during the compilation process later.
Verifying the Activation
After running the command, the terminal prompt will change as follows:
(dmd-2.109.1) username@computername:~$
If the terminal prompt displays (dmd-version number)
at the beginning, the DMD compiler has been successfully activated.
Notes
- If the version number differs: DMD versions are updated regularly, so the number will change depending on the installed version. By using the wildcard
*
, you can always activate the latest version. - If multiple versions of DMD are installed: You can specify a particular version to activate if more than one version is installed.
Example:source ~/dlang/dmd-2.109.1/activate
- To deactivate: To revert the environment and deactivate the DMD compiler, run the following command:
deactivate
With these steps, you have successfully installed and activated the DMD compiler. You can now proceed to build and install the OneDrive client.
Additional Notes
- Why activation is necessary: Activating the DMD compiler sets up the system environment variables, allowing the
dmd
command to be used. Skipping this step may result in errors during the later build process. - If you encounter an error: If you receive an error like “command not found,” make sure the activation command was executed correctly.
Download and Install the OneDrive Client
git clone https://github.com/abraunegg/onedrive.git
cd onedrive
Build and Install
./configure
make clean; make
sudo make install
If you want to enable notification support:
./configure --enable-notifications
make clean; make
sudo make install
After running the make clean; make
command, the following message was displayed:
rm -f onedrive onedrive.o version
rm -rf autom4te.cache
rm -f config.log config.status
if [ -f .git/HEAD ] ; then \
git describe –tags > version ; \
else \
echo v2.5.0 > version ; \
fi
dmd -w -J. -O -L-lcurl -L-lsqlite3 -L-ldl src/main.d src/config.d src/log.d src/util.d src/qxor.d src/curlEngine.d src/onedrive.d src/webhook.d src/sync.d src/itemdb.d src/sqlite.d src/clientSideFiltering.d src/monitor.d src/arsd/cgi.d -ofonedrive
This output shows the result of the make clean
and make
commands.
Explanation of the Output
Cleanup Process
rm -f onedrive onedrive.o version
rm -rf autom4te.cache
rm -f config.log config.status
rm -f onedrive onedrive.o version
: Deletes the previously generated executable fileonedrive
, object fileonedrive.o
, and version information fileversion
from the previous build.rm -rf autom4te.cache
: Recursively deletes the auto-generated cache directoryautom4te.cache
.rm -f config.log config.status
: Deletes the configuration log fileconfig.log
and the configuration status fileconfig.status
.
Generating Version Information
if [ -f .git/HEAD ] ; then \
git describe --tags > version ; \
else \
echo v2.5.0 > version ; \
fi
- Retrieves the latest tag information from the Git repository and writes it to the
version
file. If a Git repository is not available, the default versionv2.5.0
is used.
Compilation
dmd -w -J. -O -L-lcurl -L-lsqlite3 -L-ldl src/main.d src/config.d src/log.d src/util.d \
src/qxor.d src/curlEngine.d src/onedrive.d src/webhook.d src/sync.d src/itemdb.d \
src/sqlite.d src/clientSideFiltering.d src/monitor.d src/arsd/cgi.d -ofonedrive
dmd
: The D language compiler is used to compile the source code.
Explanation of Options:
-w
: Display all warnings.-J.
: Add the current directory to the import path.-O
: Enable optimization.-L-lcurl -L-lsqlite3 -L-ldl
: Use thelibcurl
,libsqlite3
, andlibdl
libraries during linking.-ofonedrive
: Specify the output file name asonedrive
.
Source Files:
Each .d
file in the src
directory is being compiled.
After running the sudo make install
command, the following output was displayed:
/usr/bin/install -c -D onedrive /usr/local/bin/onedrive
/usr/bin/install -c -D -m 0644 onedrive.1 /usr/local/share/man/man1/onedrive.1
/usr/bin/install -c -D -m 0644 contrib/logrotate/onedrive.logrotate /usr/local/etc/logrotate.d/onedrive
mkdir -p /usr/local/share/doc/onedrive
/usr/bin/install -c -D -m 0644 readme.md config LICENSE changelog.md docs/advanced-usage.md docs/application-config-options.md docs/application-security.md docs/business-shared-items.md docs/client-architecture.md docs/contributing.md docs/docker.md docs/install.md docs/national-cloud-deployments.md docs/podman.md docs/privacy-policy.md docs/sharepoint-libraries.md docs/terms-of-service.md docs/ubuntu-package-install.md docs/usage.md docs/known-issues.md docs/webhooks.md /usr/local/share/doc/onedrive
/usr/bin/install -c -d -m 0755 /usr/lib/systemd/user /usr/lib/systemd/system
/usr/bin/install -c -m 0644 contrib/systemd/onedrive@.service /usr/lib/systemd/system
/usr/bin/install -c -m 0644 contrib/systemd/onedrive.service /usr/lib/systemd/user
This output shows the process of installing the OneDrive client on the system using the sudo make install
command.
Explanation of the Output
Installing the Executable File
/usr/bin/install -c -D onedrive /usr/local/bin/onedrive
The onedrive
executable is being installed to /usr/local/bin/onedrive
.
Installing the Manual Page
/usr/bin/install -c -D -m 0644 onedrive.1 /usr/local/share/man/man1/onedrive.1
The manual page onedrive.1
is being installed to /usr/local/share/man/man1/
.
Installing the Log Rotation Configuration
/usr/bin/install -c -D -m 0644 contrib/logrotate/onedrive.logrotate /usr/local/etc/logrotate.d/onedrive
The logrotate configuration file is being installed to /usr/local/etc/logrotate.d/
.
Creating the Documentation Directory
mkdir -p /usr/local/share/doc/onedrive
A directory for documentation is being created.
Installing Documentation Files
/usr/bin/install -c -D -m 0644 readme.md config LICENSE changelog.md docs/advanced-usage.md docs/application-config-options.md docs/application-security.md docs/business-shared-items.md docs/client-architecture.md docs/contributing.md docs/docker.md docs/install.md docs/national-cloud-deployments.md docs/podman.md docs/privacy-policy.md docs/sharepoint-libraries.md docs/terms-of-service.md docs/ubuntu-package-install.md docs/usage.md docs/known-issues.md docs/webhooks.md /usr/local/share/doc/onedrive
Various documentation files are being installed to /usr/local/share/doc/onedrive
.
Creating the systemd Service File Directory
/usr/bin/install -c -d -m 0755 /usr/lib/systemd/user /usr/lib/systemd/system
Directories for the systemd
user and system unit files are being created.
Installing the systemd Service Files
/usr/bin/install -c -m 0644 contrib/systemd/onedrive@.service /usr/lib/systemd/system
/usr/bin/install -c -m 0644 contrib/systemd/onedrive.service /usr/lib/systemd/user
The onedrive
systemd service files are being installed in the appropriate directories.
Deactivating the DMD Compiler
Once the build is complete, deactivate the DMD compiler:
deactivate
Alternatively, you can restart the terminal.
Setting up OneDrive
Run the onedrive
command:
onedrive
A URL will be displayed in the terminal. Open this URL in a browser and log in with your Microsoft account. After logging in, copy the URL displayed in the browser’s address bar and paste it into the terminal.
After running the onedrive
command, the following output will be displayed:
Using IPv4 and IPv6 (if configured) for all network operations
Attempting to contact Microsoft OneDrive Login Service
Successfully reached Microsoft OneDrive Login Service
Configuring Global Azure AD Endpoints
Authorize this application by visiting:
Note: The client_id
in the URL above is partially masked with *
. When publishing articles, please be careful not to include any personal or sensitive information related to security.
This message is displayed when running the OneDrive client for the first time, indicating that authentication with your Microsoft account is required.
Authentication Procedure
- Open the URL displayed in the terminal:
Copy the URL displayed in the terminal and open it in a web browser. - Log in with your Microsoft account:
In the browser, enter the email address and password of the Microsoft account you want to sync with OneDrive. - Grant access to the app:
The application will request permission to access your OneDrive data. Click “Allow” or “Consent” to grant access. - Copy the redirected URL:
After authentication, the browser will redirect to a URL such ashttps://login.microsoftonline.com/common/oauth2/nativeclient?code=...
. The page may display a blank screen or an error, but copy the entire URL from the address bar. - Paste into the terminal:
Return to the terminal and ensure the following prompt is displayed:Enter the response uri:
Paste the URL you copied earlier and press Enter. - Complete authentication:
If authentication is successful, the following message will be displayed:Authorization successful.
Initialization complete.
The setup of the OneDrive client is now complete, and it is ready to sync.
Note: After completing the browser-based authentication and pasting the redirected URL into the terminal, the following output will be displayed:
Enter the response uri from your browser: https://login.microsoftonline.com/common/oauth2/nativeclient?code=**********
The application has been successfully authorised, but no extra command options have been specified.
Please use ‘onedrive –help’ for further assistance in regards to running this application.
Explanation
The message indicates that the authentication was successful:
The application has been successfully authorised
However, since no additional command options were specified, no specific action was performed:
but no extra command options have been specified.
You are prompted to use the onedrive --help
command to check available options:
Please use 'onedrive --help' for further assistance in regards to running this application.
How to Check the Configuration
To verify the settings that the OneDrive client is using, run the following command:
onedrive --display-config
This command displays the current configuration options and how they are interpreted at runtime. In my case, the following output was displayed:
Application version = onedrive v2.5.0-8-g88e2493
Compiled with = DMD 2109
User Application Config path = /home/mamu/.config/onedrive
System Application Config path = /etc/onedrive
Applicable Application ‘config’ location = /home/mamu/.config/onedrive/config
Configuration file found in config location = false – using application defaults
Applicable ‘sync_list’ location = /home/mamu/.config/onedrive/sync_list
Applicable ‘items.sqlite3’ location = /home/mamu/.config/onedrive/items.sqlite3
Config option ‘drive_id’ =
Config option ‘sync_dir’ = ~/OneDrive
Config option ‘enable_logging’ = false
Config option ‘log_dir’ = /var/log/onedrive
Config option ‘disable_notifications’ = false
Config option ‘skip_dir’ =
Config option ‘skip_dir_strict_match’ = false
Config option ‘skip_file’ = ~*|.~*|*.tmp|*.swp|*.partial
Config option ‘skip_dotfiles’ = false
Config option ‘skip_symlinks’ = false
Config option ‘monitor_interval’ = 300
Config option ‘monitor_log_frequency’ = 12
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 ‘disable_download_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’ = d50ca740-c83f-4d1b-b616-12c519384f0c
Config option ‘azure_ad_endpoint’ =
Config option ‘azure_tenant_id’ =
Config option ‘user_agent’ = ISV|abraunegg|OneDrive Client for Linux/v2.5.0-8-g88e2493
Config option ‘force_http_11’ = false
Config option ‘debug_https’ = false
Config option ‘rate_limit’ = 0
Config option ‘operation_timeout’ = 3600
Config option ‘dns_timeout’ = 60
Config option ‘connect_timeout’ = 10
Config option ‘data_timeout’ = 60
Config option ‘ip_protocol_version’ = 0
Config option ‘threads’ = 8
Compile time option –enable-notifications = false
Selective sync ‘sync_list’ configured = false
Config option ‘sync_business_shared_items’ = false
Config option ‘webhook_enabled’ = false
Points
- sync_dir: The location of the directory where files are synced locally. By default, it is set to
~/OneDrive
. - Config path: The location where the configuration file is stored.
Note
If you are using multiple OneDrive accounts, you need to specify the configuration directory using the --confdir
option.
OneDrive Client Operation Modes
The OneDrive client has two operation modes:
- Standalone Sync Mode (single synchronization):
onedrive --synchronize
Or shortened:onedrive -s
- Monitor Mode (real-time sync):
onedrive --monitor
Or shortened:onedrive -m
Tip
- Use Standalone Sync Mode if you want to sync files only once.
- Use Monitor Mode if you want to sync file changes in real-time.
Client-Side Filtering Settings
By default, all data from your OneDrive account is synced locally. However, if you want to sync only specific folders or files, you need to configure filtering.
Method 1: Using the sync_list
file
- Navigate to the configuration directory:
cd ~/.config/onedrive
- Create a
sync_list
file and specify the paths to the folders or files you want to sync:nano sync_list
Example: To sync only theDocuments
andPictures/Vacation
folders:Documents
Pictures/Vacation
- Save and exit the file.
Method 2: Using command-line options
- Exclude specific directories from sync:
onedrive --synchronize --exclude-dir 'directory_name'
- Exclude dotfiles from sync:
onedrive --synchronize --skip-dotfiles
- Exclude specific file types:
onedrive --synchronize --skip-file 'pattern'
Example: To exclude.tmp
files:onedrive --synchronize --skip-file '*.tmp'
Troubleshooting
Common Errors in Monitor Mode
- Initialization FailureCause:
The system has reached the limit of inotify watches.Solution: Increase the value offs.inotify.max_user_watches
. Check the current value:sysctl fs.inotify.max_user_watches
To increase the value:sudo sysctl fs.inotify.max_user_watches=1048576
- Unable to Add New inotify Watch
Cause and Solution: Same as above.
Making the Changes Permanent
Add the following line to the /etc/sysctl.conf
file:
fs.inotify.max_user_watches=1048576
Testing the Configuration
When testing the OneDrive client configuration, it is safer to use the --dry-run
option. This option simulates the sync operation without actually downloading, uploading, or deleting any files.
Example:
onedrive --synchronize --verbose --dry-run
Point:
- By using the
--dry-run
option, you can verify the sync behavior without affecting any actual files. - Combining it with the
--verbose
option will display detailed log information.
Running Sync with Microsoft OneDrive
By default, all files will be downloaded to the ~/OneDrive
directory. You can change this download location using the sync_dir
option in the configuration file.
Basic Sync Command:
onedrive --synchronize
Or shortened:
onedrive -s
This will sync the files from your OneDrive account to your local ~/OneDrive
directory or the location specified in sync_dir
.
Tip:
If you want to treat your local files as the “trusted source,” use the following command:
onedrive --synchronize --local-first
Syncing Specific Directories Only
In some cases, you may want to sync only a specific directory within ~/OneDrive
without changing the configuration. You can use the --single-directory
option for this.
Example:
onedrive --synchronize --single-directory 'directory_name'
Specific example:
To sync only the ~/OneDrive/linux
directory:
onedrive --synchronize --single-directory 'linux'
Performing “One-Way” Download Sync
If you want to perform a “download-only” sync from OneDrive to your local machine, use the --download-only
option.
Command:
onedrive --synchronize --download-only
Important Notes:
- All content from OneDrive will be downloaded locally.
- Files deleted online will remain locally; they will not be automatically deleted.
Important:
In version v2.5.x and later, when using the --download-only
option, files deleted online will remain on the local machine.
If you want to delete files locally that were deleted online, use the following command:
Clean up files deleted online:
onedrive --synchronize --download-only --cleanup-local-files
Performing “One-Way” Upload Sync
If you want to perform an “upload-only” sync from your local machine to OneDrive, use the --upload-only
option.
Command:
onedrive --synchronize --upload-only
Important Notes:
- In “upload-only” mode, the existing content on OneDrive is not checked or synced.
- Files and folders deleted locally will also be deleted from OneDrive.
To prevent deleting data on OneDrive:
To ensure files deleted locally are not removed from OneDrive, add the --no-remote-delete
option.
Command:
onedrive --synchronize --upload-only --no-remote-delete
Points:
--upload-only
: Uploads local changes (additions, modifications, moves, deletions) to OneDrive.--no-remote-delete
: Even if files are deleted locally, they will not be removed from OneDrive. This creates a one-way archive on OneDrive where files are only added and not deleted.
Important Notes for Beginners
When using critical options, always test first with the --dry-run
option.
Using the wrong options can result in unintended data deletion.
Make sure you fully understand the configuration file and command options before proceeding.
Performing Selective Sync Using the sync_list
File
With the OneDrive client, you can perform “selective sync” using a sync_list
file to sync only specific files and directories. This allows you to sync only the data you need while preventing unnecessary data from being synced.
Creating the sync_list
File
- Navigate to the configuration directory:
cd ~/.config/onedrive
- Create the
sync_list
file:nano sync_list
- Write the files or directories you want to sync:
For each line, write the relative path fromsync_dir
(by default,~/OneDrive
).
Example:# Comment: Sync the Documents folder
Documents/
# Comment: Sync the Pictures/Vacation folder
Pictures/Vacation/
# Comment: Sync a specific file
Notes/meeting_minutes.docx
- Save the file and exit:
PressCtrl + O
to save, thenCtrl + X
to exit the editor.
Important Notes About sync_list
- Default Exclusion Setting:
When usingsync_list
, any files or directories not listed in the file will be excluded from sync. - Path Specification:
The paths should be relative tosync_dir
.Add a/
at the end of the folder name to specify that it is a directory. - Using Wildcards:
You can use*
to match any string.
Example:# Sync all `.pdf` files
Documents/*.pdf
- Exclusion Rules:
Add!
or-
at the beginning of a line to exclude matching items.
Example:# Exclude the Temp folder
!Documents/Temp/
Important After Using sync_list
After creating or modifying a sync_list
, you need to perform a full resync with the following command:
onedrive --synchronize --resync
Warning:
Using the --resync
option will reset the local sync state. In some cases, this may result in local data being overwritten.
Make sure to back up your local data before proceeding.
Using the --resync
Option
The --resync
option is used to rebuild the sync state. It is necessary in the following cases:
- When configuration changes are made:
Such as changes tosync_dir
,skip_file
,skip_dir
,skip_dotfiles
, etc. - When the
sync_list
file is created, modified, or deleted. - When the sync state is unclear.
How to Run --resync
onedrive --synchronize --resync
Warning During Execution:
Using –resync will delete your local ‘onedrive’ client state, so there won’t be a record of your current ‘sync status.’
This may potentially overwrite local versions of files with older versions downloaded from OneDrive, leading to local data loss.
If in doubt, back up your local data before using –resync.
Are you sure you want to proceed with –resync? [Y/N]
To proceed, enter Y
.
Note:
Use --resync
with caution.
When used in automated environments, adding the --resync-auth
option will automatically approve the confirmation prompt, but it increases the risk of data loss, so it is not recommended.
Using the --force-sync
Option
If you want to temporarily sync only specific files or directories, you can use the --force-sync
option to ignore the skip_file
and skip_dir
settings without changing the configuration.
How to Use:
onedrive --synchronize --single-directory 'directory_name' --force-sync
Example:
onedrive --synchronize --single-directory 'Projects/Important' --force-sync
Warning During Execution:
WARNING: Overriding application configuration to use application defaults for skip_dir and skip_file due to –sync –single-directory –force-sync being used
Using –force-sync will reconfigure the application to use defaults. This may have unknown future impacts.
By proceeding with this option, you accept any impacts, including potential data loss resulting from using –force-sync.
Are you sure you want to proceed with –force-sync? [Y/N]
To proceed, enter Y
.
Note:
When using --force-sync
, some settings will be ignored, which may lead to unexpected behavior or the risk of data loss.
Use it cautiously and only when necessary.
Summary of Key Points
Using sync_list
:
- Effective for syncing only the necessary files and folders.
- Always run
--resync
after creating or modifying thesync_list
.
Using --resync
:
- Used to reset and rebuild the sync state.
- There is a risk of data loss, so back up your data and use it with caution.
Using --force-sync
:
- Temporarily bypasses settings for specific sync operations.
- There is a risk of unexpected behavior, so only use it when needed.
Advice for Beginners
The Importance of Backups:
Always back up your data before making significant changes or using critical options.
Using the --dry-run
Option:
This option allows you to verify the operation without performing actual file actions.
Example Command:
onedrive --synchronize --dry-run --verbose
Refer to the Official Documentation:
For any questions or detailed information, refer to the official documentation or use the help command:
onedrive --help
How to Handle Password Changes for Microsoft OneDrive Accounts
Sync Errors Due to Password Changes
When you change the password for your Microsoft OneDrive account, the OneDrive client’s authentication credentials become invalid, preventing it from syncing. The next time you run the client, you may see the following error message:
ERROR: AADSTS50173: The provided grant has expired due to it being revoked, a fresh auth token is needed. The user might have changed or reset their password. The grant was issued on ‘
ERROR: You will need to issue a –reauth and re-authorise this client to obtain a fresh auth token.
Explanation:
The AADSTS50173 error code indicates that the authentication token has been invalidated.
This is caused by the existing authentication credentials becoming invalid due to a password change or reset.
Steps for Reauthentication
To reauthenticate the client after a password change, follow these steps:
Stop the OneDrive Client
- If running as a system service:
systemctl --user stop onedrive
orsystemctl stop onedrive
(Use the appropriate command depending on your service.) - If running manually:Simply close the client.
Run the Reauthentication Command
In the terminal, run the following command:
onedrive --reauth
Note:
If you are using multiple accounts or a specific configuration directory, add the --confdir
option:
onedrive --confdir="~/.config/onedrive-personal" --reauth
Reauthenticate via Browser
After running the command, a URL will appear in the terminal for authentication.
Open this URL in your browser and log in to your Microsoft account.
Grant the app access permissions.
Copy the redirected URL from the browser and paste it into the terminal.
Restart the Client
- If running as a system service:
systemctl --user start onedrive
orsystemctl start onedrive
- If running manually:
onedrive --synchronize
Verify Sync
Ensure that the client resumes syncing properly.
Determining Sync Results and Handling Errors
Successful Sync
If the sync completes without errors, the following message will be displayed:
Sync with OneDrive is complete
When Sync Errors Occur
If an error occurs during the sync process, the following message will be displayed:
Sync with OneDrive has completed, however there were some errors.
Handling Sync Errors
When a sync error occurs, the following message will be displayed:
You can check the details of the error to identify the cause.
How to Handle Errors
Check the Logs
Review the client’s output or log files to determine which files or directories caused the error.
Common Causes and Solutions
- Network Error:Check your internet connection and try syncing again.
- File Name Issues:If the issue is caused by special characters or long file names, rename the file.
- Permission Issues:Check and correct the permissions for the affected files or directories.
Retry Syncing
onedrive --synchronize
Perform Reauthentication or Resync if Needed
- For authentication errors: Follow the reauthentication steps above.
- To reset the sync state:
onedrive --synchronize --resync
Note:
Using --resync
will reset the local sync database. Be sure to back up your data beforehand.
Password Expiration and Regular Checks
If your organization enforces password expiration policies, you’ll need to change your password regularly. Sync errors may occur when the password changes, so keep the following points in mind:
- After changing your password, reauthentication will be required for the client.
- If an error occurs, promptly follow the reauthentication steps to resume syncing.
Comparison Between the Linux OneDrive Client and Rclone
Linux OneDrive Client
- Official Name: onedrive (or onedrive-d)
- Developer: Community-led open-source project
- Key Features:
- Bidirectional sync with Microsoft OneDrive
- Supports symbolic links
- Real-time monitoring of file changes (Monitor mode)
- Selective sync and filtering options
Advantages:
- Native OneDrive Support:
- Optimized specifically for Microsoft OneDrive, allowing full use of its features.
- Real-Time Sync:
- Automatically syncs files as changes are detected.
- Detailed Configuration:
- Allows fine-tuned control over sync targets using the sync_list file and various options.
Disadvantages:
- Limited to One Cloud Service:
- Only works with OneDrive; does not support other cloud storage services.
- Complex Setup:
- While offering advanced configuration options, it may be challenging for beginners.
- Maintenance Frequency:
- Being an open-source project, updates can be sporadic depending on development progress.
Rclone
- Developer: Nick Craig-Wood (Open-source project)
- Key Features:
- Integration with over 30 cloud services (OneDrive, Google Drive, Dropbox, etc.)
- Command-line-based file transfer and sync tool
- Advanced features like encryption, caching, and virtual file system (VFS)
Advantages:
- Multi-Cloud Support:
- Manage multiple cloud services with a single tool.
- Rich Functionality:
- Supports sync, copy, move, delete, and mount operations.
- Automation-Friendly:
- As a command-line tool, it integrates well with scripts and automation.
Disadvantages:
- Real-Time Sync Complexity:
- Achieving real-time bidirectional sync requires additional tools like Cron.
- Complex Setup:
- Due to its many features, mastering the setup and usage requires a learning curve.
- Incremental Change Detection Limitations:
- Some cloud services may have limitations on detecting changes, affecting sync efficiency.
Comparison and Considerations
Choosing Based on Use Case:
- If you only use OneDrive and prioritize real-time sync:The Linux OneDrive client is ideal, as it’s optimized for OneDrive and supports real-time syncing with Monitor mode.
- If you need to manage multiple cloud services:Rclone is a powerful choice. It simplifies management by integrating various services into one tool.
Setup and Usability:
- For simpler setup:The Linux OneDrive client is more focused, with fewer configuration options tailored specifically to OneDrive.
- For flexibility and advanced features:Rclone offers extensive customization options and features to meet various needs.
Performance and Reliability:
- For high-performance, real-time sync:The Linux OneDrive client is optimized for efficient synchronization with OneDrive.
- For handling large datasets or complex sync requirements:Rclone provides advanced features such as parallel transfers, bandwidth throttling, and encryption, making it suitable for large-scale operations.
Conclusion
The Linux OneDrive client is a simple and effective tool for users who want to use OneDrive on Linux. It offers real-time sync, selective sync, and OneDrive-specific features.
Rclone is best suited for users who need to manage multiple cloud services or require advanced features. It is highly customizable and can meet diverse needs.
In my opinion:
- For OneDrive users on Linux: The Linux OneDrive client is the better choice for real-time sync and OneDrive-specific features.
- For managing multiple cloud services or automating tasks: Rclone is the ideal tool for its flexibility and extensive feature set.
We will set up OneDrive on Ubuntu 20.04. All you need to do is copy and paste the commands from the GitHub page. First, we will install the necessary dependencies.
https://github.com/abraunegg/onedrive
sudo apt install build-essential
sudo apt install libcurl4-openssl-dev
sudo apt install libsqlite3-dev
sudo apt install pkg-config
sudo apt install git
sudo apt install curl
curl -fsS https://dlang.org/install.sh | bash -s dmd
mamushi@mamushipc:~$ curl -fsS https://dlang.org/install.sh | bash -s dmd
Downloading https://dlang.org/d-keyring.gpg
################################################################## 100.0%
Downloading https://dlang.org/install.sh
################################################################## 100.0%
The latest version of this script was installed as ~/dlang/install.sh.
It can be used it to install further D compilers.
Run ~/dlang/install.sh --help
for usage information.
Downloading and unpacking http://downloads.dlang.org/releases/2.x/2.098.1/dmd.2.098.1.linux.tar.xz
################################################################## 100.0%
Using dub 1.27.0 shipped with dmd-2.098.1
Run source ~/dlang/dmd-2.098.1/activate
in your shell to use dmd-2.098.1.
This will setup PATH, LIBRARY_PATH, LD_LIBRARY_PATH, DMD, DC, and PS1.
Run deactivate
later on to restore your environment.
Here is the output that was displayed when using the Curl command. In this case, copy and paste the following into the terminal. This seems to activate the D programming language. Once you do this, “dmd” will appear in front of your username in the terminal.
source ~/dlang/dmd-2.098.1/activate
Next, we will retrieve the files from Git, configure, and install them.
git clone https://github.com/abraunegg/onedrive.git
cd onedrive
./configure
make clean; make;
sudo make install
After this step is complete, deactivate the D programming language or restart the terminal. When you type “onedrive”, a URL will be displayed, prompting you to enter a response URL. At this point, access the URL shown in the browser.
After entering your OneDrive username and password, a blank page will be displayed. The URL of this blank page is the response URL, so copy and paste it into the terminal to complete the process.
Now, let’s try syncing with the Linux version of OneDrive. First, verify the configuration.
onedrive --display-config
To sync everything, enter the synchronization command, but if you add --dry-run
at the end, you can perform a test run. The files that would be downloaded, uploaded, or deleted will be displayed, but since this is a test, no actual changes will occur.
onedrive --synchronize --verbose --dry-run
I didn’t need to sync everything, so I decided to sync only a specific folder under OneDrive.
onedrive --synchronize --single-directory '<dir_name>'
mamushi@mamushipc:~$ onedrive –synchronize –single-directory ‘linux’
Configuring Global Azure AD Endpoints
Initializing the Synchronization Engine …
WARNING: The requested path for –single-directory does not exist locally. Creating requested path within /home/mamushi/OneDrive
Syncing changes from selected OneDrive path …
Downloading file linux/test.ods … done.
Downloading file linux/kehai.xlsx … done.
Uploading differences of linux
Uploading new items of linux
It seems there is also an option for one-way synchronization.