由于网络推广中最有效的方法是SEO,所以很多有丰富SEO经验的网络营销人员,都会选择购买VPS(虚拟专用服务器)来搭建网站。

既然用到VPS,就要给VPS做备份,VPS备份可以用rclone备份同步到GDrive网盘。

什么是rclone?

RClone 可以轻松方便管理 Google Drive和Dropbox等网盘,支持挂载盘符和命令行上传和下载:
◾挂载盘,易于使用,但速度较慢,比较适合零碎小文件
◾命令行上传和下载速度非常快,适合上传大文件
◾Rclone认为Google Drive AP,与github上的[gdrive]项目相比,不易出现中断问题。

下面就来分享CentOS 安装 rclone 备份同步到 Google Drive 的方法。

如何使用rclone备份VPS?

以下是需要准备的工具:
◾Google Dirve帐号
◾一个rclone文件
◾一台Linux机器(本文以CentOS7为例)

然后开始安装rclone,安装非常简单,复制粘贴加上权限。

第 1 步:下载文件 ▼
yum install unzip wget -y
wget https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
cd rclone-*-linux-amd64

第 2 步:将该文件复制到相关路径 ▼
cp rclone /usr/bin/
chown root:root /usr/bin/rclone
chmod 755 /usr/bin/rclone
◾(此步骤可以省略,但不建议,省略后是不会有提示,所以不推荐省略)

第 3 步:安装帮助页面▼
mkdir -p /usr/local/share/man/man1
cp rclone.1 /usr/local/share/man/man1/
mandb

第 4 步:创建一个新的配置 ▼
rclone config

第 5 步:rclone配置

以下是 rclone 绑定Google Dirve 网盘为例 ▼

VPS如何使用rclone备份?CentOS使用GDrive同步教程
n) New remote

d) Delete remote
q) Quit config
e/n/d/q> n
name> gdrive(你的配置名称,此处随意填写但之后需要用到)
Type of storage to configure.
Choose a number from below, or type in your own value
 1 / Amazon Drive
   \ "amazon cloud drive"
 2 / Amazon S3 (also Dreamhost, Ceph, Minio)
   \ "s3"
 3 / Backblaze B2
   \ "b2"
 4 / Dropbox
   \ "dropbox"
 5 / Encrypt/Decrypt a remote
   \ "crypt"
 6 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
 7 / Google Drive
   \ "drive"
 8 / Hubic
   \ "hubic"
 9 / Local Disk
   \ "local"
10 / Microsoft OneDrive
   \ "onedrive"
11 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
12 / SSH/SFTP Connection
   \ "sftp"
13 / Yandex Disk
   \ "yandex"
Storage> 7(根据网盘类型选择Google Dirve)
Google Application Client Id - leave blank normally.
client_id>此处留空
Google Application Client Secret - leave blank normally.
client_secret>此处留空
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(此处一定要选择n)
If your browser doesn't open automatically go to the following
link: https://accounts.google.com/o/oauth2/auth?xxxxxxxxxxxxxxxxx

Log in and authorize rclone for access
Enter verification code>xxxxxxxxxxx(将将上面给出的网址复制到您的浏览器,登录Google Dirve的Google帐户,然后复制字符串到此粘贴)

--------------------
[gdrive]
client_id =
client_secret =
token = {"AccessToken":"xxxx.x.xxxxx_xxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","RefreshToken":"1/xxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxx","Expiry":"2014-03-16T13:57:58.955387075Z","Extra":null}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y(确定信息并保存)

rclone 使用命令

列出文件和目录命令

列出配置名为gdrive的网盘的目录(不会显示文件)▼

rclone lsd gdrive:

列出配置名为gdrive的网盘里backup目录下的文件(会显示包括子目录内的所有文件不显示目录)▼

rclone ls gdrive:backup

复制剪切删除命令

复制本地 /home/backup 到配置名为gdrive的网盘的backup目录,反之亦然 ▼

rclone copy /home/backup gdrive:backup

通过添加此参数 --ignore-existing 可以忽略在网盘上已备份的文件,这相当于增量备份 ▼

rclone copy --ignore-existing /home/backup gdrive:backup

从gdrive的网盘,复制备份文件到本地 /home/backup 目录 ▼
rclone copy gdrive:backup/admin.2018-04-12_13-10-02.tar /home/backup

移动(剪切)命令 ▼

rclone move /home/backup gdrive:backup

删除配置名为gdrive的网盘的backup目录▼

rclone delete gdrive:backup

创建配置名为gdrive的网盘的backup目录 ▼

rclone mkdir gdrive:backup

同步文件命令

同步本地 /home/backup 到配置名gdrive的网盘里的backup目录,反之亦然 ▼

rclone sync /home/backup gdrive:backup

同步配置名gdrive2的网盘里的UFO目录,到配置名为gdrive的网盘的backup目录,反之亦然 ▼

rclone sync gdrive2:ufo gdrive:backup

稍等片刻,如果没有返回错误信息,你可以在备份完成后在网盘上看到备份文件。

使用 rclone 备份VPS确实非常简单 ^_^

原帖地址:https://www.chenweiliang.com/cwl-694.html
经用于学习之用途

标签: none

添加新评论