使用unsion完成机器文件夹容灾备份
安装ocaml
wget http://caml.inria.fr/pub/distrib/ocaml-4.03/ocaml-4.03.0.tar
tar -zvxf ocaml-4.03.0.tar.gz
cd ocaml-4.03.0
./configure
make world opt
make install
安装unison
tar -zxvf unison-2.48.4.tar.gz
cd src
make UISTYLE=text
make install
在执行make install的过程中,可能会出现以下错误提示:
mv: cannot stat '/root/bin//unison': No such file or directory
make: [doinstall] Error 1 (ignored)
cp unison /root/bin/
cp: cannot create regular file '/root/bin/': Is a directory
make: *** [doinstall] Error 1
出现错误的原因在与Unison默认是将文件Copy到/root/bin目录,但Linux默认是没有该目录的,因此我们需要将生成的可执行文件unison复制到系统的PATH目录。
[root@vm1 unison-2.40.63]# cp unison /usr/local/bin
配置unsion
vi /root/.unison/rsync.prf
写入一下内容
root = /home/test1 root = /home/test2 force= /home/test1 #ignore = #batch = true repeat = 1 #retry = 3 owner = true group = true perms = -1 fastcheck = false rsync = false sshargs = -C xferbycopying = true log = true logfile = /root/.unison/unison.log confirmbigdel=false
说明如下:
两个root表示需要同步的文件夹
force表示以本地的/var/www/bbsnew文件夹为标准,将该目录同步到远端。注意,如果指定了force参数,那么unison就变成了单项同步了,也就是说会以force指定的文件夹为准进行同步.
Unison本身是可以双向同步的,但是要做到双向同步,就不要设置force参数,如果设置了force参数,就成了单项同步了,此时unison类似与sync.
Unison双向同步基本原理是:假如有A B两个文件夹,A文件夹把自己的改动同步到B,B文件夹也把自己的改动同步到A,最后A B两文件夹的内容相同,是 A B文件夹的合集.
Unison双向同步的一个缺点是,对于一个文件在两个同步文件夹中都被修改时,unison是不会去同步的,因为unison无法判断以那个为准.
ignore = Path表示忽略/sina/webdata下面的WEB-INF/tmp目录,即同步时不同步它。
batch = true,表示全自动模式,接受缺省动作,并执行
-fastcheck true表示同步时使用文件的创建时间来比较两地文件,如果这个选项为false,unison则将比较两地文件的内容.建议设置为true
log = true表示在终端输出运行信息。
logfile则指定了同时将输出写入log文件。
命令行执行
unison rsync
查看同步情况
后台运行
nohup unison rsync &
删掉后台
ps -ef|grep unison
- Redis 备份、容灾 以及高可用使用
- FTPClient的使用(二) ftp(文件夹和文件)下载,上传,复制备份
- 贝壳一键还原2.0完成,支持增量备份和还原,这里详细说明使用过程
- CentOS下使用rsync crontab搭建远程容灾备份系统
- 使用数据容灾恢复软件Acronis Backup & Recovery在几台机器上备份用户配置文件
- 在SQL Server 2005中使用OUTPUT完成数据操作时的备份
- 使用DFS和组策略完成各部门文件夹的认证及限额操作
- 如何使用 HP Backup and Recovery Manager 备份个人文件和文件夹
- 使用“ntbackup”命令通过命令行或批处理文件备份文件或文件夹的方法。
- MongoDB(自动分片+shard备份) 机器故障 (使用kill -9仿真) 稳定性测试
- 使用rsync完成内网数据备份
- 天津检验检疫局完成核心业务容灾备份系统建设
- DevOps进阶(十)Jenkins组包时解决无法删除文件夹的情况:文件夹正在使用,操作无法完成,因为其中的文件,或文件夹已在另一个程序中打开...
- 使用Putty提供的plink.exe来自动登陆一个机器并执行命令,完成后自己关闭
- 自动使用RAR备份文件夹
- 【EXPDP】不使用DIRECTORY参数完成expdp数据备份
- 使用cwRsync服务器文件夹同步备份操作记录
- 使用Go语言完成文件夹的MD5计算
- 使用innobackupex完成数据增量备份及恢复的步骤
- 使用OPENDATASOURCE访问远程机器上共享文件夹中的ACCESS、Excel数据库