rsync的helloworld

http://blog.leezhong.com/project/2010/12/13/inotify-rsync.html
这个写得不对
rsync -av --progress  --include=kk  --exclude='*' --password-file=/etc/rsyncd.secrets /opt/backuptest/ [email protected]::test
include必须写在exclude前面才起作用,要不就是exclude的*把所有的都覆盖了

inotify+rsync实时同步

-a          相当于 -rlptgoD 的集合
-u          等同于 --update,在目标文件比源文件新的情况下不更新
-v          显示同步的文件
--progress  显示文件同步时的百分比进度、传输速率
--delete    删除目标目录中多于源目录的文件

参考http://wandering.blog.51cto.com/467932/105113
注意:
1.启动用rsync --daemon
2.一定要注意结尾的/,意义不同
3.如果启动不了打开vim /etc/init.d/rsync
RSYNC_ENABLE=true

环境ubuntu11.04

vim /etc/rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 5
pid file = /var/run/rsync.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsync.log

[backup]
path = /opt/backup
ignore errors
read only = no
list = yes
auth users = haha
secrets file = /etc/rsyncd.secrets


vim /etc/rsyncd.secrets
haha:haha
root@ubuntu:~# ls -l /etc/rsyncd.secrets
-rw------- 1 root root 10 2011-05-07 13:44 /etc/rsyncd.secrets

root@ubuntu:/opt# tree
.
├── backtest
│   ├── haoning
│   ├── oo
│   └── test
└── backup
    ├── backup
    ├── oo
    └── test

2 directories, 6 files

root@ubuntu:/opt# rsync -av --progress /opt/backtest/ [email protected]::backup
Password: 
sending incremental file list
./
haoning
          16 100%    0.00kB/s    0:00:00 (xfer#1, to-check=2/4)

sent 128 bytes  received 30 bytes  28.73 bytes/sec
total size is 53  speedup is 0.34
root@ubuntu:/opt# 

root@ubuntu:/opt# tree
.
├── backtest
│   ├── haoning
│   ├── oo
│   └── test
└── backup
    ├── backup
    ├── haoning
    ├── oo
    └── test

2 directories, 7 files
root@ubuntu:/opt# 


如果用 rsync -avu --progress  --delete /opt/backtest/ [email protected]::backup
就会删除掉多余的文件
-----------------------

rsync -av --password-file=/etc/rsyncd.secrets /opt/testhao/ [email protected]::backuptest
在/etc/rsyncd.secrets中只写test的密码即可
比如服务器端是test:test
客户端则是test



你可能感兴趣的:(java,Blog,ubuntu,OO,vim)