跳至主要内容

自己建立网盘并且设置主备盘

自己建立网盘并且设置主备盘

web管理推荐:File Browser,请参考:File Browser配置教程

File Browser配置好了我们来配置3个盘,这里用到的工具是大名鼎鼎的Rclone

我们这里把Aws S3做为主盘,Google Drive和Onedrive(E3)做备份盘.提示芳姐的Onedrive教育版无法做.因为什么的?天天折腾人家,微软受不了封主号了!

开始折腾.

一. 先准备创建3个目录

mkdir /root/s3 
mkdir /root/google
mkdir /root/onedrive
#并且给与写入权限 chmod a+x /root

二. 安装Rclone Ubuntu 18为演示版本

  1. 具体教程请看利用Google Drive的无限网盘做数据定时备份
curl https://rclone.org/install.sh | sudo bash

rclone config

S3配置

root@ip-172-26-13-159:~# rclone config
2018/10/31 06:21:18 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
name> s3
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / A stackable unification remote, which can appear to merge the contents of several remotes
\ "union"
2 / Alias for a existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Dropbox
\ "dropbox"
9 / Encrypt/Decrypt a remote
\ "crypt"
10 / FTP Connection
\ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
12 / Google Drive
\ "drive"
13 / Hubic
\ "hubic"
14 / JottaCloud
\ "jottacloud"
15 / Local Disk
\ "local"
16 / Mega
\ "mega"
17 / Microsoft Azure Blob Storage
\ "azureblob"
18 / Microsoft OneDrive
\ "onedrive"
19 / OpenDrive
\ "opendrive"
20 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
21 / Pcloud
\ "pcloud"
22 / QingCloud Object Storage
\ "qingstor"
23 / SSH/SFTP Connection
\ "sftp"
24 / Webdav
\ "webdav"
25 / Yandex Disk
\ "yandex"
26 / http Connection
\ "http"
Storage> 4 选择4
** See help for s3 backend at: https://rclone.org/s3/ **

Choose your S3 provider.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Amazon Web Services (AWS) S3
\ "AWS"
2 / Ceph Object Storage
\ "Ceph"
3 / Digital Ocean Spaces
\ "DigitalOcean"
4 / Dreamhost DreamObjects
\ "Dreamhost"
5 / IBM COS S3
\ "IBMCOS"
6 / Minio Object Storage
\ "Minio"
7 / Wasabi Object Storage
\ "Wasabi"
8 / Any other S3 compatible provider
\ "Other"
provider> 1 选择1
Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars).
Only applies if access_key_id and secret_access_key is blank.
Enter a boolean value (true or false). Press Enter for the default ("false").
Choose a number from below, or type in your own value
1 / Enter AWS credentials in the next step
\ "false"
2 / Get AWS credentials from the environment (env vars or IAM)
\ "true"
env_auth> 1 选择1
AWS Access Key ID.
Leave blank for anonymous access or runtime credentials.
Enter a string value. Press Enter for the default ("").
access_key_id> 访问密钥 ID
AWS Secret Access Key (password)
Leave blank for anonymous access or runtime credentials.
Enter a string value. Press Enter for the default ("").
secret_access_key> 私有访问密钥
Region to connect to.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
/ The default endpoint - a good choice if you are unsure.
1 | US Region, Northern Virginia or Pacific Northwest.
| Leave location constraint empty.
\ "us-east-1"
/ US East (Ohio) Region
2 | Needs location constraint us-east-2.
\ "us-east-2"
/ US West (Oregon) Region
3 | Needs location constraint us-west-2.
\ "us-west-2"
/ US West (Northern California) Region
4 | Needs location constraint us-west-1.
\ "us-west-1"
/ Canada (Central) Region
5 | Needs location constraint ca-central-1.
\ "ca-central-1"
/ EU (Ireland) Region
6 | Needs location constraint EU or eu-west-1.
\ "eu-west-1"
/ EU (London) Region
7 | Needs location constraint eu-west-2.
\ "eu-west-2"
/ EU (Frankfurt) Region
8 | Needs location constraint eu-central-1.
\ "eu-central-1"
/ Asia Pacific (Singapore) Region
9 | Needs location constraint ap-southeast-1.
\ "ap-southeast-1"
/ Asia Pacific (Sydney) Region
10 | Needs location constraint ap-southeast-2.
\ "ap-southeast-2"
/ Asia Pacific (Tokyo) Region
11 | Needs location constraint ap-northeast-1.
\ "ap-northeast-1"
/ Asia Pacific (Seoul)
12 | Needs location constraint ap-northeast-2.
\ "ap-northeast-2"
/ Asia Pacific (Mumbai)
13 | Needs location constraint ap-south-1.
\ "ap-south-1"
/ South America (Sao Paulo) Region
14 | Needs location constraint sa-east-1.
\ "sa-east-1"
region> 11选择你所在的服务器地区,一定要写对不然挂载无法写入文件
Endpoint for S3 API.
Leave blank if using AWS to use the default endpoint for the region.
Enter a string value. Press Enter for the default ("").
endpoint>
Location constraint - must be set to match the Region.
Used when creating buckets only.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Empty for US Region, Northern Virginia or Pacific Northwest.
\ ""
2 / US East (Ohio) Region.
\ "us-east-2"
3 / US West (Oregon) Region.
\ "us-west-2"
4 / US West (Northern California) Region.
\ "us-west-1"
5 / Canada (Central) Region.
\ "ca-central-1"
6 / EU (Ireland) Region.
\ "eu-west-1"
7 / EU (London) Region.
\ "eu-west-2"
8 / EU Region.
\ "EU"
9 / Asia Pacific (Singapore) Region.
\ "ap-southeast-1"
10 / Asia Pacific (Sydney) Region.
\ "ap-southeast-2"
11 / Asia Pacific (Tokyo) Region.
\ "ap-northeast-1"
12 / Asia Pacific (Seoul)
\ "ap-northeast-2"
13 / Asia Pacific (Mumbai)
\ "ap-south-1"
14 / South America (Sao Paulo) Region.
\ "sa-east-1"
location_constraint> 11选择你所在的服务器地区,一定要写对不然挂载无法写入文件
Canned ACL used when creating buckets and/or storing objects in S3.
For more info visit https://ift.tt/1oksq89
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Owner gets FULL_CONTROL. No one else has access rights (default).
\ "private"
2 / Owner gets FULL_CONTROL. The AllUsers group gets READ access.
\ "public-read"
/ Owner gets FULL_CONTROL. The AllUsers group gets READ and WRITE access.
3 | Granting this on a bucket is generally not recommended.
\ "public-read-write"
4 / Owner gets FULL_CONTROL. The AuthenticatedUsers group gets READ access.
\ "authenticated-read"
/ Object owner gets FULL_CONTROL. Bucket owner gets READ access.
5 | If you specify this canned ACL when creating a bucket, Amazon S3 ignores it.
\ "bucket-owner-read"
/ Both the object owner and the bucket owner get FULL_CONTROL over the object.
6 | If you specify this canned ACL when creating a bucket, Amazon S3 ignores it.
\ "bucket-owner-full-control"
acl> 1选择1
The server-side encryption algorithm used when storing this object in S3.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / None
\ ""
2 / AES256
\ "AES256"
3 / aws:kms
\ "aws:kms"
server_side_encryption> 1选择1
If using KMS ID you must provide the ARN of Key.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / None
\ ""
2 / arn:aws:kms:*
\ "arn:aws:kms:us-east-1:*"
sse_kms_key_id> 1选择1
The storage class to use when storing new objects in S3.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Default
\ ""
2 / Standard storage class
\ "STANDARD"
3 / Reduced redundancy storage class
\ "REDUCED_REDUNDANCY"
4 / Standard Infrequent Access storage class
\ "STANDARD_IA"
5 / One Zone Infrequent Access storage class
\ "ONEZONE_IA"
storage_class> 1选择1
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n选择1

Remote config

[s3]
type = s3
provider = AWS
env_auth = false
access_key_id =
secret_access_key =
region = ap-southeast-2
location_constraint = ap-northeast-1
acl = private

y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:

Name Type
==== ====
s3 s3

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

Google盘配置

访问利用Google Drive的无限网盘做数据定时备份

Onedrive配置(只适合E3用户,下面有个人版的配置)

  1. 首页我们要在本地获取key,下载Rclone,然后执行rclone authorize "onedrive"就会出现{"access_token":"eyJ0eXAiOiJKV1QiLCJub25j.....","expiry":"2018-10-31T15:43:38.098775+08:00"}这样的字样我们要记录下来等会有用!
  2. 服务器开始配置
rclone config

root@ip-172-26-13-159:~# rclone config
Current remotes:

Name Type
==== ====
google drive
s3 s3

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> n
name> onedrive
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / A stackable unification remote, which can appear to merge the contents of several remotes
\ "union"
2 / Alias for a existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Dropbox
\ "dropbox"
9 / Encrypt/Decrypt a remote
\ "crypt"
10 / FTP Connection
\ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
12 / Google Drive
\ "drive"
13 / Hubic
\ "hubic"
14 / JottaCloud
\ "jottacloud"
15 / Local Disk
\ "local"
16 / Mega
\ "mega"
17 / Microsoft Azure Blob Storage
\ "azureblob"
18 / Microsoft OneDrive
\ "onedrive"
19 / OpenDrive
\ "opendrive"
20 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
21 / Pcloud
\ "pcloud"
22 / QingCloud Object Storage
\ "qingstor"
23 / SSH/SFTP Connection
\ "sftp"
24 / Webdav
\ "webdav"
25 / Yandex Disk
\ "yandex"
26 / http Connection
\ "http"
Storage> 18选择18 onedrive
** See help for onedrive backend at: https://ift.tt/2EqKyoM **

Microsoft App Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>回车
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>回车
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n选择n
Remote config
Use auto config?

  • Say Y if not sure
  • Say N if you are working on a remote or headless machine
    y) Yes
    n) No
    y/n> n选择n
    For this to work, you will need rclone available on a machine that has a web browser available.
    Execute the following on your machine:
    rclone authorize "onedrive"
    Then paste the result below:
    result> {"access_token":"eyJ0Cc","expiry":"2018-10-31T15:43:38.098775+08:00"}

    复制刚刚你在本机获取的key到这里
    2018/10/31 06:48:04 ERROR : Failed to save new token in config file: section 'onedrive' not found
    Choose a number from below, or type in an existing value
    1 / OneDrive Personal or Business
    \ "onedrive"
    2 / Root Sharepoint site
    \ "sharepoint"
    3 / Type in driveID
    \ "driveid"
    4 / Type in SiteID
    \ "siteid"
    5 / Search a Sharepoint site
    \ "search"
    Your choice> 1选择1
    Found 1 drives, please select the one you want to use:
    0: OneDrive (business) id=b!rfYKiY1pqvvFha3u
    Chose drive to use:> 0选择0
    Found drive 'root' of type 'business', URL: https://ift.tt/2Dd1LWJ
    Is that okay?
    y) Yes
    n) No
    y/n> y选择y

[onedrive]
type = onedrive
token = {"access_token":"eyJ0SCAA","expiry":"2018-10-31T15:43:38.098775+08:00"}
drive_id = b!rfYKiYCsYkOuIB9MlEcUUaBEqklDh0lEl0ALyjcqhBn8kS1hx7D8QqfpqvvFha3u
drive_type = business

y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y 选择y
Current remotes:

Name Type
==== ====
google drive
onedrive onedrive
s3 s3

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 选择q

没有E3的同学,可以用另外一种办法挂载onedrive的个人账户

mkdir /root/onedrive
git clone https://github.com/xybu/onedrive-d-old.git
mv onedrive-d-old onedrive-d
cd onedrive-d
./install.sh #安装
onedrive-pref #设置
onedrive-d start #启动

3个盘都挂载完毕,我们来检查一下

df -h

都挂载上了,这里有疑问的同学应该是盘大小不一样怎么做主备?其实Sandy主盘s3备盘google,onedrive只是作为arie2+电影盘.不用出墙嘛速度快拿来群晖做在线电影

挂载好了我们就来测试一下盘和盘的同步

我们在Rclone官网可以看到sync的文档里面有写到

rclone sync s3:homekey /root/google 
#这样写是s3同步google,反过来是google同步s3,注意同步是会删除目标盘里面所有的东西.所有一定要挂载干净的空目录

我们来做个测试:图1.s3 图2.googel

###图1(s3)

图2(google)

我们来执行

rclone sync s3:homekey /root/google 

我们看看图3 google目录同步的情况

图3 (google)

我们已经同步到google drive盘里面了

我们要做个crontab,让主盘每天同步一次备份盘

vi /etc/crontab
30 1 * * * rclone sync s3:homekey /root/google 
#每晚夜深人静的时候1.30分开始备份,应该你们家都没人在写数据了吧!自由发挥

主备盘教程就结束了~~~~各位看官有钱的打赏几两金子,没钱的捧个人场!

来折腾onedrive的Arie2+Nginx+rclone,折腾好了以后群晖一样用rclone挂载.然后我们就可以服务器下载利用群晖的电影APP看电影了~其他Nas只能下载一些支持nas播放的APP也可以看.这里就不详细给大家细说了!有什么问题可以加QQ群聊:

评论

此博客中的热门博文

阿里云通过Nginx中转Linode/digitalocean/AWS的V2ray协议,实现负载均衡

开篇文的废话.原因是Sandy做站服务器太多了,发现利用率不高,皮又痒了又想折腾了.v2ray是利器但是给人的感觉就是只能用一台服务器,官方也说不支持负载均衡,不会A服务器挂机,自动跳转到B服务器.这里就有点折磨人了.每个服务器挂了都要自己去改配置文件. 我们访问国外的服务器,如果没CN2的线路是非常慢的,起码不快!哈哈~现在VPS都便宜起码人手一个人有5台以上吧?这样的话我们就可以开整. 开整条件:国内VPS或者阿里云有CN2线路的机器最好是100MB-200MB的带宽的.保证你爽歪歪.但是Sandy在阿里云HK30MB下也测试了也可以达到30000KB以上,羡慕吧~我们可以开始了! 老规则工具先出: 没被gwf和谐的服务器1台(下文统称:主服务器) 国外服务器2台以上(下文统称:从服务器) nginx 1.9.5版本以上(推荐:lnmp1.4) v2ray croe 第一步: 在 主服务器 安装lnmp1.4,这里就不细说教程了.直接去 官方 看教程 安装完毕以后我们来升级Nginx让他支持stream模块 cd lnmp1.4 vi lnmp.conf 在Nginx_Modules_Options=‘’里面加入--with-stream Nginx_Modules_Options='--with-stream’ 然后执行升级命令 ./upgrade.sh nginx  第二步 修改nginx.conf文件 cd /usr/local/nginx/conf/nginx.conf 在 events { use epoll; worker_connections 51200; multi_accept on; } 下面加入 stream{ server{ listen 0.0.0.0:8080; proxy_pass v2ray_backend; proxy_timeout 10m; proxy_connect_timeout 5000ms; } upstream v2ray_backend{ server

利用haproxy来做V2RAY负载均衡

Sandy在之前有说过 阿里云通过Nginx中转Linode/digitalocean/AWS的V2ray协议,实现负载均衡 ,有些学童不想折腾nginx,那么我们可以用haproxy来折腾,不管是haproxy还是Nginx都可以在树莓派和局域网的PC机器折腾! 安装haproxy的教程就移步到-> haproxy安装教程 apt-get install haproxy 安装完毕,我们来修改haproxy的配置 vi /etc/haproxy/haproxy.cfg 里面内容全部删除,加入下面的内容 global ulimit-n 51200 log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy pidfile /var/run/haproxy.pid user haproxy group haproxy daemon defaults log global mode tcp retries 3 option dontlognull option redispatch #上游TCP服务器连接等待时间 timeout connect 5s timeout client 24h timeout server 24h #以下为Web管理页面设置,如不需要可以删除 listen admin_stats bind 0.0.0.0:8888 mode http log 127.0.0.1 local0 err stats refresh 30s stats uri /haproxy stats realm welcome login\ Haproxy stats auth admin:admin stats hide-version stat

利用aws最低配置搭建frp内网穿透

利用aws最低配置搭建frp内网穿透 由于最近忙着搬家的时候,一直在考虑如何让2个地区来实现稳定的内网穿透,可以把2边的带宽利用起来!突然想起很早之前和鸟总一起搭建过的frp内网穿透.于是就折腾了起来了. 这次我们利用别人写好的一键脚本吧,自己懒得去编辑frp.ini文件了! 1. 服务器端安装说明(ubuntu 18) wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-install-shell/master/frps/install-frps.sh -O ./install-frps.sh chmod 700 ./install-frps.sh ./install-frps.sh install 安装过程中会有提示一些的参数,我们设置好就可以了! Please input frps bind_port [1-65535](Default Server Port: 5443): #输入frp提供服务的端口,用于服务器端和客户端通信,按Enter键表示默认5443,否则手动输入新端口 Please input frps dashboard_port [1-65535](Default dashboard_port: 6443): #输入frp的控制台服务端口,用于查看frp工作状态,按Enter键表示默认6443,否则手动输入新端口 Please input frps vhost_http_port [1-65535](Default vhost_http_port: 80): #输入frp进行http穿透的http服务端口,按Enter键表示默认80,否则手动输入新端口,一般不建议默认80 Please input frps vhost_https_port [1-65535](Default vhost_https_port: 443): #输入frp进行https穿透的https服务端口,按Enter键表示默认443,否则手动输入新端口 Please input privilege_token (Default: WEWLRgwRjIJVPx2kuqzkGnvuftPLQniq): #输入frp服务器和客户端通信的密码,默认是随机生