Operating System - HP-UX
1833187 Members
3097 Online
110051 Solutions
New Discussion

sync folders between two machines

 
SOLVED
Go to solution
sethunava
Regular Advisor

sync folders between two machines

Hi,
We have HP-UX servers where Directory from one server need to be in sync with other server

Directory contains sub-directories & files

Any update in a server 1 to be replicated to server 2 & vice versa


thanks

5 REPLIES 5
Murat SULUHAN
Honored Contributor
Solution

Re: sync folders between two machines

Hi

rsync will help you

http://hpux.cs.utah.edu/hppd/hpux/Networking/Admin/rsync-2.6.9/

Best Regards
Murat
Murat Suluhan
likid0
Honored Contributor

Re: sync folders between two machines

I use rsync to do this, but here you have some commands you can use:

--={ RSYNC }=------------------------------------------------------

Remote:

# cd $SRC; rsync -axtzv --delete --rsync-path=/opt/rsync/bin/rsync . $HOST:$DST

a: archive mode, equivalent to -rlptgoD (see man)
x: don't cross filesystem boundaries
z: compress file data
n: no hacer nada (simulacion) <-- mola!
t: preserve times !
--rsync-path=PATH specify path to rsync on the remote machine
--delete : borra los archivos que se han borrado.
vv: mas verboso

ALGUNAS OPCIONES INTERESANTES (Segun caso)

H: preserve hard links
S: spares files!

nota:
path en las HP: /opt/rsync/bin/rsync o /usr/local/bin/rsync
path en las Sun: /opt/swf/bin/rsync

Ventajas:
- permite trabajar sobre un unico filesystem (-x)
- incremental (solo copia archivos que hayan cambiado de CRC)
- local/remoto (en un solo comando, sin | )
- compression (-z) incorporada de serie ;)
- muy configurable (ver man)
- compatible sun/hp/linux
- largefile soportado - no probado (eso dicen en el ITRC)

Inconvenientes:
- debe estar instalado rsync en ambas maquinas
- es un poco cabr*n con los / al final de los paths.
Por eso, para no liarla, es mas facil hacer un cd $SRC antes, y usar el rsync sobre "."


Troubleshooting:

permission denied.
rsync: connection unexpectedly closed (0 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(165)

-> habilitar el login remoto en HOST (rhost)


** Configuración de rsyncd como servidor: se levanta en el destino evita tener que configurar .rhosts y puede ser más seguro al permitir hacer "chroot" a un directorio que se especifica (para evitar equivocaciones) . El problema es que necesita que el puerto 873 esté permitido en firewalls, etc (aquí no hay problemas).

->> Configuración del "rsyncd.conf "
use chroot = yes
uid = 0
gid = 0
[ITO]
path = /mnt/ITO/
read only = no

* Comando del servidor (destino): rsync --daemon --config=/usr/contrib/bin/rsyncd.conf

* Comando del cliente (origen): rsync -axzv -H --delete /directorio_origen ::ITO

-> El path de origen se pone sin "/" final para que cree el árbol de directorios


*** Hacer un filtrado previo (si hay muchisimos ficheros):

Para hacer un primer filtrado, generamos una lista de ficheros que se
han modificado hace poco (quitando el "./" del principio, para el rsync):

src=/foo/bar
cd $SRC; find . -mtime -4 ! -type d | sed -e "s/^.\///"


En el rsync, usamos las opciones:
--include-from=/dev/stdin -> coge lista de ficheros desde stdin (pipe)
--include "*/" -> incluye todos los directorios
--exclude "*" -> excluye todo los demas ficheros



$ find . -mtime -4 ! -type d | sed -e "s/^.\///" |
rsync -av --stats \
--include-from=/dev/stdin \
--include "*/" \
--exclude "*" \
$SRC/ $DST/


--={ FIND | CPIO }=------------------------------------------------

en local:

# cd $SRC; find . -xdev -depth | cpio -pmdux $DEST
o # cd $SRC; find . -xdev -depth | cpio -o | (cd $DST; cpio -imdux )

en remoto (tecnica "remote pipes"):

# cd $SRC; find . -xdev -depth | cpio -o | remsh $HOST "(cd $DST; cpio -imdux )"

remoto+dd (buffering):

# cd $SRC; find . -xdev -depth | cpio -o | dd bs=1024k | \
remsh $HOST "dd bs=1024k | (cd $DST; cpio -imdux )"

remoto + compresion

# cd $SRC; find . -xdev -depth | cpio -o | compress | \
remsh $HOST "uncompress | (cd $DST; cpio -imdux )"

o # cd $SRC; find . -xdev -depth | cpio -o | gzip -c | \
remsh $HOST "gzip -cd | (cd $DST; cpio -imdux )"

Ventajas:
- las opciones del find !
- permite trabajar sobre un unico file system (-xdev)
- permite hacer una seleccion previa de los ficheros (por user,
fecha, grupo...)
- parece mas rapido que el rsync ! (probado el metodo remoto, con dd-buffer y va
muchisimo mas rapido que el rsync - era con archivitos pequenios)

Inconvenientes:
- no soporta largefile


Notas (ITRC):

For the cpio case, use the B option to get a 5KB block size and let dd(1)
read from cpio and write to cpio with a 5k block size, i.e. "cpio -oB .... |
dd ibs=5k obs=..." and "dd ibs=... obs=5k | cpio -iB ...". The reason for this
is that 'remote pipes' do not quarantee which 'chunks' they will use, i.e.
when you write 10 times 5k to a remote pipe, you will get 50k out of it, but
not neccessarily in 10 blocks of 5k. The dd constructs solve that problem.

--={ TAR }=--------------------------------------------------------

Local:

# (cd $SRC; tar cf - . ) | (cd $DST; tar xf - )

Remoto:

# (cd $SRC; tar cf - . ) | remsh $HOST "(cd $DST; tar xf - )"
# (cd $SRC; tar zcf - . ) | remsh $HOST "(cd $DST; tar zxf - )"

# (cd $SRC; tar cf - . ) | compress | \
remsh $HOST "uncompress | (cd $DST; tar xf - )"

# (cd $SRC; tar cf - . ) | gzip -c | \
remsh $HOST "gzip -cd | (cd $DST; tar xf - )"


Ventajas:

Inconvenientes:
- en HPUX no largefile. El GNU tar soporta largefiles.
- no permite trabajar en un unico file system
(salvo con GNU/tar donde se puede usar la opcion -l)

--={ FBACKUP | FRESTORE }=-----------------------------------------

/!\ CUIDADO : mirar los inconvenentes.

/usr/sbin/fbackup
/usr/sbin/frecover

Local:

# fbackup -i $SRC -f - | (cd $DST; frecover -Xrf -)

Remoto:

# fbackup -i $SRC/ -f - | remsh $HOST "(cd $DST; /usr/sbin/frecover -Xrf -)"
^
| cuidado con el / final?

para usar compression, al igual que con el tar y el cpio (mirar antes):

# fbackup -i $SRC -f - | compress | remsh $HOST "/usr/bin/uncompress | (cd $DST; /usr/sbin/frecover -Xrf -)"


Ventajas:
- largefile

Inconvenientes:
- solo HPUX
- Restaura la jerarquia original completa debajo de DST !
(por ejemplo si src=/usr/local, se va a crear todo debajo de DST/usr/local)
Si se tiene que restaurar en remoto, pero en el mismo sitio, usar DST=/


--={ VXDUMP | VXRESTORE }=-----------------------------------------

/usr/sbin/vxdump
/usr/sbin/vxrestore

Local:

# vxdump 0f - $SRC | (cd $DST; vxrestore rf -)

(no lo he probado)

Remoto:

# vxdump 0f - $SRC | remsh $HOST "(cd $DST; /usr/sbin/vxrestore xvf - )"

...
para usar compression, al igual que con el tar y el cpio (mirar antes).

Ventajas:
- largefile
- muy rapido

Inconvenientes:
- como root o propietario del fs.
- solo a nivel de filesystem completo, no subdirectorio dentro de un filessytem.

--={ ext2/3's DUMP / RESTORE }=---------------------------------------

# dump -0f - $SRC | ( cd $DST; restore -rvf - )

Ventajas:
- Parece muy rapido (mas que un rsync).
- Se puede hacer incrementales (jugando con el nivel del dump.
En este caso usar -u en el dump )

Inconvenientes:
- solo HPUX
- como root o propietario del fs.
- solo a nivel de filesystem completo, no subdirectorio dentro de un filessytem.


--={ PAX }=-----------------------------------------------------------

Local:

# cd $DST; pax -rw -pe -X $SRC .

(no lo he probado)

Platform:
- Linux, HPUX, Sun?


--={ RAW DEVICE }=----------------------------------------------------

dd con remote pipes

# BUFF_SZ=4096k; dd if=/dev/raw/origen bs=$BUFF_SZ |
remsh $HOST_DESTINO "dd of=/dev/raw/destino bs=$BUFF_SZ"

# dd if=/dev/vgopc/rlvsharevar bs=4096k | remsh $HOST "dd of=/dev/vgopc/rlvsharevar2 bs=4096k"
^^^ ^^^
Ventajas:
- largefile soportados,
- sparse files soportados

Inconvenientes:
- si es un filesystem, no deberia estar montado (o en r/o solo)
- si es un filesystem, si no esta muy lleno se va a perder tiempo copiando "espacio vacio".
Windows?, no thanks
sethunava
Regular Advisor

Re: sync folders between two machines

Hi
how to install rsync-2.6.9-hppa-11.11.depot.gz

thanks
Asif Sharif
Honored Contributor

Re: sync folders between two machines

#/usr/contrib/bin/gunzip rsync-2.6.9-hppa-11.11.depot.gz
#swinstall -s rsync-2.6.9-hppa-11.11.depot

Regards,
Asif Sharif
Regards,
Asif Sharif
Dennis Handly
Acclaimed Contributor

Re: sync folders between two machines

>Asif: #swinstall -s rsync-2.6.9-hppa-11.11.depot

Slight correction:
#swinstall -s $PWD/rsync-2.6.9-hppa-11.11.depot \*