差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
it:server:file_sync [2022-08-02 15:31] – [rsync 监控目录并同步] goldentianyait:server:file_sync [2022-08-29 18:45] (当前版本) goldentianya
行 3: 行 3:
 ==== rsync 监控目录并同步 ==== ==== rsync 监控目录并同步 ====
  
-[[https://www.ruanyifeng.com/blog/2020/08/rsync.html|rsync 用法教程]] +[[https://www.ruanyifeng.com/blog/2020/08/rsync.html|rsync 用法教程]] :-)
  
 [[https://segmentfault.com/a/1190000018024251|跨平台的fswatch+rsync同步备份]] / [[https://shadowdragons.github.io/2017/02/02/mac-rsync-fswatch/|mac使用rsync+fswatch实现目录文件实时同步]] [[https://segmentfault.com/a/1190000018024251|跨平台的fswatch+rsync同步备份]] / [[https://shadowdragons.github.io/2017/02/02/mac-rsync-fswatch/|mac使用rsync+fswatch实现目录文件实时同步]]
行 20: 行 20:
 tar -xzf aliyun.tar.gz tar -xzf aliyun.tar.gz
 </code> </code>
 +
 +**增量备份**
 +<code>
 +$ rsync -a --delete --link-dest /compare/path /source/path /target/path
 +</code>
 +
 +上面命令中,--link-dest参数指定基准目录/compare/path,然后源目录/source/path跟基准目录进行比较,找出变动的文件,将它们拷贝到目标目录/target/path。
 +
 ==== scp 脚本命令 ==== ==== scp 脚本命令 ====
 <code> <code>
行 32: 行 40:
 [[http://xstarcd.github.io/wiki/shell/expect_handbook.html|expect 中文教程]] / [[http://xstarcd.github.io/wiki/shell/expect.html|expect 自动交互脚本]] [[http://xstarcd.github.io/wiki/shell/expect_handbook.html|expect 中文教程]] / [[http://xstarcd.github.io/wiki/shell/expect.html|expect 自动交互脚本]]
 <code> <code>
- +apt-get install expect -y
-yum install -y expect +
 </code> </code>
  
 脚本 "deploy.exp" 文件 脚本 "deploy.exp" 文件
  
-<file sh dodeploy.sh>+<file dodeploy.sh>
 #!/usr/bin/expect #!/usr/bin/expect
 spawn scp -r ./libs ./resources ./dist index.js app.js jobs.js package.json <username>@<host_ip|name>:/destination_path spawn scp -r ./libs ./resources ./dist index.js app.js jobs.js package.json <username>@<host_ip|name>:/destination_path
行 51: 行 57:
 然后执行脚本文件 ''expect path_to/deploy.exp'' 然后执行脚本文件 ''expect path_to/deploy.exp''
  
 +如果希望执行以后继续留在进程内,比如 “su -” 更换root用户,需要将 exp_continue 换成 <color #ff7f27>''%%interact%%''</color>
  
 {{tag>shell vps 文件系统}} {{tag>shell vps 文件系统}}
it/server/file_sync.1659454290.txt.gz · 最后更改: 2022-08-02 15:31 由 goldentianya
回到顶部
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0