备份神器Rclone安装配置使用指南

Rclone介绍


Rclone是一款命令行的sync同步工具
使用Rclone可以方便的管理备份远程存储,对象存储,云硬盘,网盘等.
另外,Rclone可以将网盘挂载到本地硬盘,简直就是神器.

Rclone下载安装


wget https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-*
cd  rclone-*
cp -raf rclone /usr/bin/
chown root:root /usr/bin/rclone
chmod 755 /usr/bin/rclone
rm -Rf ../rclone-*

Rclone配置[Google Drive为例子]


rclone config
No remotes found - make a new one
n) New remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
n/r/c/s/q> n  #新建配置
name> gdrive  #配置名称,自定义
Type of storage to configure.
Choose a number from below, or type in your own value
[snip]
12 / Google Drive
   \ "drive"
[snip]
Storage> 12  #选择网盘类型
Google Application Client Id - leave blank normally.
client_id>   #留空,回车
Google Application Client Secret - leave blank normally.
client_secret>   #留空,回车
Scope that rclone should use when requesting access from drive.
Choose a number from below, or type in your own value
 1 / Full access all files, excluding Application Data Folder.
   \ "drive"
 2 / Read-only access to file metadata and file contents.
   \ "drive.readonly"
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ "drive.file"
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ "drive.appfolder"
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ "drive.metadata.readonly"
scope> 1   #给于全部权限
ID of the root folder - leave blank normally.  Fill in to access "Computers" folders. (see docs).
root_folder_id>    #留空,回车
Service Account Credentials JSON file path - needed only if you want use SA instead of interactive login.
service_account_file>    #留空,回车
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file>
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n        #不使用高级选项
Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine or Y didn't work
y) Yes
n) No
y/n> n  #远程访问,手动填写authorize code
If your browser doesn't open automatically go to the following link: xxxxx
Log in and authorize rclone for access
Waiting for code...
Got code
Configure this as a team drive?
y) Yes
n) No
y/n> n #团队盘不设置
--------------------
[remote]
client_id = 
client_secret = 
scope = drive
root_folder_id = 
service_account_file =
token = {"access_token":"XXX","token_type":"Bearer","refresh_token":"XXX","expiry":"2014-03-16T13:57:58.955387075Z"}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y  #配置正确,保存
Current remotes:
Name                 Type
====                 ====
gdrive               drive
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q  #退出设置

Rclone常用命令


文件上传
rclone copy /home/backup gdrive:backup # 本地路径 配置名字:谷歌文件夹名字
文件下载
rclone copy gdrive:backup /home/backup
列表
rclone ls gdrive:backup
rclone lsl gdrive:backup # 比上面多一个显示上传时间
rclone lsd gdrive:backup # 只显示文件夹
新建文件夹
rclone mkdir gdrive:backup
挂载
rclone mount gdrive:mm /root/mm &
rclone mount gdrive:mm /root/mm --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 &
卸载
fusermount -qzu /root/mm

其他命令


# https://softlns.github.io/2016/11/28/rclone-guide/
rclone config - 以控制会话的形式添加rclone的配置,配置保存在.rclone.conf文件中。
rclone copy - 将文件从源复制到目的地址,跳过已复制完成的。
rclone sync - 将源数据同步到目的地址,只更新目的地址的数据。 –dry-run标志来检查要复制、删除的数据
rclone move - 将源数据移动到目的地址。
rclone delete - 删除指定路径下的文件内容。
rclone purge - 清空指定路径下所有文件数据。
rclone mkdir - 创建一个新目录。
rclone rmdir - 删除空目录。
rclone check - 检查源和目的地址数据是否匹配。
rclone ls - 列出指定路径下所有的文件以及文件大小和路径。
rclone lsd - 列出指定路径下所有的目录/容器/桶。
rclone lsl - 列出指定路径下所有文件以及修改时间、文件大小和路径。
rclone md5sum - 为指定路径下的所有文件产生一个md5sum文件。
rclone sha1sum - 为指定路径下的所有文件产生一个sha1sum文件。
rclone size - 获取指定路径下,文件内容的总大小。.
rclone version - 查看当前版本。
rclone cleanup - 清空remote。
rclone dedupe - 交互式查找重复文件,进行删除/重命名操作。

--transfers 1 #限制线程
--min-size 10G #大小限制

官方网站: https://rclone.org/

发表评论