两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 |
it:server:file_sync [2022-08-02 15:31] – [rsync 监控目录并同步] goldentianya | it:server:file_sync [2022-08-29 18:45] (当前版本) – goldentianya |
---|
==== 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实现目录文件实时同步]] |
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> |
[[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 |
然后执行脚本文件 ''expect path_to/deploy.exp'' | 然后执行脚本文件 ''expect path_to/deploy.exp'' |
| |
| 如果希望执行以后继续留在进程内,比如 “su -” 更换root用户,需要将 exp_continue 换成 <color #ff7f27>''%%interact%%''</color> 。 |
| |
{{tag>shell vps 文件系统}} | {{tag>shell vps 文件系统}} |