通过 rsync 自动同步 [英] Automatic synchronization via rsync

查看:48
本文介绍了通过 rsync 自动同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要让我的代码与虚拟机上的相同代码保持同步.有没有办法监控文件更改并自动调用 rsync 或类似的东西?

I need to keep my code synchronized with the same code on virtual machine. Is there a way to monitor file changes and automatically call rsync or something like that?

推荐答案

创建一个 shell 脚本,该脚本会在循环中调用 inotifywait 然后调用 rsync,例如:

Create a shell script that would call inotifywait then rsync in a loop, something like:

#!/bin/bash
LOCAL="/path/to/local/dir"
RSYNC_OPTIONS=...
while true
do
    inotifywait -r $LOCAL
    rsync $RSYNC_OPTIONS
done

inotifywait 是 Ubuntu 下 inotify-tools 包的一部分

inotifywait is part of the inotify-tools package under Ubuntu

这篇关于通过 rsync 自动同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆