Add support for network directories on backups for remote maschines.
This commit is contained in:
parent
a70ea6a55c
commit
64971f6afa
@ -12,6 +12,8 @@
|
|||||||
## -
|
## -
|
||||||
## - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
## - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
err_Log=${LOCK_DIR}/dir.err.log
|
||||||
|
> $err_Log
|
||||||
|
|
||||||
## - load functions
|
## - load functions
|
||||||
## -
|
## -
|
||||||
@ -19,10 +21,29 @@
|
|||||||
|
|
||||||
if $mount_netdir ; then
|
if $mount_netdir ; then
|
||||||
if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then
|
if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then
|
||||||
print_error_stdout "Mounting network directories is only possible for localhost - yet:\n $(cat $err_Log)"
|
|
||||||
|
## - Network directory mounted ?
|
||||||
|
## -
|
||||||
|
if ! $($ssh ${ssh_user}@${srcHost} df -h 2> /dev/null | grep -q ${backup_dir} 2>/dev/null) ; then
|
||||||
|
$ssh ${ssh_user}@${srcHost} "$sudo mount ${backup_dir}" > /dev/null 2> $err_Log
|
||||||
|
|
||||||
|
if [[ "$?" -ne 0 ]]; then
|
||||||
echolog ""
|
echolog ""
|
||||||
echolog "\t[ERROR] Mounting network directories is only possible for localhost - yet"
|
echolog "\t[ERROR] Mounting '${backup_dir}' on '${srcHost}' failed!\n $(cat "$err_Log")"
|
||||||
exit 1
|
exit 1
|
||||||
|
else
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
if ! $($ssh ${ssh_user}@${srcHost} df -h 2> /dev/null | grep -q ${backup_dir} 2>/dev/null) ; then
|
||||||
|
echolog ""
|
||||||
|
echolog "\t[ERROR] Something went wrong with mounting '${backup_dir}' on '${srcHost}'!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
## - Network directory mounted ?
|
## - Network directory mounted ?
|
||||||
## -
|
## -
|
||||||
@ -43,9 +64,19 @@ fi
|
|||||||
|
|
||||||
## - Check if directory is empty
|
## - Check if directory is empty
|
||||||
## -
|
## -
|
||||||
if [ ! "$(ls -A $backup_dir)" ]; then
|
if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then
|
||||||
|
|
||||||
|
if [ ! "$( $ssh ${ssh_user}@${srcHost} ls -A ${backup_dir})" ] ; then
|
||||||
|
echolog ""
|
||||||
|
echolog "\t[ NOTICE ]: Directory \"${backup_dir}\" on \"${srcHost}\" is empty. So nothing to do..\n"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ ! "$(ls -A $backup_dir)" ]; then
|
||||||
|
echolog ""
|
||||||
echolog "\t[ NOTICE ]: Directory \"$backup_dir\" is empty. So nothing to do..\n"
|
echolog "\t[ NOTICE ]: Directory \"$backup_dir\" is empty. So nothing to do..\n"
|
||||||
exit 0
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echolog "\n\tBackup network directory \"$backup_dir\" ( `$date +%H`:`$date +%M` h )"
|
echolog "\n\tBackup network directory \"$backup_dir\" ( `$date +%H`:`$date +%M` h )"
|
||||||
@ -53,10 +84,19 @@ backup_dir=$backup_dir $script_dir/dir_backup.sh
|
|||||||
|
|
||||||
if $mount_netdir ; then
|
if $mount_netdir ; then
|
||||||
if [ $srcHost != "localhost" ];then
|
if [ $srcHost != "localhost" ];then
|
||||||
print_error_stdout "Mounting network directories is only possible for localhost - yet:\n $(cat $err_Log)"
|
|
||||||
|
$ssh ${ssh_user}@${srcHost} "$sudo umount ${backup_dir}" > /dev/null 2> $err_Log
|
||||||
|
if [[ "$?" -ne 0 ]]; then
|
||||||
echolog ""
|
echolog ""
|
||||||
echolog "\t[ERROR] Mounting network directories is only possible for localhost - yet"
|
echolog "\t[ERROR] Unounting '${backup_dir}' on '${srcHost}' failed!\n $(cat "$err_Log")"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#print_error_stdout "Mounting network directories is only possible for localhost - yet:\n $(cat $err_Log)"
|
||||||
|
#echolog ""
|
||||||
|
#echolog "\t[ERROR] Mounting network directories is only possible for localhost - yet"
|
||||||
|
#exit 1
|
||||||
|
|
||||||
else
|
else
|
||||||
$umount $backup_dir 2> /dev/null
|
$umount $backup_dir 2> /dev/null
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user