Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Real-time synchronization between inotify and rsync

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Build rsync server

Systemctl start rsyncd

Systemctl enable rsyncd

Systemctl status rsyncd

Ss-ntl | grep 873

Rpm-ql rsync

two。 Modify the configuration file

Vi / etc/rsyncd.conf

Uid = root

Gid = root

Use chroot = no

Max connections = 0

Ignore errors

Exclude = lost+found/

Log file = / var/log/rsyncd.log

Pid file = / var/run/rsyncd.pid

Lock file = / var/run/rsyncd.lock

Reverse lookup = no

Hosts allow = 192.168.8.0 Compact 24 # client IP

[backup]

Path = / backup/

Comment = backup

Read only = no

Auth users = rsyncuser

Secrets file = / etc/rsync.pass

3. Create a rsync backup server directory

Mkdir / backup

The server generates a verification file

Echo "rsyncuser:magedu" > / etc/rsync.pass

Chmod 600 / etc/rsync.pass

 server-side preparation directory

Mkdir / backup

The server starts the rsync service

Rsync-daemon can join / etc/rc.d/rc.local to realize boot

Systemctl start rsyncd CentOS 7

Client configuration password file

Echo "magedu" > / etc/rsync.pass

Chmod 600 / etc/rsync.pass

Client

Turn on inotify

Yum-y install inotify-tools

4. Client test synchronization data

Rsync-avz-- password-file=/etc/rsync.pass / data/backup rsyncuser@rsync server IP::backup

5. Client create inotify_rsync.sh script

Vim inotify_rsync.sh #! / bin/bash

SRC='/data/backup/'

DEST='rsyncuser@rsync server IP::backup'br/ > #! / bin/bash

SRC='/data/backup/'

DEST='rsyncuser@rsync Server IP::backup'

Do

FILEPATH=$ {DIR} ${FILE}

Rsync-az-- delete-- password-file=/etc/rsync.pass $SRC $DEST &

Echo "At ${TIME} on ${DATE}, file $FILEPATH was backuped up via rsync"

/ var/log/changelist.log

Done

Chmod + x inotify_rsync.sh

Start the background monitoring process

6.sh inotify_rsync.sh &

Ps-ef | grep inotify_rsync

Note: both hosts must enable ssh secret-free login, allowing clients to distribute data to rsync servers.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report