RadarURL

10 Februari 2018

Script backup & upload server senayan perpus dan di sync ke server Online di TIPD

Berdasarkan contoh script dari mas Hendro Wicaksono (developer SLiMS - Senayan Library Management System), terima kasih mas... baru sempat dokumentasi/sharing ke blog...

Saya mencoba adaptasi script tersebut untuk backup server SLiMS di Perpustakaan IAIN Palangka Raya (offline sebagai Server sirkulasi) dan mensinkronkan dengan server SLiMS online di TIPD IAIN Palangka Raya.
Berikut script yang dipakai:

backupupload.sh
===
#!/bin/bash
cd /home/iain/backup/sql
/usr/bin/mysqldump -u root -p*** slim5 > slim5.sql
tar c
zvf slim5.sql.tar.gz slim5.sql
rm slim5.sql
echo `date +%Y/%m/%d` `date +%H:%m` "Backup DB slim5 sukses..."
# Upload ke server online (file database)
sshpass -p*** /usr/bin/rsync -e ssh -av -z -P /home/iain/backup/sql/ upload@192.168.5.11:/home/upload/backup/ >/dev/null 2>&1
echo `date +%Y/%m/%d` `date +%H:%m` "Upload DB slim5 sukses..."
# Upload ke server online (folder files, images, repositori)
sshpass -p*** /usr/bin/rsync -e ssh -av -z -P /var/www/html/akasia/files/ upload1@192.168.5.11:/var/www/html/senayan/akasia/files/ >/dev/null 2>&1
echo `date +%Y/%m/%d` `date +%H:%m` "Upload folder files sukses..."
sshpass -p*** /usr/bin/rsync -e ssh -av -z -P /var/www/html/akasia/images/ upload1@192.168.5.11:/var/www/html/senayan/akasia/images/ >/dev/null 2>&1
echo `date +%Y/%m/%d` `date +%H:%m` "Upload folder images sukses..."
sshpass -p*** /usr/bin/rsync -e ssh -av -z -P /var/www/html/akasia/repository/ upload1@192.168.5.11:/var/www/html/senayan/akasia/repository/ >/dev/null 2>&1
echo `date +%Y/%m/%d` `date +%H:%m` "Upload folder repository sukses..."
===

selanjutnya restore file backup slim5.sql.tar.gz di server Online
resstoredb.sh
===
#!/bin/bash
echo "DROP DATABASE slim5" | mysql -u root -p***
echo "CREATE DATABASE slim5" | mysql -u root -p***
cd backup
tar -xzvf /home/upload/backup/slim5.sql.tar.gz
/usr/bin/mysql -u root -p*** slim5 < /home/upload/backup/slim5.sql
echo `date +%Y/%m/%d` `date +%H:%m` "restore Database slim5 sukses..."
===

Demikian... Semoga bermanfaat...
Posting Komentar