• 欢迎访问db1024网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏db1024吧

Windows和Linux VPS/GDrive之间文件夹的实时单向/双向同步教程

主机教程 Liam 1年前 (2019-07-30) 771次浏览 23个评论 扫描二维码
文章目录[隐藏]

说明:一般我们同步WindowsLinux之间的文件时,常用的方法有nfs挂载,inotify + rsync同步等,有钱的或许会买成熟的storenext系统,当然后者基本上都是公司在用,storenext由于价格太贵,个人使用基本可以无视,而nfs由于兼容性问题,在实际挂载中会出现很多小问题,算是inotify + rsync使用的比较多,不过鉴于前两天水过一篇Mutagen,博主发现用来实现WindowsLinux VPS之间双向同步的时候,速度还行,资源占用都不算很大,这里就大致水下使用方法,顺便也可以结合下Rclone,间接实现不挂梯子达到WindowsGdrive双向同步的目的。

安装

Github地址:https://github.com/mutagen-io/mutagen

说明:这里Windows使用Mutagen前提条件需要OpenSSH,而Windows 10内置OpenSSH,不过貌似mutagen目前不支持默认的SSH,所以就需要我们安装一个额外的OpenSSH了,官方是推荐Git for Windows的,里面自带OpenSSH客户端,我们可以手动下载安装→传送门,也可以使用其它方法安装,这里博主就使用比较简单的Scoop命令行安装,好处就是安装和卸载都很方便。

以下方法适用于以下系统:

Windows 10 Windows Server 2012 R2 Windows Server 2012 Windows Server 2008 R2 SP1 Windows 8.1 Windows 7 SP1

这里Windows 10可以跳过12步骤;其它系统需要进行12步骤升级到PowerShell 5

1、安装.NET Framework 4.5.2

#下载地址 https://www.microsoft.com/en-us/download/details.aspx?id=42642 

2、安装Management Framework 5.1

#下载地址 https://www.microsoft.com/en-us/download/details.aspx?id=54616  ##对应的系统下载包名 #Win 2012 64位 W2K12-KB3191565-x64.msu     #Win 7和Win 2008 R2 64位 Win7AndW2K8R2-KB3191566-x64.zip     #Win 7 32位 Win7-KB3191566-x86.zip     #Win 8.1和Win 2012 R2 64位 Win8.1AndW2K12R2-KB3191564-x64.msu #Win 8.1 32位 Win8.1-KB3191564-x86.msu

都安装完成后记得重启电脑生效。

3、安装Scoop
先在电脑左下角程序搜索框输入PowerShell,然后双击Windows PowerShell工具,再使用命令:

iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

如果安装不上,可能还需要更改执行策略,使用命令:

Set-ExecutionPolicy RemoteSigned -scope CurrentUser

出现提示,选择Y即可,然后再重新执行上面的命令安装Scoop

4、安装Git

scoop install git 

5、下载Mutagen

#先在D盘根目录新建mutagen文件夹 mkdir D:mutagen #替换下面最新版的Windows二进制文件地址,查看地址:https://github.com/mutagen-io/mutagen/releases $ws = New-Object Net.WebClient $url = "https://github.com/mutagen-io/mutagen/releases/download/v0.10.0/mutagen_windows_amd64_v0.10.0.zip" #设置下载路径,默认D盘根目录mutagen文件夹 $downdir = "D:mutagenmutagen.zip" #开始下载,这里挂梯子下载貌似会快些 $ws.DownloadFile($url,$downdir) #解压文件 Expand-Archive -Path D:mutagenmutagen.zip -DestinationPath D:mutagen 

这里除了可以在PowerShell使用命令下载,还可以直接使用浏览器下载压缩包,然后在D盘新建mutagen文件夹,并解压到该文件夹即可。

同步到VPS服务器

这里我们需要先设置一个变量MUTAGEN_SSH_PATH,指向SSHSCP可执行文件目录,不然会无法识别SSH可执行文件。

$env:MUTAGEN_SSH_PATH= "$env:GIT_INSTALL_ROOTusrbin" 

比如我要同步本地D盘根目录的BACK文件夹和远程Linux服务器的/moerats文件夹,使用命令:

#双向同步,创建会话为rats,D:BACK为BACK文件夹绝对路径 D:mutagenmutagen.exe sync create --name=rats D:BACK [email protected]远程服务器ip:ssh端口:/moerats  #单向同步,创建会话为rats,D:BACK为BACK文件夹绝对路径 D:mutagenmutagen.exe sync create --name=rats -m one-way-safe D:BACK [email protected]远程服务器ip:ssh端口:/moerats

如果期间遇到提示,选择yes,第一次可能会多要你输入几次服务器密码。

同步到GDrive网盘

提示:这里挂载网盘的同步参数会比上面多个--probe-mode=assume,不然远程会不停的产生很多缓存文件。 

首先在VPS上使用rclone挂载Google Drive网盘,挂载教程→传送门,当然这里挂载OneDrive什么也是可以的,不过没啥必要,毕竟有OneDrive客户端。

接下来设置一个变量MUTAGEN_SSH_PATH,指向SSHSCP可执行文件目录,不然会无法识别SSH可执行文件。

$env:MUTAGEN_SSH_PATH= "$env:GIT_INSTALL_ROOTusrbin" 

比如我要同步本地D盘根目录的BACK文件夹和远程Linux服务器挂载Gdrive网盘的/moerats文件夹,使用命令:

#双向同步,创建会话为rats,D:BACK为BACK文件夹绝对路径 D:mutagenmutagen.exe sync create --name=rats --probe-mode=assume D:BACK [email protected]远程服务器ip:ssh端口:/moerats  #单向同步,创建会话为rats,D:BACK为BACK文件夹绝对路径 D:mutagenmutagen.exe sync create --name=rats -m one-way-safe --probe-mode=assume D:BACK [email protected]远程服务器ip:ssh端口:/moerats

如果期间遇到提示,选择yes,第一次可能会多要你输入几次服务器密码。

具体的使用命令可以查看→传送门,基本上都差不多。注意电脑每次重启后,都需要重新设置变量和创建一个同步会话,即重复同步步骤即可。

最后该方法只适合折腾玩玩,毕竟是博主瞎在折腾,也没用太久,实际效果未知,同样喜欢折腾的可以试试,反之,了解下就行了。


db1024 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Windows和Linux VPS/GDrive之间文件夹的实时单向/双向同步教程
喜欢 (1)
关于作者:
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(23)个小伙伴在吐槽
  1. Exceptional post however , I was wanting to know if you could write a litte more on this topic? I'd be very grateful if you could elaborate a little bit further. Cheers!
    web hosting providers2020-08-31 19:33 回复 Linux | 未知浏览器
  2. Currently it sounds like Expression Engine is the top blogging platform out there right now. (from what I've read) Is that what you are using on your blog?
    black mass2020-08-31 09:25 回复 Mac OS X | Chrome 66.0.3359.66
  3. Highly descriptive post, I enjoyed that a lot. Will there be a part 2?
    black mass2020-08-28 18:45 回复 Mac OS X | Chrome 66.0.3359.181
  4. Heya i'm for the first time here. I came across this board and I find It truly useful & it helped me out a lot. I hope to give something back and help others like you aided me.
    cheap flights2020-08-24 19:00 回复 Linux | Firefox浏览器 61.0
  5. Hello, I think your website might be having browser compatibility issues. When I look at your website in Ie, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, very good blog!
    cheap flights2020-08-24 18:18 回复 Mac OS X | Chrome 65.0.3325.181
  6. I every time used to read paragraph in news papers but now as I am a user of net so from now I am using net for articles, thanks to web.
    best web hosting sites2020-08-14 19:47 回复 Linux | Firefox浏览器 2.0.0.6
  7. Awesome things here. I am very happy to peer your post. Thank you so much and I am looking ahead to touch you. Will you kindly drop me a mail?
    best web hosting 20202020-08-10 06:26 回复 Mac OS X | Chrome 67.0.3396.62
  8. If you wish for to grow your knowledge only keep visiting this site and be updated with the most up-to-date information posted here.
    web hosting service2020-08-06 21:32 回复 Linux | Chrome 66.0.3359.139
  9. Your style is unique in comparison to other people I have read stuff from. Thanks for posting when you have the opportunity, Guess I will just book mark this web site.
    best web hosting 20202020-08-06 02:15 回复 Mac OS X | Chrome 67.0.3396.79
  10. I'd like to thank you for the efforts you have put in writing this website. I am hoping to view the same high-grade content by you in the future as well. In fact, your creative writing abilities has encouraged me to get my very own site now ;) adreamoftrains web hosting service
    adreamoftrains best web hosting 20202020-07-30 17:20 回复 Windows 7 | 360浏览器 SE
  11. Everyone loves what you guys are up too. Such clever work and coverage! Keep up the terrific works guys I've added you guys to my blogroll.
    skyscanner flights2020-07-29 13:53 回复 Windows 7 | Internet Explorer 10.0
  12. Thanks , I have recently been searching for information approximately this subject for ages and yours is the best I've found out so far. But, what concerning the bottom line? Are you certain concerning the source?
    air flights cheap2020-07-27 17:39 回复 Linux | Chrome 52.0.2777.35
  13. Thank you, I've recently been looking for information about this topic for ages and yours is the best I have discovered so far. However, what about the conclusion? Are you positive concerning the supply?
    website host2020-07-27 06:05 回复 Linux | Firefox浏览器 60.0.1
  14. I like what you guys are up too. This sort of clever work and coverage! Keep up the awesome works guys I've you guys to my own blogroll.
    web hosting companies2020-07-26 08:27 回复 Windows XP | 360浏览器 JK
  15. constantly i used to read smaller articles that also clear their motive, and that is also happening with this post which I am reading at this place.
    best web hosting2020-07-23 08:20 回复 Linux | Chrome 53.0.2834.76
  16. With havin so much content do you ever run into any problems of plagorism or copyright infringement? My website has a lot of exclusive content I've either created myself or outsourced but it seems a lot of it is popping it up all over the web without my permission. Do you know any methods to help prevent content from being ripped off? I'd truly appreciate it.
    web hosting reviews2020-07-22 09:23 回复 Linux | Chrome 67.0.3396.87
  17. Good day! I know this is kinda off topic however I'd figured I'd ask. Would you be interested in trading links or maybe guest writing a blog post or vice-versa? My site goes over a lot of the same topics as yours and I believe we could greatly benefit from each other. If you're interested feel free to shoot me an e-mail. I look forward to hearing from you! Fantastic blog by the way!
    best web hosting company2020-07-18 13:51 回复 Linux | Chrome 52.0.2777.35
  18. What's up, this weekend is good in support of me, because this point in time i am reading this fantastic educational paragraph here at my residence.
    cbd oil that works 20202020-06-29 04:46 回复 Linux | Chrome 65.0.3325.109
  19. If some one desires to be updated with newest technologies then he must be pay a visit this web site and be up to date daily.
    cbd oil that works 20202020-06-28 02:39 回复 Windows 8.1 | Chrome 56.0.2924.90
  20. There is certainly a lot to learn about this subject. I love all of the points you've made.
    web.xorg.cn2020-06-27 12:08 回复 未知操作系统 | Chrome 64.0.3282.167
  21. Excellent article! We will be linking to this particularly great content on our site. Keep up the good writing.
    tinyurl.com2020-06-26 23:47 回复 Linux | Chrome 66.0.3359.170
  22. you're in point of fact a good webmaster. The site loading velocity is incredible. It sort of feels that you are doing any distinctive trick. Also, The contents are masterwork. you have performed a wonderful job in this subject!
    tinyurl.com2020-06-26 13:49 回复 Linux | Chrome 65.0.3325.181
  23. Informative article, exactly what I wanted to find.
    rsacwgxy g2020-06-23 18:40 回复 未知操作系统 | Chrome 64.0.3282.167