目錄表

使用 rclone 同步 Google Drive 檔案

因為愈來愈多檔案存放在 Google Drive, 所以要考慮一個自動的機制將檔案同步回自己的電腦主機內.

如果需要 Docker Compose 版本可以參考 - 使用 RClone(Docker) 設定同步 Google Photo/Drive 回本地

安裝方式

Alpine 3

CentOS 7

設定 rclone 對 Google Drive / Photos Library API 的 config

使用 rclone 讀取 Google Drive 的語法

設定每天 2:00 執行一次

  • 如果要設定可以自動寄出 log 內容, 可先參考 CentOS7 設定 mailx 寄出 log 方式
  • 將 /etc/crontab 改成類似以下的語法, 將原本產生的 /tmp/syncGooglePhotos.log 內容寄給 [email protected]
    :
    0 2 * * * root rclone copy --max-age 48h --no-traverse -v JonathanGooglePhotos:/ /nas_Photos/GooglePhotos/ 2>&1 | tee /tmp/syncGooglePhotos.log ; cat /tmp/syncGooglePhotos.log | mail -s "RClone Sync Log" [email protected]
  • 如果要改用 webhook 方式進行通知(Exp. Discord, Teams…)
    1. 先安裝 bash, jq 與 curl Exp.

      apk add bash jq curl

    2. 下載 send_logs_to_discord.sh

      curl -o /usr/local/bin/send_logs_to_discord.sh https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/scripts/send_logs_to_discord.sh
      chmod a+x /usr/local/bin/send_logs_to_discord.sh

    3. 將 crontab 內容改成
      :
      0 2 * * * root rclone copy --max-age 48h --no-traverse -v JonathanGooglePhotos:/ /nas_Photos/GooglePhotos/ 2>&1 | tee /tmp/syncGooglePhotos.log && send_logs_to_discord.sh TITLE="RClone sync Google Photos..." LOG_FILE="/tmp/syncGooglePhotos.log" WEBHOOK_URL="https://discord.com/api/webhooks/13xxxxxxxxxxxxxxx28/Wxxxxxy-hkxxxxxxxxxxxxxxxxxxxxIOsyuGjyaqxxxxxxxxxxxxxxxxxxxxNJ0kYFnC"
      

更新 rclone 方式

啟用 rclone WebUI

參考網址