缘由&要求

iPhone的屏幕碎裂,又想着去Apple化,加之在浏览Google Photos时候的感触颇深,于是就有了这样的操作。
当然,需要一台位于境外的VPS,从iCloud上拉资源,再上传到Google Drive。

从iCloud上下载

由于Apple没有开放iCloud的API,于是关于iCloud下载的第三方程序少之又少。于是我找到了这个icloudpd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#以Ubuntu/Debian系统为例
#下载并安装pip,若为安装unzip,则需使用apt-get install unzip。
root@Raincorn:/icloud# wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
--2019-01-30 20:58:55-- https://bootstrap.pypa.io/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.0.175, 151.101.64.175, 151.101.128.175, ...
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.0.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1700321 (1.6M) [text/x-python]
Saving to:get-pip.py’

get-pip.py 100%[===========================>] 1.62M --.-KB/s in 0.02s

2019-01-30 20:58:55 (79.4 MB/s) - ‘get-pip.py’ saved [1700321/1700321]

root@Raincorn:/icloud# python get-pip.py
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting pip
Downloading
Successfully installed pip-19.0.1 setuptools-40.7.1 wheel-0.32.3
#由于已经由pip收录,可以使用```pip install icloudpd```来下载icloudpd。

使用icloud photos(注意,photos为你要保存照片的目录,可自定义为其他。)
接着会要求输入iCloud账号密码,验证完成后就会开始下载,我用了51分20秒把2324张照片下载了下来。但是为什么速度不理想,原因很大程度上是因为苹果的iCloud服务器由云上贵州接管,服务器在国内,晚上又是高峰时段,速度。。。嗯,苹果💊。

上传到Google Drive

Google作为行业巨头,全力推行开源事业,有关Drive的有关程序网上比比皆是,我这里介绍我正在使用的一个名为rclone的管理程序。

rclone的安装

下载rclone

1
2
3
4
5
6
7
#按照官方Docs操作就好。
#首先下载并解压rclone
root@Raincorn:~# wget https://downloads.rclone.org/rclone-current-linux-amd64.zip

root@Raincorn:~# unzip rclone-current-linux-amd64.zip

root@Raincorn:~# cd rclone-*linux-amd64

复制赋权

1
2
3
4
5
6
cp rclone /usr/bin/

chown root:root /usr/bin/rclone

chmod 755 /usr/bin/rclone
#至于为什么要有这一步,可以参考之前那篇关于[环境变量](https://raincorn.top/2018/08/29/%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F/)的文章,间的来说,就是为了在用rclone时能够找到对应的程序。

安装帮助页面

1
2
3
4
5
mkdir -p /usr/local/share/man/man1

cp rclone.1 /usr/local/share/man/man1/

mandb

配置

键入rclone config即可进入配置页面。

这里是配置实例,基本上有些英语基础就没问题。也可以参考https://rclone.org/drive/ 给出的实例,或者https://www.chenweiliang.com/cwl-694.html 的例子。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
root@Raincorn:/rclone# rclone config
2019/01/30 21:25:58 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(创建新的Drive类型)
name> Google(自定义配置的名称)
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"

Storage> 12(选择类型,会随着版本变动而有所变化。)
** See help for drive backend at: https://rclone.org/drive/ **

Google Application Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>
Google Application Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>
Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default ("").
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(即允许rclone获得你全部的Drive访问权限。)
ID of the root folder
Leave blank normally.
Fill in to access "Computers" folders. (see docs).
Enter a string value. Press Enter for the default ("").
root_folder_id>
Service Account Credentials JSON file path
Leave blank normally.
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
If your browser doesn't open automatically go to the following link: https://accounts.google.com/(你需要登陆的链接。)
Enter verification code> 4/4gBaYe2_(你在网页中获得erification code)
Configure this as a team drive?
y) Yes
n) No
y/n> n
--------------------
[Google]
type = drive
scope = drive
token = {"access_token":"ya29.GluhBkLo5l7zLGZFmeHEbBSWFxJD8HaiAqpDLmD7BPPFUGcpXrgnnd8pWoahZJvgyv9Qk5yc7TxRLRmxKt31N8mmjP4bbvr2sSb_E8ZbpRNetFtglc2SrjMRFW6z","token_type":"Bearer","refresh_token":"1/jmLzUeXGBUqMVHV_k4x8F6UhPXkbMW-U-zJpnGnnv6I","expiry":"2019-01-30T22:28:52.644486809+08:00"}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:

Name Type
==== ====
Google 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

开始上传Google Drive

(本地文件夹以origin,Drive文件夹以backup为例)
在web端新建一个名为backup的文件夹,新建完成后使用

1
2
3
4
5
root@Raincorn:/rclone# rclone lsd Google:
-1 2019-01-30 21:32:54 -1 backup
#这里的“Google”即为你所创建的配置名称,backup即为你刚刚新建的那个用来备份的文件夹。
root@Raincorn:/rclone# rclone copy /root/origin Google:backup
#/root/origin为源文件夹,Google:backup为配置名称+远程文件夹。

QWQ,(我不会告诉你第二步花了我5个小时,也许是主机商的锅?