rsync is a file transfer program for Unix systems. rsync uses the “rsync algorithm” which provides a very fast method for bringing remote files into sync. It does this by sending just the differences in the files across the link, without requiring that both sets of files are present at one of the ends of the link beforehand.
Some features of rsync include
- can update whole directory trees and filesystems
- optionally preserves symbolic links, hard links, file ownership, permissions, devices and times
- requires no special privileges to install
- internal pipelining reduces latency for multiple files
- can use rsh, ssh or direct sockets as the transport
- supports anonymous rsync which is ideal for mirroring
Server
rsyncd.conf1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21usechroot = no
max connections = 20
strict mode = yes
port = 18730
timeout = 600
transfer logging = yes
log format = %t %a %m %f %b
syslog facility = local3
pid file = /path-of-rsync/run/rsyncd.pid
lock file = /path-of-rsync/run/rsync.lock
log file = /path-of-rsync/log/rsyncd.log
[static]
path = /path-to-upload/
ignore errors
read only = no
write only = no
list = no
hosts allow = xx.xx.xx.xx
hosts deny = 0.0.0.0/32
auth users = rsync_static
secrets file = /path-of-rsync/config/rsyncd.secrets
rsyncd.secrets1
user:pass
start_rsync.sh1
2
3!/bin/bash
rsync --daemon --config /path-of-rsync/config/rsyncd.conf
stop_rsync.sh1
2
3!/bin/bash
pkill rsync
Client
rsyncd.secrets1
pass
rsync_get.sh1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17!/bin/bash
RSYNC_HOME=/path-of-rsync
TARGET_PATH=/path-to-download
RSYNC_USER=username
REMOTE_IP=29.149.146.205
REMOTE_PORT=18730
date | tee -a ${RSYNC_HOME}/log/rsync_get.log
echo "------------------------" >> ${RSYNC_HOME}/log/rsync_get.log
echo "" >> ${RSYNC_HOME}/log/rsync_get.log
rsync -avh --delete --progress --password-file=${RSYNC_HOME}/config/rsyncd.secrets rsync://${RSYNC_USER}@${REMOTE_IP}:${REMOTE_PORT}/static ${TARGET_PATH} | tee -a ${RSYNC_HOME}/log/rsync_get.log
echo -e "\n" >> ${RSYNC_HOME}/log/rsync_get.log