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

Rsync synchronizes files

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

one。 The server (the host that needs to be synchronized) 1. Install rsync yum install-y rsync 2. Configuration, add profile / etc/rsyncd.conf

[global]

Uid = root

Gid = root

Use chroot = no

Max connections = 10

List = yes

Pid file = / var/run/rsyncd.pid

Lock file = / var/run/rsyncd.lock

Log file = / var/log/rsyncd.log

Hosts allow = 192.168.217.130 / / whitelist, IP address of machines allowed to synchronize

[data] / / data directory alias, which is required for synchronization

Path = / usr/local/src / / the synchronization directory corresponding to the alias

Ignore errors

Read only = yes

Auth users = vicxiang / / user name used in synchronization

Secrets file = / etc/sery.pass / / account password configuration file used during synchronization

3. Configuration, add profile / etc/sery.pass

Vicxiang:123456

Modify file permissions chmod 600 / etc/sery.pass 4. Start the rsync service rsync-- daemon-- config=/etc/rsyncd.conf 5. Firewall setting, the port needs to be open to tcp 873II. Client (the destination machine to which the files are synchronized) 1. Configure password file / etc/sery_client.pass

123456

Modify file permissions chmod 600 / etc/sery_client.pass 2. Synchronization command rsync-avr-P vicxiang@192.168.217.128::data / usr/local/src/-- password-file=/etc/sery_client.pass where vicxiang is the user name used during synchronization; 192.168.217.128 is the data directory alias configured by the server IP; data; / usr/local/src/ is the directory synchronized to the local machine / etc/sery_client.pass is the configuration password file III. Write script rsync.sh with crontab timing synchronization

Log_file=rsync.log

Function sync () {

Ip=$ {1}

Path=$ {2}

T=date +% Y%m%d-%H%M%S

Echo "${t} start to sync data from ${ip}..." > > ${log_file}

Rsync-avr-P vicxiang@$ {ip}:: data ${path}-password-file=/etc/sery_client.pass

Echo "done" > > ${log_file}

}

Sync ip path

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