系统间复制文档
windows和Linux之间传输
xftp工具
直接拉取
xshell
Linux服务器安装
lrzsz
软件包。该方式传输速度比ftp慢。
#安装iotop[root@server ~ 16:01:10]# yum install -y iotop#iotop查看下载用户/传输等[root@server ~ 16:01:10]# iotopTotal DISK READ : 0.00 B/s | Total DISK WRITE : 91.59 M/sActual DISK READ: 0.00 B/s | Actual DISK WRITE: 264.54 M/sTID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND 8408 be/4 root 0.00 B/s 0.00 B/s 0.00 % 4.14 % [kworker/u256:2]8596 be/4 root 0.00 B/s 47.48 M/s 0.00 % 0.00 % sftp-server8605 be/4 root 0.00 B/s 44.12 M/s 0.00 % 0.00 % sftp-server1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % systemd -~ialize 222 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd]
Linux之间传输
scp命令
scp 命令缺点:不管目的位置是否有文件,总是再复制一次,可以理解为全量备份。缺少比对功能。
#client复制server的文件过来[root@client ~ 16:32:32]# scp root@server:/root/etc.tar.bz2 .root@server's password: etc.tar.bz2 100% 10MB 77.3MB/s 00:00 [root@client ~ 16:33:09]# ls etc*etc.tar.bz2# 复制多个文件[root@client ~ 16:37:55]# scp root@server:/root/{etc.tar.gz,etc.tar.xz} .root@server's password: etc.tar.gz 100% 12MB 76.6MB/s 00:00 root@server's password: etc.tar.xz 100% 8485KB 88.5MB/s 00:00 #复制目录不加-r报错[root@client ~ 16:39:36]# scp root@server:/etc/eeedir/ .root@server's password: scp: /etc/eeedir: not a regular file# 复制目录,使用 -r 选项[root@client ~ 16:41:10]# scp -r root@server:/etc/eeedir/ .root@server's password: 1.txt 100% 0 0.0KB/s 00:00 2.txt 100% 0 0.0KB/s 00:00 # 上传,如果路径没有写,表示相对用户家目录。这里是上传到root用户家目录/root,root@server加上冒号:[root@client ~ 16:42:48]# scp etc.tar.bz2 root@server:root@server's password: etc.tar.bz2 100% 10MB 108.4MB/s 00:00
rsync命令
Rsync具有本地与远程两台主机之间的数据快速复制同步镜像、远程备份等功能,该功能类似scp,但是优于scp功能,还具有本地不同分区目录之间全量及增量复制数据。
Rsync同步数据镜像时,通过“quick check”算法,仅同步大小或最后修改时间发生变化的文件或目录,当然也可以根据权限,属主等属性变化的同步,所以可以实现快速同步。
前提:客户端和服务端都要提前安装好
rsync
软件包。
# 准备文件[root@client ~ 17:01:01]# mkdir Pictures[root@client ~ 17:01:07]# touch Pictures/snap{1..5}.jpg# 首次同步[root@client ~ 17:01:13]# rsync -av Pictures root@server:root@server's password: sending incremental file listPictures/Pictures/snap1.jpgPictures/snap2.jpgPictures/snap3.jpgPictures/snap4.jpgPictures/snap5.jpgsent 351 bytes received 115 bytes 84.73 bytes/sectotal size is 0 speedup is 0.00# 再次同步[root@client ~ 17:01:26]# rsync -av Pictures root@server:root@server's password: sending incremental file listsent 153 bytes received 17 bytes 68.00 bytes/sectotal size is 0 speedup is 0.00# 更新部分文件时间戳,再同步[root@client ~ 17:01:36]# touch Pictures/snap{1,2}*[root@client ~ 17:03:00]# rsync -av Pictures root@server:root@server's password: sending incremental file listPictures/snap1.jpgPictures/snap2.jpgsent 239 bytes received 55 bytes 84.00 bytes/sectotal size is 0 speedup is 0.00# 删除 SRC 中文件,默认不会同步删除DEST中文件[root@client ~ 17:03:07]# rm -f Pictures/snap5.jpg[root@client ~ 17:03:59]# rsync -av Pictures root@server:root@server's password: sending incremental file listPictures/sent 147 bytes received 20 bytes 66.80 bytes/sectotal size is 0 speedup is 0.00# 使用选项 --delete 同步删除 DEST 中文件[root@client ~ 17:04:05]# rsync -av Pictures root@server: --deleteroot@server's password: sending incremental file listdeleting Pictures/snap5.jpgsent 144 bytes received 39 bytes 73.20 bytes/sectotal size is 0 speedup is 0.00