当前位置:网站首页>Realize inotify and Rsync real-time backup
Realize inotify and Rsync real-time backup
2022-06-29 20:58:00 【Brother Xing plays with the clouds】
Realization inotify coordination rsync Real time backup
( One ): The daemon mode of the server and the daemon mode of the client rsync To configure
1. Configure server rysnc vi /etc/rsyncd.conf Contents of Li uid = rsync gid = rsync use chroot = no max connections = 200 timeout = 100 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log [backup] path = /backup/ ignore errors read only = false list = false hosts allow = 199.101.117.0/24 hosts deny = 0.0.0.0/32 auth users = rsync_backup secrets file = /etc/rsync.password
## If in windows Edit or copy the code to linux You'd better use this command to handle the following Dos2unix /etc/rsyncd.conf [[email protected] backup]#mkdir /backup [[email protected] backup]#useradd rsync -s /bin/nologin –M
## Create a new account ( And configuration files uid-gid Corresponding , This account attribute cannot be logged in and has no directory ) [[email protected] backup]#chown -R rsync.rsync /oldboy
[[email protected] backup]#echo “rsync_backup:oldboy”> /etc/rsync.password
##rsync_backup Is a virtual account , At that time, the client connection will use this account and password oldboy. [[email protected] backup]#chmod 600 /etc/rsyncd.password ### Set it so that no one else can see , Because there is a password in it [[email protected] backup]#rsync --daemon
# Start the process
2. To the client configuration : Just these two steps [[email protected] ~]#echo “oldboy”>/etc/rsync.password
# This path has nothing to do with the server path , Just for the sake of standardization , The password must be the same as the service [[email protected] ~]#chmod 600 /etc/rsync.password
( Two ): Client's inotify Deploy
[[email protected] ~]#wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz [[email protected] ~]# ll /proc/sys/fs/inotify/ total 0 -rw-r--r-- 1 root root 0 Jan 21 00:34 max_queued_events -rw-r--r-- 1 root root 0 Jan 21 00:34 max_user_instances -rw-r--r-- 1 root root 0 Jan 21 00:34 max_user_watches #### Check the order ; You can see that these three descriptions support inotify, Execute the following command ( It can be copied and executed in batch ) [[email protected] ~]#tar zxf inotify-tools-3.14.tar.gz [[email protected] ~]#cd inotify-tools-3.14 [[email protected] ~]#./configure --prefix=/usr/local/inotify-tools-3.14 [[email protected] ~]#make && make install [[email protected] ~]#ln -s /usr/local/inotify-tools-3.14 /usr/local/inotify ##vps Need to install make gcc gcc++,/usr/local/inotify/bin/inotifywait --help There are many parameters in , But just remember create and delete Parameters , Used to listen for events to trigger inotify
Write a script inotify as follows : [[email protected] ~]#vi realtime.sh
#!/bin/bash host01=199.101.117.34 src=/backup dst=backup user=rsync_backup rsync_passfile=/etc/rsync.password inotify_home=/usr/local/inotify
if [ ! -e "$src" ] \ || [ ! -e "${rsync_passfile}" ] \ || [ ! -e "${inotify_home}/bin/inotifywait" ] \ || [ ! -e "/usr/bin/rsync" ]; then echo "Check File and Folder" exit 0 fi
${inotify_home}/bin/inotifywait -mrq --timefmt '%d%m%y %H:%M' --format '%T %w%f' -e close_write,delete,create,attrib $src \ | while read file do cd $src && rsync -aruz -R --delete ./ --timeout=100 [email protected]$host01::$dst --password-file=${rsync_passfile} >/dev/null 2>&1 done exit 0 ## That's the script [[email protected] ~]#nohup ./realtime.sh & # Start the background listening script stay /backup Test under Directory touch {1..100}, On the server side /backup This will be synchronized soon 100 File , success ! If it is not successful, you need to manually check each command , of rsync Server configuration of , See Rsync The simple application and configuration of
边栏推荐
- Jump to open a new window
- Advances in computational imaging
- 炒股开户请问哪个券商佣金是最低最安全的
- "Xiaodeng" active directory batch user creation in operation and maintenance
- Calibration, correction and world coordinate calculation of binocular stereo vision camera (openCV)
- GoAhead 翻译—Active Server Pages
- Alibaba cloud released the atlas of China's robot industry (2022), 122 Pages pdf
- 不同系统下的文件层级符号小结
- verilog实现DDS波形发生器模块,可实现频率、相位可调,三种波形
- About Effect Size
猜你喜欢
随机推荐
Alibaba cloud released the atlas of China's robot industry (2022), 122 Pages pdf
STM32最小系统搭建(原理图)
PostgreSQL weekly news - June 22
How do I audit Active Directory User account changes?
Is it safe to open an account with flush for stock trading?
ads131a04 ADC verilog实现及仿真
Go deep into the underlying principles of go and rewrite redis middleware without secret
《强化学习周刊》第51期:PAC、ILQL、RRL&无模型强化学习集成于微电网络格控制:综述与启示
STL教程6-deque、stack、queue、list容器
Cantata version 9.5 has officially passed the sgs-t Ü V certification and conforms to all major software safety standards
Analysis of the factors affecting the transmission signal of the conductive slip ring
"Xiaodeng" active directory batch user creation in operation and maintenance
"Xiaodeng" ad domain delegation for operation and maintenance
管理人员应具备的基本素质
Curl download example
Xiaomi written test real question 1
Selection of materials for space conductive disc slip ring
解释PBR纹理贴图(texture-maps)
Shutter bottomnavigationbar with page switching example
Live broadcast preview | PostgreSQL kernel Interpretation Series Lecture 1: overview of PostgreSQL system








