linux7实现增量同步目录

89 篇文章 4 订阅

需求:源端增,改均同步到目标端,源端删除,但目标端保留不删。

系统准备图形界面:(freefilesync必须要求带图形环境)

yum groupinstall "X Window System" -y
yum groupinstall "GNOME Desktop" -y
​​​​​​​systemctl set-default graphical.target
reboot

vi /etc/selinux/config

disabled

setenforce 0

systemctl stop firewalld

systemctl disable firewalld

准备同步软件:

yum install wget
wget https://freefilesync.org/download/FreeFileSync_11.15_Linux.tar.gz
./FreeFileSync_11.15_Install.run 

启用图形界面生成批处理文件

xshell方式或本地起图形

cd /opt/FreeFileSync/
./FreeFileSync  

注意选择图中勾选的。

 配置系统定时任务:

vi /etc/crontab

*/2 * * * * root DISPLAY=:0 /root/s220.sh > /root/s220.log 2>&1

vi /root/s220.sh

#!/bin/sh
export DISPLAY=:0
sersync="/opt/FreeFileSync/FreeFileSync"
confxml="/root/bak220"
status=`ps aux |grep 'FreeFileSync'|grep -v 'grep'|wc -l`
#if [[$status=0] || [$status=1] || [$status=2] || [$status=3]];then
if [ $status -gt 0 ];then
exit 0
else
$sersync $confxml
fi

tail -f /var/log/cron查看任务日志

tail -f /root/s200.log看是否有报错日志 

检查源目录和目标目录文件是否正常同步即可。

遇到的问题:

注意注意如果不是图形系统,crontab的任务脚本启动报错:

FreeFileSync Error: Unable to initialize GTK+, is DISPLAY set properly

相关参考:

centos上freefilesync与定时任务 - 阳光宝贝-沐沐 - 博客园

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值