====== 使用 RClone(Docker) 設定同步 Google Photo/Drive 回本地 ====== ===== 安裝程序 ===== - 下載 docker-compose.yml 相關檔案 wget https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/rclone/docker-compose.yml wget https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/rclone/.env.example wget https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/rclone/root_crontab mv .env.example .env {{repo>https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/rclone/docker-compose.yml|docker-compose.yml}} - 請在 volumes 加上要備份到本地端的目錄 Exp. /nas_Photos:/nas_Photos - 在 rclone-webui 與 rclone-cron 兩個服務容器都要加 - 編輯 .env 檔案{{repo>https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/rclone/.env.example|.env}} - 請修改 Web 登入的帳號(RCLONE_RC_USER)與密碼(RCLONE_RC_PASS) - 請修改 Discord 通知時的 Title - 請修改 Discord 通知的 WebHook URL (請到 Discord 的通知頻道產生) - 啟動 docker compose docker compose pull docker compose up -d - 登入 Web UI Exp. http://192.168.11.243:5572/ - 成功登入後畫面 \\ {{:tech:螢幕擷取畫面_2025-04-21_191803.png?800|}} - 到 config 進行新增 Google Photo / Drive 的設定 \\ {{:tech:螢幕擷取畫面_2025-04-21_192008.png?800|}} \\ {{:tech:螢幕擷取畫面_2025-04-21_192049.png?800|}} - 儲存後應該就可以看到類似以下的 config 清單 \\ {{:tech:螢幕擷取畫面_2025-04-21_192146.png?800|}} - 也可以到主機端看產生的 rclone.conf # cat rclone-config/rclone.conf [EverplastGoogle] type = drive client_id = 5100000070-hrhklfhjdfhsd1rfhs1.apps.googleusercontent.com client_secret = rTYxxxxxxxxxxxxxxxxxxxxd scope = drive.readonly token = {"access_token":"ya29.a0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxUeD449TBTsJIv9htJ6Q0178","token_type":"Bearer","refresh_token":"1//0eUHhK-CxxxxxxxxxxxxxxxxSNwF-W5CU","expiry":"2025-04-21T19:39:59.759797588+08:00"} root_folder_id = 0BxxxxxxxxxY-aFxxxxxxxxxxeVk [JonathanGooglePhotos] type = google photos client_id = 51xxxxxx70-hrxxxxxxxxxxxx1rfhs1.apps.googleusercontent.com client_secret = rTYxxxxxxxxxxxxxxxxxxxxxd read_only = true token = {"access_token":"ya29.a0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxQV-sS3xxxxxxxxxxxxxt3qsUjQwfitN7YMjLnBPw0178","token_type":"Bearer","refresh_token":"1//0efrxxxxxxxxL9IrJY0_EQNxxxxxxxxxxxxxxxxxxx3nd_2aTElCiZNxxxxxxmyxAfY","expiry":"2025-04-21T19:13:59.96375334+08:00"} [NAS145WorkDir] type = ftp host = 192.168.11.145 pass = flxxxxxx6-QDxxxxxxxxxx5tp_nTxxxxxg user = jonathan # - 編輯 root_crontab 檔案{{repo>https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/rclone/root_crontab|root_crontab}} - 預設每分鐘會跑測試通知一次, 確認 cron-job 是否正確運作, 如果沒問題就可以將這測試項目加上 # 關閉 : #* * * * * date >> /var/log/cron/test.log 2>&1 && send_logs_to_discord.sh TITLE="RClone Cron Test..." LOG_FILE="/var/log/cron/test.log" : - 加上實際需要執行 rclone 的項目 Exp. 每天 17:20 執行一次 JonathanGooglePhotos 項目, 將最近 48 小時內新增的相片同步回 /nas_Photos/GooglePhotos/ 內, 並將結果用 RClone sync Google Photos... 當標題以 Discord 進行通知 : 20 17 * * * rclone copy --max-age 48h --no-traverse -v JonathanGooglePhotos:/media/by-year/ /nas_Photos/GooglePhotos/ > /var/log/cron/GooglePhotos.log 2>&1 && send_logs_to_discord.sh TITLE="RClone sync Google Photos..." LOG_FILE="/var/log/cron/GooglePhotos.log" - 修改完成後, 必須重起 rclone-cron 服務才會生效 docker compose restart rclone-cron # docker compose restart rclone-cron [+] Restarting 1/1 ✔ Container rclone-cron Started # ===== 參考網址 ===== * https://www.youtube.com/watch?v=n8qghZC1Kuc * https://github.com/tryweb/docker-compose/tree/main/rclone {{tag>sync rclone}}