保持远程目录为最新 [英] Keep Remote Directory Up-to-date

查看:183
本文介绍了保持远程目录为最新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我绝对喜欢 Winscp .不幸的是,我找不到在OS X或Linux中使用起来那么简单的东西.我知道可以使用 changedfiles rsync ,但是我一直发现这两种工具的教程都缺乏和/或矛盾.

I absolutely love the Keep Remote Directory Up-to-date feature in Winscp. Unfortunately, I can't find anything as simple to use in OS X or Linux. I know the same thing can theoretically be accomplished using changedfiles or rsync, but I've always found the tutorials for both tools to be lacking and/or contradictory.

我基本上只需要一个可以在OSX或Linux上运行的工具,并在更改本地目录时使远程目录与本地目录保持同步(镜像).

I basically just need a tool that works in OSX or Linux and keeps a remote directory in sync (mirrored) with a local directory while I make changes to the local directory.

更新

通过这些解决方案,我看到了一对夫妇,它们解决了使远程目录与本地目录保持手动同步的一般问题.我知道我可以将cron任务设置为每分钟运行rsync,这应该非常接近实时.

Looking through the solutions, I see a couple which solve the general problem of keeping a remote directory in sync with a local directory manually. I know that I can set a cron task to run rsync every minute, and this should be fairly close to real time.

这不是我一直在寻找的确切解决方案,因为winscp会执行此操作以及更多操作:它检测目录中的文件更改(当我处理它们时),然后自动将更改推送到远程服务器.我知道这不是最好的解决方案(没有代码存储库),但是它允许我在开发服务器时非常快速地在服务器上测试代码.有谁知道如何将rsync与任何其他命令结合使用以获得此功能?

This is not the exact solution I was looking for as winscp does this and more: it detects file changes in a directory (while I work on them) and then automatically pushes the changes to the remote server. I know this is not the best solution (no code repository), but it allows me to very quickly test code on a server while I develop it. Does anyone know how to combine rsync with any other commands to get this functionality?

推荐答案

您希望如何实时"进行同步?我仍然倾向于rsync,因为您知道它将在两个平台(Windows,以及cygwin)上也都得到完全支持,并且可以通过cron作业运行它.我在系统上运行了一个非常简单的bash文件(这不会删除旧文件):

How "real-time" do you want the syncing? I would still lean toward rsync since you know it is going to be fully supported on both platforms (Windows, too, with cygwin) and you can run it via a cron job. I have a super-simple bash file that I run on my system (this does not remove old files):

#!/bin/sh
rsync -avrz --progress --exclude-from .rsync_exclude_remote . remote_login@remote_computer:remote_dir    

# options
#   -a  archive
#   -v  verbose
#   -r  recursive
#   -z  compress 

您最好的选择是进行设置并尝试一下. -n (--dry-run)选项是您的朋友!

Your best bet is to set it up and try it out. The -n (--dry-run) option is your friend!

请记住,rsync(至少在cygwin中)不支持Unicode文件名(截至2008年8月16日).

Keep in mind that rsync (at least in cygwin) does not support unicode file names (as of 16 Aug 2008).

这篇关于保持远程目录为最新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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