Managing rsync fail
This commit is contained in:
parent
a1169c79a6
commit
4d4ef3a5c4
@ -29,6 +29,11 @@ sync() {
|
||||
# PUSH TO REMOTE - and PULL FROM REMOTE swapping `src` with `dest`
|
||||
#echo "executing rsync -aPu --log-file=$LOGFILE -e ssh $otheropts $src $dest"
|
||||
# NOTE REMOTEDIR ALREADY EXISTS IN DESTINATION
|
||||
rsync -aPu --log-file=$LOGFILE -e ssh $otheropts $src $dest 1>/dev/null || \
|
||||
echo 'generic sync error. Probabily for some reason rsync is broken, raise Exception and quit' && exit 1
|
||||
rsync -aPu --log-file=$LOGFILE -e ssh $otheropts $src $dest 1>/dev/null 2>&1
|
||||
# last command execution exit code $?"
|
||||
rsync_result=$?
|
||||
if [[ ${rsync_result} -ne 0 ]]; then
|
||||
echo "Generic sync error. rsync has failed with the code ${rsync_result}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
9
masync
9
masync
@ -115,7 +115,7 @@ feeddeletes() {
|
||||
##########################################
|
||||
|
||||
initsyncpath() {
|
||||
echo 'Starting initial sync...'
|
||||
echo -e "Start mirroring remote folder ${GREEN}$2${ENDCOLOR} on local folder ${GREEN}$1${ENDCOLOR}"
|
||||
## write the file with remotepath and localpath for future use
|
||||
localpath_hash=$(echo "$1" | md5sum | cut -f1 --delimiter=" " -)
|
||||
sync $localpath_hash $2 $1
|
||||
@ -209,7 +209,6 @@ stoploopsyncpath() {
|
||||
}
|
||||
|
||||
removeloopsyncpath() {
|
||||
echo "removeloopsyncpath $1"
|
||||
#echo $(sed "1q;d" ~/.syncdir.sync) | sed -e "s/STOPPED/RUNNING/"
|
||||
nline=$(nsync "$1")
|
||||
sed -n -s "$nline"p "$SYNCFILE" | while read hash pid when status localpath remotepath; do
|
||||
@ -249,8 +248,7 @@ case "$1" in
|
||||
shift
|
||||
while getopts ":l:r:" option; do
|
||||
case "${option}" in
|
||||
l) echo "l option: ${option} value ${OPTARG}"
|
||||
localpath=${OPTARG}
|
||||
l) localpath=${OPTARG}
|
||||
if [ ! -d "$localpath" ]; then
|
||||
echo 'local path to sync not exists... do you want to create it?'
|
||||
test_no='^(N|n)[[:alnum:]]+'
|
||||
@ -268,9 +266,8 @@ case "$1" in
|
||||
localpath="${localpath}"/
|
||||
fi
|
||||
;;
|
||||
r) echo "r option: ${option} value ${OPTARG}"
|
||||
r) remotepath=${OPTARG}
|
||||
#match an adress in this form username@from_host:/home/test
|
||||
remotepath=${OPTARG}
|
||||
re_isremote='^[[:alnum:]]+\@([[:alnum:]]+|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})):/[[:alnum:]]+/?'
|
||||
if ! [[ $remotepath =~ $re_isremote ]]; then
|
||||
echo 'Incorrect format for destination path... aborting'
|
||||
|
Loading…
x
Reference in New Issue
Block a user