下载当前最新版本的rclone
mkdir /opt/rclone && cd /opt/rclone # 创建rclone程序文件夹并进入
wget https://downloads.rclone.org/v1.66.0/rclone-v1.66.0-linux-amd64.zip # 下载rclone
unzip rclone-v1.66.0-linux-amd64.zip # 解压rclone
rm -rf rclone-v1.66.0-linux-amd64.zip # 删除rclone压缩包
ln -s /opt/rclone/rclone-v1.66.0-linux-amd64/rclone /usr/bin # 创建rclone软链接方便全局使用
安装完成后, 使用rclone -V
,返回如下信息说明rclone安装成功
rclone v1.66.0
- os/version: debian 11.9 (64 bit)
- os/kernel: 5.10.0-28-cloud-amd64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.22.1
- go/linking: static
- go/tags: none
配置rclone
运行rclone config
开始配置
2024/05/23 08:46:24 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q>
输入n新建配置
Enter name for new remote.
name>
输入配置名称,我这里输入minio
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
...
...
...
33 / Microsoft OneDrive
\ (onedrive)
...
...
...
输入存储提供商,我这里填33,同步onedrive云盘
Option client_id.
OAuth Client Id.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_id>
这里填client_id,直接回车,通常为空
Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret>
这里填client_secret,直接回车,通常为空
Option region.
Choose national cloud region for OneDrive.
Choose a number from below, or type in your own string value.
Press Enter for the default (global).
1 / Microsoft Cloud Global
\ (global)
2 / Microsoft Cloud for US Government
\ (us)
3 / Microsoft Cloud Germany
\ (de)
4 / Azure and Office 365 operated by Vnet Group in China
\ (cn)
选择onedrive区域,填1选择全球
Edit advanced config?
y) Yes
n) No (default)
是否填写高级配置,填n不填写
Use web browser to automatically authenticate rclone with remote?
* Say Y if the machine running rclone has a web browser you can use
* Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.
y) Yes (default)
n) No
是否使用浏览器去onedrive获取认证,因为服务器没有GUI界面,这里填n
Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
rclone authorize "onedrive" "XXXXXXXXXXXXXXXXXXX"
Then paste the result.
Enter a value.
config_token>
这里需要用到本地电脑,首先前往 https://downloads.rclone.org/v1.66.0 ,下载对应版本的客户端,rclone建议和服务器rclone版本号保持一致,下载完成后运行上面的命令,例如windows, 使用CMD执行./rclone.exe authorize "onedrive" "XXXXXXXXXXXXXXXXXXX"
, 执行后,会弹出浏览器,根据提示授权rclone ,授权完成后返回控制台
PS C:\Software\Rclone\rclone-v1.66.0-windows-amd64> .\rclone.exe authorize "onedrive" "XXXXXXXXXXXXXXXXXXX"
2024/05/24 09:26:59 NOTICE: Config file "C:\\Users\\SUHANG\\AppData\\Roaming\\rclone\\rclone.conf" not found - using defaults
2024/05/24 09:26:59 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=XXXXXXXXXXXXXXXXXXX
2024/05/24 09:26:59 NOTICE: Log in and authorize rclone for access
2024/05/24 09:26:59 NOTICE: Waiting for code...
2024/05/24 09:27:20 NOTICE: Got code
Paste the following into your remote machine --->
[需要复制的内容]
<---End paste
将需要[需要复制的内容], 复制到上一步的config_token里面,并回车
Option config_type.
Type of connection
Choose a number from below, or type in an existing string value.
Press Enter for the default (onedrive).
1 / OneDrive Personal or Business
\ (onedrive)
2 / Root Sharepoint site
\ (sharepoint)
/ Sharepoint site name or URL
3 | E.g. mysite or https://contoso.sharepoint.com/sites/mysite
\ (url)
4 / Search for a Sharepoint site
\ (search)
5 / Type in driveID (advanced)
\ (driveid)
6 / Type in SiteID (advanced)
\ (siteid)
/ Sharepoint server-relative path (advanced)
7 | E.g. /teams/hr
\ (path)
选择onedrive账户类型,填1回车
Option config_driveid.
Select drive you want to use
Choose a number from below, or type in your own string value.
Press Enter for the default (xxxxxxxx).
1 / (personal)
\ (xxxxxxxx)
config_driveid>
选择账号下的driveid, 填1回车
Drive OK?
Found drive "root" of type "personal"
URL: https://onedrive.live.com/?cid=xxxxxxxx
y) Yes (default)
n) No
y/n>
默认回车
Configuration complete.
Options:
- type: onedrive
- token: {"access_token":"xxxxxxxx","token_type":"Bearer","refresh_token":"xxxxxxxx","expiry":"2024-05-24T10:27:22.6482968+08:00"}
- drive_id: xxxxxxxx
- drive_type: personal
Keep this "minio" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
默认回车
至此,rclone配置完成
使用rclone ls minio:/
查看是否能正常列出onedrive目录,验证配置是否成功
配置定时备份
执行crontab -e
参考以下配置,填写自己的备份策略
0 1 * * * rclone sync /opt/minio/ minio:/backup/minio # 每天凌晨一点将/opt/minio目录备份到onedrive /backup/minio目录