UNIT16 Auto http&ftp&rsync

.ftp命令自动传输

1.手动FTP

ftp ftp.kernel.org

anonymous

zcs@example.com

cd pub

get README

quit

2.半自动FTP

#cat getreadme.ftp

ftp ftp.kernel.org

anonymous

zcs@example.com

cd pub

get README

quit

#ftp ftp.kernel.org < getreadme.ftp

ftp等待键盘输入密码

读取到zcs@example.com时显示?Invalid command。

2.全自动FTP

cat .netrc(提供用户名密码)

Default login anonymous password zcs@example.com

ftp ftp.example.com < getreadme.ftp

.wget用法详解

wget是一个命令行工具,用于批量下载文件,支持HTTP和FTP。

#wget http://server1/pub/dns.tar.gz -o /tmp/dns.tar.gz

#wget -r http://place.your.url/here(下载整个站点,-r=--recursive)

只下载一类文件

#wget -m --reject=gif http://target.web.site/subdirectory

用wget下载整个网站

wget -r -p  -np  -k \

http://sources.redhat.com/gdb/current/onlinedocs/gdb_toc.html

# 或者wget -m http://www.tldp.org/LDP/abs/html/

断点续传是自动的

# wget -c http://the.url.of/incomplete/file (-c=--continue)

批量下载

#wget -F -i download.txt(-F=--force-html;-i file1等价于--input-file=file1)

.Rsync+SSH+cron自动异地加密备份

1.首先要先对192.168.0.3RsyncServer on起来...

#chkconfig rsync on

#vi sync

rsync -avlR --delete -e ssh 192.168.0.3:/var/lib/mysql /backup

rsync -avlR --delete -e ssh 192.168.0.3:/var/www/html /backup

# chmod 700 sync && ./sync

receiving file list ... done...donewrote 16 bytes read 107 bytes 82.00

bytes/sectotal size is 0 speedup is 0.00receiving file list ...

done...donewrote 16 bytes read 921 bytes 624.67 bytes/sectotal size is 308331 speedup is 329.06

2.ssh参数意义如下

-a, --archive

It is a quick way of saying you want recursion and want to preserve almost everything.

-l, --links

When symlinks are encountered, recreate the symlink on the destination.

-R, --relative

Use relative paths. 保留相对路径...才不会让子目录跟 parent 挤在同一层...

--delete

是指如果Server端删除了一文件,那客户端也相应把这一文件删除,保持真正的一致。

-e ssh

建立起加密的连接。

.RSYNC同步/备份

rsync服务器默认以Xinetd运行,还可常驻模式(daemon)运行,若一台主机以daemon模式运行rsync,一般称其为rsync服务器。rsync的C/S方式运行方式概述如下:用户验证由服务器负责,用户口令文件在默认配置文件/etc/rsyncd.conf中指明。

1.服务器端配置# vi /etc/rsyncd.conf

uid = nobody

gid = nobody

use chroot = yes

max connections = 4

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsync.lock

log file = /var/log/rsyncd.log

[root]

path = /home/sites/compshop

auth users = root

uid = root

gid = root

secrets file = /etc/rsyncd.secrets

read only = no

#chmod 600 /etc/rsyncd.conf

#vi /etc/rsyncd.secrets

root:123456

#chmod 600 /etc/rsyncd.secrets

#/usr/bin/rsync ‐‐daemon

#echo "/usr/bin/rsync ‐‐daemon" >> /etc/rc.local

#ps ‐ef | grep rsync 找出进程杀死可停止服务

2.客户端的配置

#vi /etc/rsyncd.secrets:123456(rsync服务器登录密码)

#chmod 600 /etc/rsyncd.secrets

与服务器端同步 avqz

#rsync ‐vazu –progress –delete ‐‐password‐file=/etc/rsync.secret /tmp/old root@192.168.23.102::root

3.rsync有六种不同的工作模式

拷贝本地文件。

如:rsync -a /data /backup

使用一个远程shell程序(如rsh.ssh)来实现将本地机器的内容拷贝到远程机器。

如:rsync -avz *.c 192.168.0.3:dst

使用一个远程shell程序(如rsh.ssh)来实现将远程机器的内容拷贝到本地机器。

如:rsync –avz 192.168.0.1:src/bar /data

从远程rsync服务器中拷贝文件到本地机。

如:rsync -av root@172.16.78.192::www /databack

从本地机器拷贝文件到远程rsync服务器中

如:rsync -av /databack root@172.16.78.192::www

列远程机的文件列表。

如:rsync -v rsync://172.16.78.192/www

# rsync ‐vazu –progress /home terry@192.168.100.21:/terry/

#rsync ‐vazu ‐‐progress ‐‐password‐file=/etc/rsync.secret terry@192.168.100.21:/terry/ /home

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值