Get the App
SLTechnology News&Howtos  ›  Servers  › 

Rsync synchronizes files

Shulou Source: shulou.com Published: 2022-06-03 10:02:28 11月15日 Update

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

Tags: Synchronization files configuration directories services aliases passwords data machines permissions users user names hosts lists commands addresses clients clients destinations ports Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Linux MariaDB Shulou Information