用 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
用 rsync 同步本地和服务器的文件的更多相关文章
- rsync同步本地和服务器之间的文件
同步本地文件到服务器 rsync -zvrtopg --progress --delete test -e 'ssh -p 6665' yueyao@172.16.0.99:/media/sdb/us ...
- rsync+sersync+inotify实现服务器间文件同步之一
rsync+sersync+inotify实现服务器间文件同步之一:rsync安装配置 2013年12月14日 ⁄ Linux管理, 服务器集群技术 ⁄ 共 4925字 ⁄ rsync+sersync ...
- rsync 同步多台服务器项目目录
server1:192.168.10.1server2:192.168.10.2实现server2实时同步server1的数据! ###############server1############# ...
- 本地和服务器(ubuntu)文件同步
秘钥登录远端服务器 rsync -avze 'ssh -i ./id_rsa' root@remoteIp:/xx/remotefile.txt ./localpath (./id_rsa为本地秘钥路 ...
- rsync同步数据---把左边的文件全部拷贝到右边
背景,配置好了ssh 使用rsa pulbic key的方式登陆远程服务器.//ssh-keygen -t rsa -b 2048 -f andy-rsync-key -P '' https://he ...
- ubuntu 本地和服务器scp文件传输
安装 SSH(Secure Shell) 服务以提供远程管理服务 sudo apt-get install ssh SSH 远程登入 Ubuntu 机 ssh username@192.168.0.1 ...
- 本地读取服务器Xml文件及本地读本地的xml
updateUrl="ServerUrl"(服务器路径) WebClient wc = new WebClient(); Stream stream = wc.OpenRead(u ...
- xftp实现本地与服务器的文件上传下载(windows)
背景: Jemter环境搭建,需上传下载服务器文件到aws服务器上,由于secureCRT的局限性它只支持pub格式的密钥,不支持pem格式密钥,xshell是支持pem格式的,所以尝试安装xshel ...
- 使用rsync同步目录
本文描述了linux下使用rsync单向同步两个机器目录的问题. 使用rsync同步后可以保持目录的一致性(含删除操作). 数据同步方式 从主机拉数据 备机上启动的流程 同步命令: rsync -av ...
随机推荐
- Python核心编程笔记--随机数
#第一步引入模块 import random #第二步生成随机数 print random.randint(1,3);#[1,2,3]注意这里是闭区间.
- 关于java同步包中ConcurrentLinkedQueue类的深入分析与理解
一,官方描写叙述 一个基于连接节点的无界线程安全队列.这个队列的顺序是先进先出.队列头部的元素是留在队列中时间最长的,队列尾部的元素是留在队列中时间最短的.新元素被插入到元素的尾部,队列从队列的头部检 ...
- 关于 FPGA 和 外部芯片接口时序设计
在看这篇文章之前, 建议先好好读下这篇文章.http://download.csdn.net/detail/angelbosj/8013827. 因为我不太会用 VISio.要是哪位网友能告诉我.怎么 ...
- Tip插件的使用
Tip.js概述——美化弹窗插件 开源美化弹窗插件1.JavaScript原生代码2.美化网站用户界面 Tip.js插件的显示效果 Tip.js的使用方法 Tip({ str:'alert上需要弹出显 ...
- Truncate Delete 用法
Truncate /Delete Table 1.含义上都是删除表全部记录 2.Truncate 是属于数据定义语言,系统不会写每一笔记录操作事务日志,无法恢复记录数据的操作 Truncate Ta ...
- hive j简单邮件过滤
select min(call_log), a.mail_subject from (select mail_to,mail_subject from dw_user_deviler_201408 w ...
- qt检测网络连接状态【只能检测和路由器的连接,不能测试到外网的连接】
#include <QCoreApplication>#include <QDebug>#include <QTextStream>#include <QDi ...
- csapp lab2 bomb 二进制炸弹《深入理解计算机系统》
bomb炸弹实验 首先对bomb这个文件进行反汇编,得到一个1000+的汇编程序,看的头大. phase_1: 0000000000400ef0 <phase_1>: 400ef0: 48 ...
- LeetCode 1. twoSums
C++: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int, int&g ...
- jQ的自定义插件
此文运用的是优雅的Markdown而书 项目中写js时,有很多时候有需要重复利用的东西,我们可以给它们写成一个插件的形式,这样阅读性和适用性都会大大提高.最近抽个时间,好一番的研究了下 Jcrop 的 ...