0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Raspberry Pi(raspbian) と Onedrive ファイル同期 20250803

Last updated at Posted at 2025-08-03

OneDrive Client構築 20250803

前提条件

ラズパイ構築(64bitOS)が完了していることが前提

rsapberrypi 5 GNU/Linux 12 でのOneDrive Client導入

仕様

OneDrive Clientの動作仕様としては「変更」をダウンロード/アップロードします。
ファイルをダウンロード/アップロードするだけで、反映先を変更/削除しないという使い方はできません。
簡単に言うと、Download_only設定にしても、OneDrive側でフォルダ削除(状態変更操作)をすれば、ローカル側のフォルダが自動削除(変更の反映)されます。
バックアップ用途のような一方に蓄積するだけの利用の場合、同期後にBackup用の別フォルダにコピーした後、OneDriveから削除する、という運用になります。

参考資料

image.png

上記リンクの最下層にある、OneDrive for Linux インストール/ビルド手順リンクが以下

raspbian の手順はDebian Package インストール手順参照
image.png

以下リンクがインストール手順

コマンド

sudo apt remove onedrive
sudo add-apt-repository --remove ppa:yann1ck/onedrive
sudo rm /etc/systemd/user/default.target.wants/onedrive.service
sudo rm -rf /var/lib/dpkg/lock-frontend
sudo rm -rf /var/lib/dpkg/lock

以下は公式手順では update-os.shというスクリプトでまとめて実行しているが、インストールだけしたいなら、以下5個を手動実行で問題なし

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get autoremove -y
sudo apt-get autoclean -y

image.png

step 4 で各OSの各Verごとに手順が変わるため、確認。
私はraspbian のGNU/Linux 12 なので、以降はその前提で記載。

pi@raspberrypi:~ $  cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
pi@raspberrypi:~ $

image.png

raspbian のGNU/Linux 12 手順。
基本公式リンクを参照すること。

image.png

wget -qO - https://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/Debian_12/Release.key | gpg --dearmor | sudo tee /usr/share/keyrings/obs-onedrive.gpg > /dev/null

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/obs-onedrive.gpg] https://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/Debian_12/ ./" | sudo tee /etc/apt/sources.list.d/onedrive.list

sudo apt-get update

sudo apt install --no-install-recommends --no-install-suggests onedrive

これでOneDriveはインストール完了。
onedrive 設定確認コマンドでonedrive client動作確認

onedrive --display-config

image.png

インストール後の手順は以下を参照

同期前に設定(config)

※私の用途としてはダウンロードのみでアップロードはしないので、「download_only」を設定

ややこしいのですが、configファイルのテンプレが「/home/pi/onedrive/config」なのですが、上記の「onedrive --display-config」で表示された「Config path = /home/pi/.config/onedrive」が読み込まれるconfigエリアです。
デフォルトでは「/home/pi/.config/onedrive」にconfigもsync_listも存在しません。「/home/pi/onedrive/config」ファイルを「/home/pi/.config/onedrive」にコピーして、編集します。
sync_listは元より無いので、新規作成です。

cp -p ~/onedrive/config /home/<user>/.config/onedrive/
ls -l /home/<user>/.config/onedrive/config
vi /home/<user>/.config/onedrive/config
###以下2行を設定
sync_dir = "<ローカルの同期元先>"
download_only = "true"
touch /home/<user>/.config/onedrive/sync_list
vi /home/<user>/.config/onedrive/sync_list
### ラズパイと同期したいOneDriveのフォルダやファイル名を指定する。
### 例~~~~~~~~
### test
### test2/test.xlsx
### ~~~~~~~~

この設定だとOneDrive直下のtestフォルダ配下のすべてと
test2フォルダのtest.xlsxがダウンロードされる。
image.png

自動起動の設定

systemctl --user enable onedrive
systemctl --user start onedrive

pi@raspberrypi:~ $ systemctl --user enable onedrive
Created symlink /home/pi/.config/systemd/user/default.target.wants/onedrive.service → /usr/lib/systemd/user/onedrive.service.
pi@raspberrypi:~ $ systemctl --user start onedrive
pi@raspberrypi:~ $

初回起動時のログイン

onedriveコマンドを実行すれば、初回実行時にOneDriveへのログイン確認が実施される。
ちなみにこれはRaspbianOSのGUI画面でなくとも、TeratemベースのCUI画面でURLが表示された後、Teraterm接続元のWindowsOSからURLに接続し、OneDriveへのアクセスを許可してもラズパイとの連携は正常に動作する。

手動同期

onedrive --sync

※onedriveコマンドのオプションなどは以下を参照

最後に以下を叩き、configとsync_list設定を読み込ませ常時サービス起動することで領域を監視して自動同期させる。
systemctl --user restart onedrive

この後に、同期設定したOnedrive側にファイルを置き、ローカルに自動で同期されるか確認。

エラーについては一部同じ動作になるものもあるかも。参考。

補足(Network Connection Issue)

config修正

WARNING: Configured 'threads = 8' exceeds available CPU cores (4). Capping to 'threads' to 4.
WARNING: D-Bus message bus daemon is not available; GUI notifications are disabled

pi@raspberrypi:~ $ onedrive --sync
Reading configuration file: /home/pi/.config/onedrive/config
Configuration file successfully loaded
WARNING: Configured 'threads = 8' exceeds available CPU cores (4). Capping to 'threads' to 4.
WARNING: D-Bus message bus daemon is not available; GUI notifications are disabled

WARNING: Your cURL/libcurl version (7.88.1) has known HTTP/2 bugs that impact the use of this client.
         Please report this to your distribution, requesting an update to a newer cURL version, or consider upgrading it yourself for optimal stability.
         Downgrading all client operations to use HTTP/1.1 to ensure maximum operational stability.
         Please read https://github.com/abraunegg/onedrive/blob/master/docs/usage.md#compatibility-with-curl for more information.

Application configuration file has been updated, checking if --resync needed
WARNING: no backup config file was found, unable to validate if any changes made

An application configuration change has been detected where a --resync is required

pi@raspberrypi:~ $

threads = "4"を明示的に設定。
GUI通知の無効設定を有効化
HTTP/1.1 を明示的に使用
ip_protocol_version = "1"

sudo vi /home/pi/.config/onedrive/config


## Number of threads to use for upload/download.
#threads = "8"
threads = "4"

## This setting controls whether GUI notifications are sent from the client to your display manager session.
#disable_notifications = "false"
disable_notifications = "true"

## This setting controls the application HTTP protocol version, downgrading to HTTP/1.1 when enabled.
#force_http_11 = "false"
force_http_11 = "true"

## This setting controls the application IP protocol used when communicating with Microsoft OneDrive.
#ip_protocol_version = "0"
ip_protocol_version = "1"

警告修正

pi@raspberrypi:~ $ onedrive --sync
Reading configuration file: /home/pi/.config/onedrive/config
Configuration file successfully loaded
WARNING: Configured 'threads = 8' exceeds available CPU cores (4). Capping to 'threads' to 4.
WARNING: D-Bus message bus daemon is not available; GUI notifications are disabled

WARNING: Your cURL/libcurl version (7.88.1) has known HTTP/2 bugs that impact the use of this client.
         Please report this to your distribution, requesting an update to a newer cURL version, or consider upgrading it yourself for optimal stability.
         Downgrading all client operations to use HTTP/1.1 to ensure maximum operational stability.
         Please read https://github.com/abraunegg/onedrive/blob/master/docs/usage.md#compatibility-with-curl for more information.

Application configuration file has been updated, checking if --resync needed
WARNING: no backup config file was found, unable to validate if any changes made

An application configuration change has been detected where a --resync is required

pi@raspberrypi:~ $

「Application configuration file has been updated, checking if --resync needed
WARNING: no backup config file was found, unable to validate if any changes made」

理由は不明だが「/home/pi/.config/onedrive/.config.backup」を利用しようとしているが、無いとのこと。
空ファイルを作成したら、警告が消えた。
touch /home/pi/.config/onedrive/.config.backup

pi@raspberrypi:~/onedrive $onedrive -s -v -v
DEBUG: Application started
DEBUG: Process ID: 7FFF20186E48
DEBUG: User UID:   1000
~
DEBUG: Configuring default new folder permissions as: 700
DEBUG: Configuring default new file permissions as: 600
DEBUG: sync_list file has been updated, --resync needed
DEBUG: Application configuration file has been updated, checking if --resync needed
DEBUG: Using this configBackupFile: /home/pi/.config/onedrive/.config.backup
DEBUG: WARNING: no backup config file was found, unable to validate if any changes made
~

調査中

WARNING: Your cURL/libcurl version (7.88.1) has known operational bugs that impact the use of this client.
Please report this to your distribution, requesting an update to a newer cURL version, or consider upgrading it yourself for optimal stability.
 

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?