Sincronizar subdiretórios com Shell Script e Rsync

#!/bin/bash
# Script para sincronizar subdiretorios com rsync
# sincroniza arquivos de diretorio local para diretorio remoto
# ex de comando manual sem script:
# rsync -av /mnt/bigdir/dir1 192.168.0.1:/mnt/bigdir/

LOCAL_SOURCE_DIR=/mnt/bigdir
REMOTE_TARGET_IP=192.168.0.1
REMOTE_TARGET_DIR=/mnt/bigdir/

for i in $( ls $LOCAL_SOURCE_DIR ); do
  echo Sincronizando diretorio: $i
  rsync -aAXHv $LOCAL_SOURCE_DIR/$i $REMOTE_TARGET_IP:$REMOTE_TARGET_DIR
done
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s