Header Ads

Header Ads

Setting up rsync server on debian linux for gentoo mirror


Hi again, now i will tell you guys how to simply setup rsync mirror server on GNU/Debian Linux (i will use it for Gentoo portage tree mirroring).


First of all we will need to install rsync (it includes server)
# apt-get install rsync
Now you will need decide where you want to serve mirror files, in my way it is: "/home/gentoo/public_html/pub", i prefer to create new user and chroot rsync daemon to it. Now we will create the user and make directories:
# adduser gentoo
# mkdir -p /home/gentoo/public_html/pub
# chown -R gentoo:gentoo /home/gentoo/public_html
Then we will need edit configuration files and prepare the server, open file "/etc/default/rsync" and change these two lines to look like:
RSYNC_ENABLE=true
RSYNC_CONFIG_FILE=/etc/rsyncd.conf
Save file and open "/etc/rsysncd.conf", if there exists any lines then erase them all and paste the following config text:

uid = gentoo
gid = gentoo
use chroot = yes
max connections = 15
pid file = /var/run/rsyncd.pid
motd file = /etc/rsyncd.motd
log file = /var/log/rsync.log
transfer logging = yes
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
[gentoo-portage]
path = /home/gentoo/public_html/pub
comment = Gentoo Linux Portage tree mirror
exclude = distfiles
read only = yes
list = yes
log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
Save this and as you see you can create file "/etc/rsyncd.motd" and paste here all the information about your server including hardware and so on, this is only for a text banner then connecting to rsync server.
Add startup script to run levels and start the service:
# update-rc.d rsync defaults
# service rsync start
If anything goes wrong you can always check "/var/log/rsync.log" for errors. Now we need to setup the service that runs once per day to update the mirror with rsync command, create directory:
# mkdir /etc/init.d/gentoo-rsync/
# cd /etc/init.d/gentoo-rsync/
# touch kill-proc  rsync-gentoo-portage
Yeah we almost finished, just need a little bit paste  to "rsync-gentoo-portage" script file:
#!/bin/bash
cd /etc/init.d/gentoo-rsync
RSYNC="/usr/bin/rsync"
OPTS="--quiet --recursive --links --perms --times -D --delete --timeout=300"
SRC="rsync://rsync.de.gentoo.org/gentoo-portage"
DST="/home/gentoo/public_html/pub/"
echo "Started update at" `date` >> $0.log 2>&1
logger -t rsync "re-rsyncing the gentoo-portage tree"
${RSYNC} ${OPTS} ${SRC} ${DST} >> $0.log 2>&1
And to another file (file needed that if you will be in trouble it will kill all rsync processes) "kill-proc":
 kill -9 `ps --no-headers -Crsync -o etime,user,pid,command|grep nobody | \
 grep "[0-9]\{2\}:[0-9]\{2\}:" |awk '{print $3}'`kill -9 `ps --no-headers -Crsync -o etime,user,pid,command|grep gentoo | \
 grep "[0-9]\{2\}:[0-9]\{2\}:" |awk '{print $3}'`
make these scripts executable and add to crontab for cycle update
# chmod +x kill-proc  rsync-gentoo-portage
# chown -R gentoo:gentoo /etc/init.d/gentoo-rsync
# echo "0 3 * * * gentoo /etc/init.d/gentoo-rsync/rsync-gentoo-portage  > /dev/null 2>&1" >> /etc/crontab
Now you can run and test it (run it as gentoo user not as root):
# su - gentoo
# /etc/init.d/gentoo-rsync/rsync-gentoo-portage
It will takes couple of minutes (depending on your dialup connection... just kidding).

Now on client side (machine), if you would like to use this mirror edit make.conf and paste the following line to it:
SYNC="rsync://your_server_name/gentoo-portage"
Thats all, have a nice day! ;-)

2 comments:

  1. Works fine, thanks for the tutorial!

    ReplyDelete
  2. Anonymous4/12/22 20:25

    If you plan to make one deposit in every week, examine the current Deal-a-Day bonus list to see which day by day bonus you like. Read through the anticipated delivery instances discover out} which is the best cost methodology for you. We use dedicated individuals and clever thecasinosource.com know-how to safeguard our platform.

    ReplyDelete

Copyright (c) 2012-2013 Unix Master. Powered by Blogger.