使用者工具

網站工具


tech:rclone

CentOS7 使用 rclone 同步 Google Drive 檔案

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

  • 安裝環境 : CentOS Linux release 7.6.1810 (Core)

安裝 rclone 方式

  • 安裝相關套件
    yum install curl unzip man-db
  • 開始安裝 rclone
    curl https://rclone.org/install.sh |  bash
  • 安裝成功後可以下以下指令確認版本
    rclone version
    [[email protected] ~]# rclone version
    rclone v1.46
    - os/arch: linux/amd64
    - go version: go1.11.5

設定 rclone 對 Google Drive 的 config

使用 rclone 讀取 Google Drive 的語法

  • 列出所有檔案
    rclone ls JonathanGooglePhotos:/ 
  • 只列出目錄
    rclone lsd JonathanGooglePhotos:/ 
  • 將所有檔案複製回本機 /nas_Photos/ 目錄內
    rclone copy -v JonathanGooglePhotos:/ /nas_Photos/GooglePhotos/

設定每天 2:00 執行一次

  • 設定到 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

更新 rclone 方式

  • 其實和開始安裝 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.48.0 has successfully installed.
    Now run "rclone config" for setup. Check https://rclone.org/docs/ for more details.

參考網址

tech/rclone.txt · 上一次變更: 2019/07/22 15:00 由 jonathan_tsai