rsync包装使同步变得容易

zyklop的Python项目详细描述


这个程序是rsync的包装器。它将帮助您:

  • if you need to sync files from remote server frequently
  • No need to keep the location of the file in your mind. It finds them for you.

要求

  • Python >= 2.6 (Python >= 2.7 for tests)
  • rsync installed
  • locate installed with up-to-date database on the remote system

第一步

如果您是ssh新手,请先设置ssh配置。如果你是 处理很多服务器,给它们一个别名使它们更容易 记住,你不必打字那么多。

  1. Create an ssh configuration in your SSH home, e.g.:

    vim ~/.ssh/config
    

    You can use the following example as a starter:

    Host spameggs
    Hostname  12.112.11.122
    Compression yes
    CompressionLevel 9
    User guido
    

    but be sure to check the documentation or the man page (5) for ssh_config

  2. Make the config only readable for the owner:

    chmod 600 ~/.ssh/config
    
  3. Test if you can login to your configured host using only your alias:

    ssh spameggs
    

示例

  1. Syncing ZODB from remote server configured in ^{tt1}$ as spameggs. We choose not the first database, but the second:

    $ zyklop spameggs:Data.fs .
    Use /opt/otherbuildout/var/filestorage/Data.fs? Y(es)/N(o)/A(bort) n
    Use /opt/buildout/var/filestorage/Data.fs? Y(es)/N(o)/A(bort) y
    
  2. Syncing a directory providing a path segment:

    $ zyklop spameggs:buildout/var/filestorage$ .
    
  3. Syncing a directory which ends with blobstorage`, excluding any other blobstorage directories with postfixes in the name (e.g. blobstorage.old):

    $ zyklop spameggs:blobstorage$ .
    
  4. Use an absolute path if you know exactly where to copy from:

    $ zyklop spameggs:/tmp/Data.fs .
    
  5. Syncing a directory which needs higher privileges. We use the ^{tt2}$ argument:

    $ zyklop -s spameggs:blobstorage$ .
    
  6. Dry run prints out all found remote paths and just exits:

    $ zyklop -d spameggs:blobstorage$ .
    /opt/otherbuildout/var/blobstorage
    /opt/otherbuildout/var/blobstorage.old
    /opt/buildout/var/blobstorag
    
  7. Sync the first result zyklop finds automatically without prompting:

    $ zyklop -y spameggs:blobstorage$ .
    

已知问题

Zyklop只是挂了起来

这可能是paramiko和ssh设置不充分造成的。制造 只需发出a:

ssh myhost

如果这不能解决你的问题,试着提供一个绝对的路径 从源头上。有时用户对 远程服务器和paramiko只等待远程服务器的输出 命令:

zyklop myhost:/path/to/file .

动机

我大部分时间都在和zope服务器打交道。他们中的一些人 hugedata.fs-一个面向对象的数据库。我有99%的 在我的电脑上安装旧版本的客户端数据库。 整个数据库要花我很多时间。使用rsync并简单地下载 二进制补丁使得更新本地数据库变得很快。

总而言之,对于zyklop,我想谈两件事:

  1. Downloading large ZODBs takes a long time and bandwidth. I simply don’t want to wait that long and download that much.
  2. Most of the time I can not remember the exact path where the item to copy is on the remote server.

待办事项

  • tty support: sometimes needed if SSH is configured to only allow tty’s to connect.
  • Don’t hang if only password auth is configured for SSH

开发

如果您对黑客感兴趣,请在github上克隆zyklop:

https://github.com/romanofski/zyklop

更改

0.5.2(2013-02-12)

  • Bugfix: use one function to retrieve the username.

0.5.1(2013-02-12)

  • Command line utility now shows version information.
  • Bugfix: now uses the ‘user’ configured in the ssh config and falls back to the environment user

0.5(2013-02-06)

  • Added -d or –dry-run switch to only print out found remote paths by zyklop
  • Added -y or –assume-yes switch to sync the first result found.
  • Fixed b0rked README.rst

0.4(2013-02-05)

  • Improved documentation
  • Fixed bug, which lead to a hanging command when issuing a remote command in order to find the target path

0.3(2013-01-14)

  • Changed host, match parameters: Now you can specify the source host and path match in one parameter delimited by a column, similar to scp (e.g. foohost:/path)
  • Allow to provide an absolute path to the file you’d like to copy.

0.2(2012-03-08)

  • Added basic support for using sudo in finding and syncing (rsync)
  • Added argparse as dependency as Python 2.6 won’t have it
  • New positional argument to provide destination to copy file/directory

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaPax考试:从非标准Maven存储库解析Karaf特性存储库(XML文件)   java Spring启动Bean创建异常   java中将ArrayList转换为数组的方法   Android Studio的java Unity插件。   java在CheckStyle中从方法计数中排除getter和setter   HibernateJava。sql。SQLSyntaxErrorException:表/视图“序列”不存在   与命令行程序Java vs C通信   java WebView膨胀异常   java在O(n)java8流中寻找两个列表的交集   java使用Gradle运行单元测试时,最大堆大小在哪里设置?   ssl加载java应用程序(CXF)内的jks文件   CI:Jenkins Git:Simple Java项目:希望在特定时间在脚本上发送消息   java根据位置更改数字   java按数值排序字符串数组   macos java版本“1.6.0_65”是否与java 6模棱两可?   Cassandra中的java时间戳