差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:rclone [2020/08/26 09:15] – [設定每天 2:00 執行一次] jonathan_tsaitech:rclone [2025/04/21 19:38] (目前版本) – [使用 rclone 同步 Google Drive 檔案] jonathan
行 1: 行 1:
-====== CentOS7 使用 rclone 同步 Google Drive 檔案 ======+====== 使用 rclone 同步 Google Drive 檔案 ======
  
 因為愈來愈多檔案存放在 Google Drive, 所以要考慮一個自動的機制將檔案同步回自己的電腦主機內. 因為愈來愈多檔案存放在 Google Drive, 所以要考慮一個自動的機制將檔案同步回自己的電腦主機內.
  
-  * 安裝環境 : CentOS Linux release 7.7.1908 (Core)+<note> 
 +**如果需要 Docker Compose 版本可以參考** - [[tech/rclone_docker]] 
 +</note> 
 +===== 安裝方式 ===== 
 +==== Alpine 3 ==== 
 +  * 安裝環境 : Alpine Linux 3.18 
 +  * 設定 cifs 掛上 NAS 目錄 : [[alpine_cifs]]  
 +  * <cli> 
 +apk add rclone 
 +rclone version 
 +</cli> 
 +    * ++看結果|<cli> 
 +pve-alpine3:~# rclone version 
 +rclone v1.62.2-DEV 
 +- os/version: alpine 3.18.6 (64 bit) 
 +- os/kernel: 6.1.84-0-lts (x86_64) 
 +- os/type: linux 
 +- os/arch: amd64 
 +- go/version: go1.20.11 
 +- go/linking: static 
 +- go/tags: none 
 +</cli>++
  
-===== 安裝 rclone 方式 =====+==== CentOS 7 ====  
 +  * 安裝環境 : CentOS Linux release 7.7.1908 (Core)
   * 安裝相關套件 <code sh>   * 安裝相關套件 <code sh>
 yum install curl unzip man-db yum install curl unzip man-db
行 14: 行 36:
   * 安裝成功後可以下以下指令確認版本 <code sh>   * 安裝成功後可以下以下指令確認版本 <code sh>
 rclone version rclone version
-</code><file>+</code> 
 +    * ++看結果|<cli>
 [root@ct-cloudsync ~]# rclone version [root@ct-cloudsync ~]# rclone version
 rclone v1.50.1 rclone v1.50.1
 - os/arch: linux/amd64 - os/arch: linux/amd64
 - go version: go1.13.4 - go version: go1.13.4
-</file>+</cli>++
  
 ===== 設定 rclone 對 Google Drive / Photos Library API 的 config ===== ===== 設定 rclone 對 Google Drive / Photos Library API 的 config =====
行 33: 行 56:
     - name> (設定這個遠端連結定義名稱) Exp. JonathanGooglePhotos     - name> (設定這個遠端連結定義名稱) Exp. JonathanGooglePhotos
     - Storage> (選擇 Cloud Storage 類型)      - Storage> (選擇 Cloud Storage 類型) 
-      - 如果是 Google Drive 就要選 -> **13 Google Drive** +      - 如果是 Google Drive 就要選 -> **15 Google Drive** 
-      - 如果是要同步 Google 相簿 就要選 -> **14 Google Photos**+      - 如果是要同步 Google 相簿 就要選 -> **16 Google Photos**
     - client_id> (就直接輸入 oAuth 申請的 **用戶端 ID**)     - client_id> (就直接輸入 oAuth 申請的 **用戶端 ID**)
     - client_secret> (就直接輸入 oAuth 申請的 **用戶端密碼**)     - client_secret> (就直接輸入 oAuth 申請的 **用戶端密碼**)
行 71: 行 94:
 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] 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]
 </file> </file>
 +</note>
 +
 +<note tip>
 +  * 如果要改用 webhook 方式進行通知(Exp. Discord, Teams...)
 +    - 先安裝 bash, jq 與 curl Exp. <cli>
 +apk add bash jq curl
 +</cli>
 +    - 下載 [[https://raw.githubusercontent.com/tryweb/docker-compose/refs/heads/main/scripts/send_logs_to_discord.sh|send_logs_to_discord.sh]]<cli>
 +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
 +</cli>
 +    - 將 crontab 內容改成<file>
 +:
 +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"
 +
 +</file>  
 </note> </note>
 ===== 更新 rclone 方式 ===== ===== 更新 rclone 方式 =====
行 89: 行 128:
 0 old database entries were purged. 0 old database entries were purged.
  
-rclone v1.48.0 has successfully installed.+rclone v1.54.0 has successfully installed.
 Now run "rclone config" for setup. Check https://rclone.org/docs/ for more details. Now run "rclone config" for setup. Check https://rclone.org/docs/ for more details.
 </file> </file>
 +
 +
 +===== 啟用 rclone WebUI =====
 +  * 只要加上 rcd --rc-web-gui 就可以啟動 Web UI 的服務
 +  * 如果要外部電腦也可以使用 Web UI 就要加上 --rc-addr 0.0.0.0:5572 
 +  * 再加上登入帳號密碼 Exp. --rc-user admin --rc-pass "MyPass_111"
 +  * Exp. <cli>
 +rclone rcd --rc-web-gui --rc-addr 0.0.0.0:5572 --rc-user admin --rc-pass "MyPass_111" &
 +</cli> \\ {{:tech:螢幕擷取畫面_2025-04-21_135724.png|}}
  
  
  • tech/rclone.1598404547.txt.gz
  • 上一次變更: 2020/08/26 09:15
  • jonathan_tsai