Wednesday, April 21, 2010

How To Rsync at Freebsd Using ssh.

Before rsync,your have to make sure your BSD box already insttaled rsync. If you don't have it please to do so and please to install both of your server.

You can install rsync using ports (Please to csup your ports 1st to get the new packages)

#cd /usr/ports/net/rsync/
#make config
#make && make install
#rehash.

Start to rsync.

i am only rsync forder usr/src.
#rsync -av -e "ssh -l admin" root@servername:/usr/src/ /usr/src/

After finish do not reboot, please re-compile.
** I recommended to csup the stable_supfile 1st before your compile your kernel.

#cd /usr/src
#make cleanworld && make cleandir
#make buildworld
#make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
#make installworld
#make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
#reboot

Then start to rsync other folder.
Your can exclude any folder that you think not necessary.
I am rsync some folder such as boot or usr/src.

#rsync -av --exclude=/boot --exclude=/usr/src -e "ssh -l admin" root@servername:/ /

password will be prompted. Then enter password. wait until finish the rsync.

After finish

change ip address,hostname and vhost.

To change hostname.
#ee /etc/hosts

To change ip address
#ee /etc/rc.conf

to change vhost ** If you use it.
# ee /usr/local/etc/apache22/extra/httpd-vhosts.conf

then reboot your server

Rsync on linux box

Consider you already have 2 Linux server then open terminal or ssh at the new Linux server.

type command below

#rsync -av --exclude=/boot-e ssh username@oldserverhost:/(source) /(destination)

or standard rsync

#rsync -av -e ssh username@oldserverhost:/home/old_home/ /home/new_home/


password will be prom then enter password.
i exclude boot file because it need difficult configuration. You also can exclude the folder you want to rsync too such as /root /home /lib or anything else.

After finish the transferring data, your have to reconfigure, the Ip address,hostname or any necessary file need such as apache, mysql or others that you use.

*Ip tables or firewall at linux sometime need to stop to running the application.