你的位置:首页 > 操作系统

[操作系统]rsync实时同步文件


http://rsync.samba.org/download.html

 

[root@v01 src]# yum install git

 

[root@v01 src]# git clone git://git.samba.org/rsync.git

 

[root@v01 src]# git clone git://git.samba.org/rsync.gitInitialized empty Git repository in /usr/local/src/rsync/.git/remote: Counting objects: 25470, done.remote: Compressing objects: 100% (9736/9736), done.

 

[root@v01 local]# which rsync/usr/bin/rsync

 

[root@v01 local]# rpm -qf /usr/bin/rsync rsync-3.0.6-12.el6.x86_64

 

[root@v01 www]# rsync -a webtest/ online/[root@v01 www]# tree online/online/├── authz├── index.html└── index.php0 directories, 3 files[root@v01 www]# cd online/[root@v01 online]# ll -alltotal 24drwxr-xr-x. 3 www www 4096 May 9 12:03 .dr-xr-xr-x. 6 www www 4096 May 9 12:42 ..-rw-r--r--. 1 root root 1080 May 9 12:03 authz-rw-r--r--. 1 root root  31 May 9 11:40 index.html-rw-r--r--. 1 root root  17 May 9 10:42 index.phpdrwxr-xr-x. 6 root root 4096 May 9 12:03 .svn

 

[root@v01 www]# rsync -v webtest/* online/ #如果加*(如:webtest/*),则.xxx的隐藏文件不会被同步authzindex.htmlindex.phpsent 1315 bytes received 69 bytes 2768.00 bytes/sectotal size is 1128 speedup is 0.82[root@v01 www]# cd online/[root@v01 online]# lsauthz index.html index.php[root@v01 online]# ll -alltotal 20drwxr-xr-x. 2 root root 4096 May 9 12:51 .dr-xr-xr-x. 6 www www 4096 May 9 12:50 ..-rw-r--r--. 1 root root 1080 May 9 12:51 authz-rw-r--r--. 1 root root  31 May 9 12:51 index.html-rw-r--r--. 1 root root  17 May 9 12:51 index.php