|
使用下面的 rsync 命令复制多个文件到远程服务器。
# rsync -avz /home/daygeek/2g/shell-script/output.txt passwd-up.sh root@2g.CentOS.com:/opt/backup-
sending incremental file listoutput.txtpasswd-up.sh-
sent 737 bytes received 50 bytes 1574.00 bytes/sectotal size is 2537 speedup is 3.22
使用下面的 rsync 命令通过 ssh 复制单个文件到远程服务器。
# rsync -avzhe ssh /home/daygeek/2g/shell-script/output.txt root@2g.CentOS.com:/opt/backup-
sending incremental file listoutput.txt-
sent 598 bytes received 31 bytes 419.33 bytes/sectotal size is 2.47K speedup is 3.92
使用下面的 rsync 命令通过 ssh 递归地复制文件夹到远程服务器。这种方式只复制文件不包括文件夹。
# rsync -avzhe ssh /home/daygeek/2g/shell-script/ root@2g.CentOS.com:/opt/backup-
sending incremental file list./output.txtovh.shpasswd-up.shpasswd-up1.shserver-list.txt-
sent 3.85K bytes received 281 bytes 8.26K bytes/sectotal size is 9.12K speedup is 2.21
方式 5:如何在 Linux 上使用 rsync 命令和 Shell 脚本复制文件/文件夹到多个远程系统上?
如果你想复制同一个文件到多个远程服务器上,那也需要创建一个如下面那样的小 shell 脚本。
# file-copy.sh-
#!/bin/shfor server in `more server-list.txt`do rsync -avzhe ssh /home/daygeek/2g/shell-script/ root@2g.CentOS.com$server:/opt/backupdone
上面脚本的输出。
# ./file-copy.sh-
sending incremental file list./output.txtovh.shpasswd-up.shpasswd-up1.shserver-list.txt-
sent 3.86K bytes received 281 bytes 8.28K bytes/sectotal size is 9.13K speedup is 2.21-
sending incremental file list./output.txtovh.shpasswd-up.shpasswd-up1.shserver-list.txt-
sent 3.86K bytes received 281 bytes 2.76K bytes/sectotal size is 9.13K speedup is 2.21
方式 6:如何在 Linux 上使用 scp 命令和 Shell 脚本从本地系统向多个远程系统复制文件/文件夹?
在上面两个 shell 脚本中,我们需要事先指定好文件和文件夹的路径,这儿我做了些小修改,让脚本可以接收文件或文件夹作为输入参数。当你每天需要多次执行复制时,这将会非常有用。
# file-copy.sh-
#!/bin/shfor server in `more server-list.txt`doscp -r $1 root@2g.CentOS.com$server:/opt/backupdone
输入文件名并运行脚本。
# ./file-copy.sh output1.txt-
output1.txt 100% 3558 3.5KB/s 00:00output1.txt 100% 3558 3.5KB/s 00:00
方式 7:如何在 Linux 系统上用非标准端口复制文件/文件夹到远程系统?
如果你想使用非标准端口,使用下面的 shell 脚本复制文件或文件夹。 (编辑:清远站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|