# cd /usr/ports/
# make search name=’rsync’
# cd /usr/ports/net/rsync/
# make install clean
# rehash
rsyncd.conf:
# cd /usr/local/etc/
# ls -la | grep rsync
-r—r—r— 1 root wheel 766 Jan 6 03:21 rsyncd.conf
-r—r—r— 1 root wheel 766 Jan 6 03:21 rsyncd.conf.sample
mail#
rsyncd.conf:
motd file = /etc/new_motd
log file = /var/log/rsyncd.log
transfer logging = true
[etc]
# Путь к директории
path = /etc/
# Под каким uid’ом работать
uid = root
# Только чтение
read only = yes
# Разрешать просмотр файлов
list = yes
# Комментарий
comment = ETC
# Хосты, которым разрешен доступ
hosts allow = 192.168.0.136
# Разрешенные пользователи
auth users = backup
# Путь к файлу с паролями
secrets file = /usr/local/etc/rsyncd.scrt
Создаем необходимые файлы и директории
# cat > /etc/new_motd
RSYNC START
# touch /var/log/rsyncd.log
# chmod 0600 /var/log/rsyncd.log
# chown root:wheel /var/log/rsyncd.log
# cat > /usr/local/etc/rsyncd.scrt
backup:123123
# chown root:wheel /usr/local/etc/rsyncd.scrt
# chmod 0600 /usr/local/etc/rsyncd.scrt
# mv /usr/local/etc/rc.d/rsyncd /usr/local/etc/rc.d/rsyncd.sh
# echo rsyncd_enable=»YES» >> /etc/rc.conf
# /usr/local/etc/rc.d/rsyncd.sh start
Starting rsyncd.
mail# ps ax | grep rsyn
175214 ?? Ss 0:00.00 /usr/local/bin/rsync —daemon
175285 p0 S+ 0:00.01 grep rsyn
#
клинт:
/root/> cd /usr/ports/net/rsync/
/usr/ports/net/rsync/> make install clean
… skipped …
/usr/ports/net/rsync/> rehash
/usr/ports/net/rsync/>
Проверяем:
/root/> rsync serv::
RSYNC START
etc ETC
/root/>
/usr/ports/net/rsync/> rsync backup@serv::etc
RSYNC START
Password:
@ERROR: auth failed on module etc
rsync error: error starting client-server protocol (code 5)
at main.c(1296) [receiver=2.6.8]
/usr/ports/net/rsync/> rsync backup@serv::etc
RSYNC START
Password:
drwxr-xr-x 2048 2011/10/05 21:27:03 .
lrwxrwxrwx 12 2011/09/15 21:24:09 aliases
-rw-r—r— 16324 2011/09/17 14:27:21 aliases.db
-rw-r—r— 109 2011/07/12 08:00:03 amd.map
-rw-r—r— 1434 2011/07/12 08:00:03 apmd.conf
-rw-r—r— 235 2011/07/12 08:00:03 auth.conf
-rw-r—r— 237 2011/07/13 18:21:43 crontab
-rw-r—r— 148 2011/07/16 11:10:24 csh.cshrc
-rw-r—r— 421 2011/07/27 06:03:17 csh.login
-rw-r—r— 112 2011/07/27 08:20:20 csh.logout
… skipped …
/usr/ports/net/rsync/>
password-file:
/usr/ports/net/rsync/> cat > /usr/local/etc/rsyncd.scrt
123123
/usr/ports/net/rsync/> chown root:wheel /usr/local/etc/rsyncd.scrt
/usr/ports/net/rsync/> chmod 0600 /usr/local/etc/rsyncd.scrt
/usr/ports/net/rsync/> rsync —password-file=/usr/local/etc/rsyncd.scrt
? backup@serv::etc
HELLOSTART
drwxr-xr-x 2048 2006/10/05 21:27:03 .
…..
… skipped …
/usr/ports/net/rsync/>
На backup сервере создадим директорию, где будут храниться backup:
/root/> df -alh | grep backup
/dev/ad1s1d 524G 2.0K 524G 0% /backup
/root/> mkdir -p /backup/serv.one/etc/
/root/> chmod -R 0700 /backup/serv.one/
/root/> ls -la /backup/serv.one/
total 6
…
/root/> rsync —update —recursive
? —password-file=/usr/local/etc/rsyncd.scrt backup@serv::etc
? /backup/serv.one/etc/
RSYNC START
skipping non-regular file «aliases»
skipping non-regular file «namedb»
skipping non-regular file «rmt»
skipping non-regular file «termcap»
/root/>
Ссылочки rsync качать не стал. ;). Смотрим, что у нас получилось:
/root/> ls -la /backup/serv.one/etc/
… skipped …
/root/>
На сервере:
serv# tail -3 /var/log/rsyncd.log
serv#
mail# echo «» >> /etc/hosts
mail#
бэкапим:
/root/> rsync —update —verbose —recursive
? —password-file=/usr/local/etc/rsyncd.scrt
? backup@serv::etc /backup/serv.one/etc/
RSYNC START
receiving file list … done
skipping non-regular file «aliases»
skipping non-regular file «namedb»
skipping non-regular file «rmt»
skipping non-regular file «termcap»
hosts
sent 326 bytes received 8172 bytes 3425.00 bytes/sec
…