CentOS7 使用 rclone 同步 Google Drive 檔案

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

  • 安裝環境 : CentOS Linux release 7.7.1908 (Core)
  • 安裝相關套件
    yum install curl unzip man-db
  • 開始安裝 rclone
    curl https://rclone.org/install.sh |  bash
  • 安裝成功後可以下以下指令確認版本
    rclone version
    [root@ct-cloudsync ~]# rclone version
    rclone v1.50.1
    - os/arch: linux/amd64
    - go version: go1.13.4
  • 列出所有檔案
    rclone ls JonathanGooglePhotos:/ 
  • 只列出目錄
    rclone lsd JonathanGooglePhotos:/ 
  • 將所有檔案複製回本機 /nas_Photos/ 目錄內
    rclone copy -v JonathanGooglePhotos:/ /nas_Photos/GooglePhotos/
  • 設定到 crontab
     vi /etc/crontab 
    :
    0 2 * * * root rclone copy --max-age 48h --no-traverse -v JonathanGooglePhotos:/ /nas_Photos/GooglePhotos/ 2>&1 | tee /tmp/syncGooglePhotos.log
  • 重新啟動 crond
    systemctl restart crond
  • 如果要設定可以自動寄出 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]
  • 其實和開始安裝 rclone 的語法相同
    curl https://rclone.org/install.sh |  bash
  • 更新後的結果
    Processing manual pages under /usr/share/man/sk...
    Purging old database entries in /usr/share/man/tr...
    Processing manual pages under /usr/share/man/tr...
    Purging old database entries in /usr/share/man/da...
    Processing manual pages under /usr/share/man/da...
    Purging old database entries in /usr/local/share/man...
    Processing manual pages under /usr/local/share/man...
    0 man subdirectories contained newer manual pages.
    0 manual pages were added.
    0 stray cats were added.
    0 old database entries were purged.
    
    rclone v1.54.0 has successfully installed.
    Now run "rclone config" for setup. Check https://rclone.org/docs/ for more details.
  • tech/rclone.txt
  • 上一次變更: 2021/02/27 22:38
  • jonathan