Created
August 7, 2014 10:20
-
-
Save 6LYTH3/0e1277d43fc02ef26b04 to your computer and use it in GitHub Desktop.
Script for move file at RuleBase to backup path with 'rsync'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################################################### | |
### | |
### Version Date Author Description | |
### 0.0.1 7 Jul 2014 Naruedol Y. Initial Script | |
### Sanit B. move file at RuleBase | |
### to backup path with 'rsync' | |
################################################################### | |
SOURCE=/home/autodiag/MountShareRuleBase/ | |
SOURCE_LOCALDEX=/home/autodiag/MountShareRuleBase/localDex/ | |
DESTINATION=/home/autodiag/work/ | |
DESTINATION_LOCALDEX=/home/autodiag/localDex/ | |
LOG=/home/autodiag/SyncRBlog-$(date +%Y-%m-%d).log | |
### Check Rule Base path is not averiable ### | |
#ls -ld $SOURCE ### if $? -ne 0 | |
mount | grep ShareRuleBase | |
if [ $? -ne 1 ]; then | |
mail -s "Please check Rule Base mount path on `hostname`" tkfis-support < /dev/null | |
exit | |
fi | |
## Heartbeat ### | |
HB=`ps -ef|grep rsync|grep -v grep|grep -v bash|wc -l` | |
if [ $HB -le 0 ]; then | |
########################## | |
### work directory ### | |
########################## | |
## Generate Log Header ### | |
echo " " >> $LOG | |
echo " -=-=-=-=-=-=-=-=-= Start Synchonize On Work Directory =-=-=-=-=-=-=-=-=-=- " >> $LOG | |
echo " " >> $LOG | |
rsync -avh --delete --progress --exclude 'localDex' --log-file=$LOG --log-file-format="%o %f %b" $SOURCE $DESTINATION | |
## Generate Log Footer ### | |
echo " " >> $LOG | |
echo " -=-=-=-=-=-=-=-=-= Finish Synchonize For Work Directory =-=-=-=-=-=-=-=-=-=- " >> $LOG | |
########################## | |
### localDex directory ### | |
########################## | |
## Generate Log Header ### | |
echo " " >> $LOG | |
echo " -=-=-=-=-=-=-=-=-= Start Synchonize On localDex Directory =-=-=-=-=-=-=-=-=-=- " >> $LOG | |
echo " " >> $LOG | |
rsync -avr --delete --progress --log-file=$LOG --log-file-format="%o %f %b" $SOURCE_LOCALDEX $DESTINATION_LOCALDEX | |
## Generate Log Footer ### | |
echo " " >> $LOG | |
echo " -=-=-=-=-=-=-=-=-= Finish Synchonize For localDex Directory =-=-=-=-=-=-=-=-=-=- " >> $LOG | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment