• 用 rsync 同步本地和服务器的文件


    参考 DigitalOcean

    安装

    For Debian/Ubuntu:

    sudo apt-get install rsync
    

    For OpenSUSE/Fedora:

    sudo yum install rsync
    

    本地同步

    dir1 内的文件 同步到 dir2

    rsync -anv dir1/ dir2
    

    上面斜杠 / 表示同步 dir1 内部的文件而不是 dir1 这个文件夹,去掉 / 会导致整个 dir1 文件夹同步到 dir2/ 下,也就是 dir2/dir1

    参数 a 表示 all,参数 v 表示 verbose,参数 n 表示 dry run

    远程同步

    本地同步到远程服务器:

    rsync -av /path/to/local_dir username@remote_host:/path/to/destination_directory
    

    远程服务器同步到本地:

    rsync -av username@remote_host:/path/to/remote_dir path/to/local_directory
    

    一些有用的参数

    同步过程中进行压缩以加快同步速度 -z

    rsync -az source destination
    

    显示传播进度条 -P

    rsync -azP source destination
    

    进度显示如下:

    sending incremental file list
    ./
    file1
               0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=99/101)
    file10
               0 100%    0.00kB/s    0:00:00 (xfer#2, to-check=98/101)
    file100
               0 100%    0.00kB/s    0:00:00 (xfer#3, to-check=97/101)
    file11
               0 100%    0.00kB/s    0:00:00 (xfer#4, to-check=96/101)
    . . .
    

    过滤不需要同步的文件 --exclude=

    rsync -a --exclude=pattern_to_exclude source destination
    

    删除目标文件:

    rsync -a --delete source destination
    

    过滤中包含回需要的文件 --include=

    rsync -a --exclude=pattern_to_exclude --include=pattern_to_include source destination
    
  • 相关阅读:
    VuGen错误处理函数
    LR的日志
    创建性能测试脚本时如何选择HTML模式和URL模式
    Java变量
    查找&排序
    selenium执行JS
    Python中 is 和 == 的区别
    Python中 and or的计算规则
    selenium使用location定位元素坐标偏差
    错误:Could not find an available JavaScript runtime
  • 原文地址:https://www.cnblogs.com/youngdze/p/4174582.html
Copyright © 2020-2023  润新知