<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<title>Eric&#039;s Blog - Onedrive网盘</title>
<link>https://eblog.ink/category/Onedrive%E7%BD%91%E7%9B%98/</link>
<atom:link href="https://eblog.ink/feed/category/Onedrive%E7%BD%91%E7%9B%98/" rel="self" type="application/rss+xml" />
<language>zh-CN</language>
<description></description>
<lastBuildDate>Sun, 30 Aug 2020 02:09:00 +0000</lastBuildDate>
<pubDate>Sun, 30 Aug 2020 02:09:00 +0000</pubDate>
<item>
<title>Onedrive+OneManager+Heroku+CFWorkers 羊毛衫新织法</title>
<link>https://eblog.ink/archives/244/</link>
<guid>https://eblog.ink/archives/244/</guid>
<pubDate>Sun, 30 Aug 2020 02:09:00 +0000</pubDate>
<dc:creator>eric</dc:creator>
<description><![CDATA[Demo，不放。网站下载链接直接是xxx.com/abc.jpg，没有302跳到微软xxx.sharepoint.com，也没有反代xxx.sharepoint.com那样后面一长串。准备工作：...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<p>Demo，不放。<br>网站下载链接直接是xxx.com/abc.jpg，没有302跳到微软xxx.sharepoint.com，也没有反代xxx.sharepoint.com那样后面一长串。</p><p>准备工作：<br>1，        Onedrive，或Sharepoint<br>这个大家有的，各种A1，E3，E5，世纪。（Sharepoint默认25T）<br>2，        OneManager，Github地址：<a href="https://github.com/qkqpttgf/OneManager-php">https://github.com/qkqpttgf/OneManager-php</a><br>基于各种无服务器的平台，比如Heroku、腾讯SCF、阿里FC、华为FG、百度CFC，配置都保存在其环境变量中，当然也可以装在VPS与空间里，不过为了一致，程序不固定储存onedrive的目录结构，缓存最多1小时<br>3，        Heroku，最好需要注册2个帐号，注册与登录时需要魔法，平时操作时不需要<br>OneManager配置是保存在环境变量中的，所以不需要一直监控保活，Heroku免费套餐每月550小时，550小时/30天=18.33小时，每天只要访问时间段空出来24-18=6小时没有人访问，这一个月其实就足够使用了，但有些人的网站可能访问人比较多所以还没到月底就用光了。<br>当然，heroku也可绑卡达到1000小时，同时还能自定义域名。但，SSL却比较麻烦。<br>4，        CF workers，免费的就好</p><p>部署程序、安装程序、绑定网盘：<br>1，        将OneManager一键部署到Heroku<br>2，        访问给定的herokuapp域名，正式安装好程序<br>3，        安装好后登录，在设置中绑定Onedrive或Sharepoint<br>4，        在设置中做些设定<br>5，        换一个Heroku帐号再安装一次（时长够用就无所谓）</p><p>重点：<br>在CF Workers中填入以下代码</p><pre><code>// 单日
const SingleDay = &#039;111.herokuapp.com&#039;
// 双日
const DoubleDay = &#039;222.herokuapp.com&#039;
// 一切给CF代理，true/false
const CFproxy = true

// 由于heroku不绑卡不能自定义域名，就算绑卡后https也不方便
// 另外免费套餐每月550小时，有些人不够用
// 于是在CF Workers使用此代码，分单双日拉取不同heroku帐号下的相同网页
// 只改上面，下面不用动

addEventListener(&#039;fetch&#039;, event =&gt; {
    let nd = new Date();
    if (nd.getDate()%2) {
        host = SingleDay
    } else {
        host = DoubleDay
    }
    if (!CFproxy) {
        let url=new URL(event.request.url);
        if (url.protocol == &#039;http:&#039;) {
            url.protocol = &#039;https:&#039;
            response = Response.redirect(url.href);
            event.respondWith( response );
        } else {
            url.hostname=host;
            let request=new Request(url,event.request);
            event.respondWith( fetch(request) )
        }
    } else {
        event.respondWith( fetchAndApply(event.request) );
    }
})

async function fetchAndApply(request) {
    let response = null;
    let url = new URL(request.url);
    if (url.protocol == &#039;http:&#039;) {
        url.protocol = &#039;https:&#039;
        response = Response.redirect(url.href);
        return response;
    }
    url.host = host;

    let method = request.method;
    let body = request.body;
    let request_headers = request.headers;
    let new_request_headers = new Headers(request_headers);

    new_request_headers.set(&#039;Host&#039;, url.host);
    new_request_headers.set(&#039;Referer&#039;, request.url);

    let original_response = await fetch(url.href, {
        method: method,
        body: body,
        headers: new_request_headers
    });

    response = new Response(original_response.body, {
        status: original_response.status,
        headers: original_response.headers
    })

    return response;
}
</code></pre><p>单双日分别填入不同的heroku帐号下的网站（当然2个网站要设置得一模一样），这样每个heroku帐号每个月都只访问15或16天，就算24小时有人访问也才360或384小时。<br>最后，给workers加上自定义域名的路由！</p><p>从头到尾都可以是Free的，不看网站页面，光从下载过程来看，可以完全假装CF套在了大盘鸡上,谁也看不出我没服务器.</p><p><a href="https://www.hostloc.com/thread-737360-1-1.html">原文链接</a></p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://eblog.ink/archives/244/#comments</comments>
<wfw:commentRss>https://eblog.ink/feed/category/Onedrive%E7%BD%91%E7%9B%98/</wfw:commentRss>
</item>
<item>
<title>使用 rclone 将 Google Drive 文件同步至 OneDrive</title>
<link>https://eblog.ink/archives/234/</link>
<guid>https://eblog.ink/archives/234/</guid>
<pubDate>Fri, 10 Jul 2020 02:45:00 +0000</pubDate>
<dc:creator>eric</dc:creator>
<description><![CDATA[Google 虽然是大厂，但是数据只有一份，还是怕怕，多一个备份不是坏事。苹果 iCloud 不错，但是贼贵，况且我只有一个进过水的 SE……那就 OneDrive 吧，Office 365 就...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<p>Google 虽然是大厂，但是数据只有一份，还是怕怕，多一个备份不是坏事。苹果 iCloud 不错，但是贼贵，况且我只有一个进过水的 SE……</p><p>那就 OneDrive 吧，Office 365 就有 1T，前阵子在老司机群看到博友合租 Office 365 家庭套餐，还挺划算的，于是就上车了。</p><p>1.1 rclone 安装<br>执行命令：curl <a href="https://rclone.org/install.sh">https://rclone.org/install.sh</a> | sudo bash</p><p>1.2 连接网盘<br>连接 Google Drive，执行命令进入配置菜单：rclone config</p><p>1.3 初次进入会有如下菜单提示：</p><pre><code>#~:rclone config
No remotes found - make a new one
n) New remote -&gt; 连接新远程网盘
s) Set configuration password -&gt; 设置密码保护配置信息
q) Quit config -&gt; 退出
n/s/q&gt;
</code></pre><p>1.4 需要加密码保护配置信息就按 s 进入设置密码，若不需要，按 n 进入连接网盘。</p><pre><code>n/s/q&gt; n
name&gt; gdrive -&gt; 网盘名字，写一个方便自己识别的名字就好
Type of storage to configure.
Enter a string value. Press Enter for the default (&quot;&quot;).
Choose a number from below, or type in your own value
 1 / Alias for a existing remote
   \ &quot;alias&quot;
 2 / Amazon Drive
   \ &quot;amazon cloud drive&quot;
 3 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
   \ &quot;s3&quot;
 4 / Backblaze B2
   \ &quot;b2&quot;
 5 / Box
   \ &quot;box&quot;
 6 / Cache a remote
   \ &quot;cache&quot;
 7 / Dropbox
   \ &quot;dropbox&quot;
 8 / Encrypt/Decrypt a remote
   \ &quot;crypt&quot;
 9 / FTP Connection
   \ &quot;ftp&quot;
10 / Google Cloud Storage (this is not Google Drive)
   \ &quot;google cloud storage&quot;
11 / Google Drive
   \ &quot;drive&quot;
12 / Hubic
   \ &quot;hubic&quot;
13 / JottaCloud
   \ &quot;jottacloud&quot;
14 / Local Disk
   \ &quot;local&quot;
15 / Mega
   \ &quot;mega&quot;
16 / Microsoft Azure Blob Storage
   \ &quot;azureblob&quot;
17 / Microsoft OneDrive
   \ &quot;onedrive&quot;
18 / OpenDrive
   \ &quot;opendrive&quot;
19 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ &quot;swift&quot;
20 / Pcloud
   \ &quot;pcloud&quot;
21 / QingCloud Object Storage
   \ &quot;qingstor&quot;
22 / SSH/SFTP Connection
   \ &quot;sftp&quot;
23 / Webdav
   \ &quot;webdav&quot;
24 / Yandex Disk
   \ &quot;yandex&quot;
25 / http Connection
   \ &quot;http&quot;
Storage&gt; 11 -&gt; 11 是 Google Drive
Google Application Client Id
Leave blank normally.
Enter a string value. Press Enter for the default (&quot;&quot;).
client_id&gt; -&gt; 留空，按回车下一步就好
Google Application Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default (&quot;&quot;).
client_secret&gt; -&gt; 留空，按回车下一步就好
Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default (&quot;&quot;).
Choose a number from below, or type in your own value
 1 / Full access all files, excluding Application Data Folder.
   \ &quot;drive&quot;
 2 / Read-only access to file metadata and file contents.
   \ &quot;drive.readonly&quot;
   / 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.
   \ &quot;drive.file&quot;
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ &quot;drive.appfolder&quot;
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ &quot;drive.metadata.readonly&quot;
scope&gt; 2 -&gt; 1 是拥有所有权限，包括删除；2 是只能访问所有文件，不能删除，按需要选择吧
ID of the root folder
Leave blank normally.
Fill in to access &quot;Computers&quot; folders. (see docs).
Enter a string value. Press Enter for the default (&quot;&quot;).
root_folder_id&gt; -&gt; 留空，按回车下一步就好
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 (&quot;&quot;).
service_account_file&gt; -&gt; 留空，按回车下一步就好
Edit advanced config? (y/n)
y) Yes
n) No
y/n&gt; n -&gt; 一般不需要高级设置，选择 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&#039;t work
y) Yes
n) No
y/n&gt; n -&gt; 如果是在 VPS 上连接，选 n 吧
If your browser doesn&#039;t open automatically go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=offline&amp;client_id=**************************************
Log in and authorize rclone for access
Enter verification code&gt; **************zN5****vd5*******************bwZethESs
Configure this as a team drive?
y) Yes
n) No
y/n&gt; n
--------------------
[remote]
client_id = 
client_secret = 
scope = drive
root_folder_id = 
service_account_file =
token = {&quot;access_token&quot;:&quot;XXX&quot;,&quot;token_type&quot;:&quot;Bearer&quot;,&quot;refresh_token&quot;:&quot;XXX&quot;,&quot;expiry&quot;:&quot;2018-09-16T13:57:58.955387075Z&quot;}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d&gt; y
</code></pre><p>1.5 Google Drive 连接完成，可以执行命令检查一下是否真的能连接上：</p><pre><code>#列出顶级文件夹，（gdrive 是前面第一步设置的名字，如果配置设置了密码会提示输入密码）
rclone lsd gdrive:

#列出所有文件
rclone ls gdrive:
</code></pre><p>1.6 连接 OneDrive，方法类似，命令进入配置：rclone config</p><pre><code>#~:rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q&gt; n
name&gt; onedrive
Type of storage to configure.
Enter a string value. Press Enter for the default (&quot;&quot;).
Choose a number from below, or type in your own value
 1 / Alias for a existing remote
   \ &quot;alias&quot;
 2 / Amazon Drive
   \ &quot;amazon cloud drive&quot;
 3 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
   \ &quot;s3&quot;
 4 / Backblaze B2
   \ &quot;b2&quot;
 5 / Box
   \ &quot;box&quot;
 6 / Cache a remote
   \ &quot;cache&quot;
 7 / Dropbox
   \ &quot;dropbox&quot;
 8 / Encrypt/Decrypt a remote
   \ &quot;crypt&quot;
 9 / FTP Connection
   \ &quot;ftp&quot;
10 / Google Cloud Storage (this is not Google Drive)
   \ &quot;google cloud storage&quot;
11 / Google Drive
   \ &quot;drive&quot;
12 / Hubic
   \ &quot;hubic&quot;
13 / JottaCloud
   \ &quot;jottacloud&quot;
14 / Local Disk
   \ &quot;local&quot;
15 / Mega
   \ &quot;mega&quot;
16 / Microsoft Azure Blob Storage
   \ &quot;azureblob&quot;
17 / Microsoft OneDrive
   \ &quot;onedrive&quot;
18 / OpenDrive
   \ &quot;opendrive&quot;
19 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ &quot;swift&quot;
20 / Pcloud
   \ &quot;pcloud&quot;
21 / QingCloud Object Storage
   \ &quot;qingstor&quot;
22 / SSH/SFTP Connection
   \ &quot;sftp&quot;
23 / Webdav
   \ &quot;webdav&quot;
24 / Yandex Disk
   \ &quot;yandex&quot;
25 / http Connection
   \ &quot;http&quot;
Storage&gt; 17
Microsoft App Client Id
Leave blank normally.
Enter a string value. Press Enter for the default (&quot;&quot;).
client_id&gt;
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default (&quot;&quot;).
client_secret&gt;
Edit advanced config? (y/n)
y) Yes
n) No
y/n&gt; n
Remote config
Choose OneDrive account type?
 * Say b for a OneDrive business account -&gt; b 商业版
 * Say p for a personal OneDrive account -&gt; p 个人版
b) Business
p) Personal
b/p&gt; p
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&gt; 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 &quot;onedrive&quot;
Then paste the result below:（需要在能打开浏览器的电脑上获取，方法见下面：OneDrive 授权码获取方法）
result&gt;{&quot;access_token&quot;:&quot;$$$$$$$$$$$$$$&quot;,&quot;expiry&quot;:&quot;2018-09-03T08:43:55.5290909+08:00&quot;}
2018/09/03 07:47:11 ERROR : Failed to save new token in config file: section &#039;onedrive&#039; not found
--------------------
[onedrive]
type = onedrive
token = {&quot;access_token&quot;:&quot;$$$$$$$$$$$$$$&quot;,&quot;expiry&quot;:&quot;2018-09-01T08:43:55.5290909+08:00&quot;}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d&gt; y
Current remotes:

Name                 Type
====                 ====
onedrive             onedrive

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&gt; q
</code></pre><p>1.7 OneDrive 授权码获取方法：</p><p>官网下载 rclone Windows 版，地址：<a href="https://rclone.org/downloads/">https://rclone.org/downloads/</a></p><p>如 Rclone Download v1.43 Windows 64 位：<a href="https://downloads.rclone.org/v1.43/rclone-v1.43-windows-amd64.zip">https://downloads.rclone.org/v1.43/rclone-v1.43-windows-amd64.zip</a>，解压到 C 盘根目录，文件夹重命名为 rc，然后参考下面方法即可获取授权。</p><pre><code>Microsoft Windows [版本 10.0.14393]
(c) 2016 Microsoft Corporation。保留所有权利。
C:\Users\Administrator&gt;cd c:\rc
c:\rc&gt;rclone authorize &quot;onedrive&quot;  -·-·- （PowerShell 可能需要使用此命令：.\rclone authorize &quot;onedrive&quot;）
Choose OneDrive account type?
 * Say b for a OneDrive business account
 * Say p for a personal OneDrive account
b) Business
p) Personal
b/p&gt; p
If your browser doesn&#039;t open automatically go to the following link: http://127.0.0.1:53682/auth
Log in and authorize rclone for access
Waiting for code...
Got code
Paste the following into your remote machine ---&gt;
{&quot;access_token&quot;:&quot;***************########################################################################################################################**************************************************************************************************************************************************************************************************************$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$&quot;,&quot;expiry&quot;:&quot;2018-09-01T01:43:55.5290909+08:00&quot;}
&lt;---End paste
</code></pre><p>然后将 { } 内的内容（包括{}）复制到前面 result&gt; 后面，回车即可。</p><p>同样，执行 ls 或者 lsd 命令检查是否连接成功：</p><pre><code>#列出顶级文件夹，（gdrive 是前面第一步设置的名字，如果配置设置了密码会提示输入密码）
rclone lsd onedrive:

#列出所有文件
rclone ls onedrive:

</code></pre><p>2.1 定时执行脚本 rclone 命令大全</p><p>如果用来备份或者同步文件，用到的命令可能就两个：rclone_copy 和 rclone_sync。</p><p>rclone_copy 是复制，配合附加参数 --ignore-existing 可以假装增量备份；</p><p>rclone_sync 是源目录同步到目标目录，使两者一致，会删除目标目录多余内容，测试时可以加上 --dry-run，检查会复制和删除那些文件。</p><pre><code>rclone about - Get quota information from the remote.
rclone authorize - Remote authorization.
rclone cachestats - Print cache stats for a remote
rclone cat - Concatenates any files and sends them to stdout.
rclone check - Checks the files in the source and destination match.
rclone cleanup - Clean up the remote if possible
rclone config - Enter an interactive configuration session.
rclone copy - Copy files from source to dest, skipping already copied
rclone copyto - Copy files from source to dest, skipping already copied
rclone copyurl - Copy url content to dest.
rclone cryptcheck - Cryptcheck checks the integrity of a crypted remote.
rclone cryptdecode - Cryptdecode returns unencrypted file names.
rclone dbhashsum - Produces a Dropbox hash file for all the objects in the path.
rclone dedupe - Interactively find duplicate files and delete/rename them.
rclone delete - Remove the contents of path.
rclone deletefile - Remove a single file from remote.
rclone genautocomplete - Output completion script for a given shell.
rclone gendocs - Output markdown docs for rclone to the directory supplied.
rclone hashsum - Produces an hashsum file for all the objects in the path.
rclone link - Generate public link to file/folder.
rclone listremotes - List all the remotes in the config file.
rclone ls - List the objects in the path with size and path.
rclone lsd - List all directories/containers/buckets in the path.
rclone lsf - List directories and objects in remote:path formatted for parsing
rclone lsjson - List directories and objects in the path in JSON format.
rclone lsl - List the objects in path with modification time, size and path.
rclone md5sum - Produces an md5sum file for all the objects in the path.
rclone mkdir - Make the path if it doesn’t already exist.
rclone mount - Mount the remote as a mountpoint. EXPERIMENTAL
rclone move - Move files from source to dest.
rclone moveto - Move file or directory from source to dest.
rclone ncdu - Explore a remote with a text based user interface.
rclone obscure - Obscure password for use in the rclone.conf
rclone purge - Remove the path and all of its contents.
rclone rc - Run a command against a running rclone.
rclone rcat - Copies standard input to file on remote.
rclone rmdir - Remove the path if empty.
rclone rmdirs - Remove empty directories under the path.
rclone serve - Serve a remote over a protocol.
rclone sha1sum - Produces an sha1sum file for all the objects in the path.
rclone size - Prints the total size and number of objects in remote:path.
rclone sync - Make source and dest identical, modifying destination only.
rclone touch - Create new file or change file modification time.
rclone tree - List the contents of the remote in a tree like fashion.
rclone version - Show the version number.
</code></pre><p>保证数据不会中断</p><pre><code>yum install screen
screen -S rclone #第一次同步大量数据使用 screen 会话尽可能保护 rclone 执行不被中断
rclone copy gdrive:GooglePhotos onedrive:GooglePhotos
</code></pre><p>第一次同步完成，就可以 VPS 上（每天/周/月，按需选择）定时执行脚本自动同步。可以选择使用 rclone_copy --ignore-existing 进行增量备份（没有实测，按官方说明是可以实现），或者使用 rclone sync 同步。</p><p>我希望 OneDrive 上的备份与 Google Drive 一致，所以每天定时执行 rclone sync gdrive:GooglePhotos onedrive:GooglePhotos</p><pre><code>/usr/bin/rclone sync gdrive:GooglePhotos onedrive:GooglePhotos &gt;&gt; /root/rclone.log 2&gt;&amp;1
</code></pre><p>配合 crontab 定时执行，比如每天 4:44 执行一次，日志写到 /root/rclone.log。执行 crontab -e，i，添加下面代码进去，按一下 Esc，然后输入 :wq 回车保存退出。</p><pre><code>44 4 * * * /usr/bin/rclone sync gdrive:GooglePhotos onedrive:GooglePhotos &gt;&gt; /root/rclone.log 2&gt;&amp;1
</code></pre><p>注：不需要日志的话把 &gt;&gt; /root/rclone.log 2&gt;&1 去掉。</p><p>然后重启一下 crond 服务即可。（service crond restart）</p><pre><code>注意：最好执行 service crond status 检查 crond 服务是否启动，service crond start 可手动启动，或者设置开机启动：chkconfig --level 35 crond on。Centos 7 x86_64 实测通过。
</code></pre><p><a href="https://cyhour.com/825/">原文链接</a></p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://eblog.ink/archives/234/#comments</comments>
<wfw:commentRss>https://eblog.ink/feed/category/Onedrive%E7%BD%91%E7%9B%98/</wfw:commentRss>
</item>
</channel>
</rss>