Bash Script untuk rsync ke jaringan client
Bash script ini ditulis secara sederhana oleh penulis, bisa dimodifikasi sesuai dengan kebutuhan. Dengan memanfaatkan program rsync di linux untuk melakukan sinkronisasi data melalui jaringan digunakan untuk kebutuhan backup data, dengan menggunakan rsync bisa lebih efisien terhadap penggunaan bandwitdh dan bersifat resumable. Topologi yang digunakan oleh penulis adalah sebagai berikut:
bash script yang digunakan adalah sebagai berikut:
#!/bin/bash
rsync=/usr/bin/rsync
#----------------------baddress share direktory milik client host1=192.168.0.2
host2=192.168.0.3
share1=//192.168.0.2/data
share2=//192.168.0.3/data
#------------------------------------path lokasi data backup
path1=/home/tomi/data/windows
path2=/home/tomi/data/linux
#--------------------------------------------lokasi mounting
source1=/mnt/windows
source2=/mnt/linux
clear;
echo " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%";
echo " %% %%";
echo " %% BACKUP DATA JARINGAN MENGGUNAKAN RSYNC %%";
echo " %% %%";
echo " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%";
sleep 1;
echo "";
#--------------------------------test koneksi ping ke client
echo " [ Pengecekan koneksi ke client-1 ]...";
echo "";
if ! ping -c 1 -w 5 "$host1" &>/dev/null ;
then
echo " ----- client-1 timeout, komunikasi gagal";
echo "";
else
echo " ----- client-1 aktif, komunikasi berhasil";
echo "* Proses mounting share direktory ke client-1...";
echo "";
sleep 1;
mount -t cifs $share1 $source1 -o user=banksonk,ntvlm2;
if [ $? -ne 0 ]
then
echo " * Share Direktory tidak ditemukan, backup diabaikan..";
else
echo " [ Proses sinkronisasi backup dan transfer data..]";
#----------------------------------proses backup ke client-1
$rsync -avP $source1/ $path1/ #>> /home/tomic/data/rsync-windows.log;
wait;
echo "";
echo " [ Backup ke client-1 selesai...]";
echo "";
fi
fi
echo "----------------------------------------------------";





