需求:源端增,改均同步到目标端,源端删除,但目标端保留不删。
系统准备图形界面:(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
相关参考: