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

/ 0评 / 0

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

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://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
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://rclone.org/onedrive/ **

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://logdns-my.sharepoint.com/personal/idwoo_cao_by/Documents
    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群聊:

发表评论

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