使用 rclone 连接云存储进行备份

rclone 支持各种云存储,这里主要在 Debian 下配置连接 Google Drive,然后进行文件管理和备份操作

1. 安装
curl https://rclone.org/install.sh | sudo bash

2. 初始化配置
rclone config

New Remote
Name: [Name for the Remote Storage, e.g. gdrive]
Type of storage to configure: Google Drive
Google Application Client Id: [Leave Blank]
Google Application Client Secret: [Leave Blank]
Scope: 1
ID of the root folder: [Leave Blank]
root_folder_id: [Leave Blank]
service_account_file: [Leave Blank]
Remote config – Use auto config?: Yes

  • If your browser doesn’t open automatically go to the following link: http://127.0.0.1:53682/auth
    Log in and authorize rclone for access
    Waiting for code…
    在浏览器窗口中,单击要使用的 Google 帐户
    单击 “允许” 按钮允许 rclone 访问您的 Google Drive

Configure this as a Shared Drive (Team Drive)?: No
[gdrive] Yes this is OK
Quit config

 

3. 几个基本操作
List directories in top level of your drive
rclone lsd gdrive:

List all the files in your drive
rclone ls remote:

To copy a local directory to a drive directory called backup
rclone copy /home/source gdrive:backup

Replace copy with move, sync

Setup crontab, e.g. 每天 3:45 同步去 gdrive,排除 tmp 文件夹内容:
45 3 * * * rclone sync /home/source --exclude tmp/ gdrive:backup

Add a Comment

您的电子邮箱地址不会被公开。 必填项已用*标注