Add support for remote backup server.
This commit is contained in:
127
rcopy.sh
127
rcopy.sh
@@ -40,6 +40,16 @@ logrotate_conf_file="$rcopy_base_dir/conf/logrotate.conf"
|
||||
[ -f $rcopy_conf_file ] || exit 1
|
||||
. $rcopy_conf_file
|
||||
|
||||
# - Be compartible with older configuration files
|
||||
# -
|
||||
if [ "X$remote_disk" = "X" ] ; then
|
||||
remote_disk=false
|
||||
fi
|
||||
|
||||
if [ "X$check_mountpoint" = "X" ] ; then
|
||||
check_mountpoint=false
|
||||
fi
|
||||
|
||||
[ -f $rcopy_functions_file ] || exit 1
|
||||
. $rcopy_functions_file
|
||||
|
||||
@@ -69,11 +79,6 @@ else
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if [ "X$check_mountpoint" = "X" ] ; then
|
||||
check_mountpoint=false
|
||||
fi
|
||||
|
||||
if $check_mountpoint ; then
|
||||
if [[ ! -d $backup_mountpoint ]];then
|
||||
msg00="[ Error ]: Mountpoint \"$backup_mountpoint\" for Backup Partion \"$backup_partition\" not found.\n"
|
||||
@@ -110,20 +115,54 @@ if $extern_usb_disk || $extern_sata_disk || $intern_disk ; then
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
elif $check_mountpoint ; then
|
||||
|
||||
elif $remote_disk ; then
|
||||
|
||||
if ! df | grep "$backup_mountpoint" > /dev/null 2>&1 ;then
|
||||
msg00="[ Error ]: Mountpoint \"$backup_mountpoint\" for Backup Partion \"$backup_partition\" not found.\n"
|
||||
msg01=" exiting now.."
|
||||
msg="${msg00}\n${msg01}"
|
||||
mount "$backup_mountpoint" > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
if ! df | grep "$backup_mountpoint" > /dev/null 2>&1 ;then
|
||||
msg="[ Error ]: Mounting remote disk to '$backup_mountpoint' failed. exiting now.."
|
||||
if $manual ; then
|
||||
echo -e "\n$msg\n"
|
||||
else
|
||||
datum=`date +"%d.%m.%Y"`
|
||||
echo -e "To:${admin_email}\nSubject:Backup Errors $company -- $datum\n${msg}\n" | /usr/sbin/sendmail -F "Errors BACKUP $company" -f $from_address $admin_email
|
||||
echo -e "To:${admin_email}\n${content_type}\nSubject:Backup Errors $company -- $datum\n${msg}\n" | /usr/sbin/sendmail -F "Errors BACKUP $company" -f $from_address $admin_email
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#elif $check_mountpoint ; then
|
||||
# if ! df | grep "$backup_mountpoint" > /dev/null 2>&1 ;then
|
||||
# msg00="[ Error ]: Mountpoint \"$backup_mountpoint\" for Backup Partion \"$backup_partition\" not found.\n"
|
||||
# msg01=" exiting now.."
|
||||
# msg="${msg00}\n${msg01}"
|
||||
# if $manual ; then
|
||||
# echo -e "\n$msg\n"
|
||||
# else
|
||||
# datum=`date +"%d.%m.%Y"`
|
||||
# echo -e "To:${admin_email}\nSubject:Backup Errors $company -- $datum\n${msg}\n" | /usr/sbin/sendmail -F "Errors BACKUP $company" -f $from_address $admin_email
|
||||
# fi
|
||||
# exit 1
|
||||
# fi
|
||||
fi
|
||||
|
||||
if $extern_usb_disk || $extern_sata_disk || $intern_disk || $remote_disk ; then
|
||||
sleep 2
|
||||
if ! df | grep "$backup_partition" > /dev/null 2>&1 ;then
|
||||
msg="[ Error ]: Cannot mount Backup Partion \"$backup_partition\". exiting now.."
|
||||
if $manual ; then
|
||||
echo -e "\n$msg\n"
|
||||
else
|
||||
datum=`date +"%d.%m.%Y"`
|
||||
echo -e "To:${admin_email}\n${content_type}\nSubject:Backup Errors $company -- $datum\n${msg}\n" | /usr/sbin/sendmail -F "Errors BACKUP $company" -f $from_address $admin_email
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
## - $AGENT muss (root) geh<65>ren und darf nicht beschreibbar sein
|
||||
@@ -198,6 +237,7 @@ fi
|
||||
## -
|
||||
if $manual ; then
|
||||
host_scripts="${hosts_base_dir}/localhost.sh"
|
||||
host_scripts="${hosts_base_dir}/gw-km.anw-km.netz.sh"
|
||||
else
|
||||
host_scripts=`$find $hosts_base_dir -maxdepth 1 -type f -perm -700 | $sort`
|
||||
fi
|
||||
@@ -253,38 +293,43 @@ if $found ; then
|
||||
root_s="0$root_s"
|
||||
fi
|
||||
|
||||
|
||||
## - write backup info to
|
||||
## -
|
||||
if $extern_usb_disk || $extern_sata_disk ; then
|
||||
|
||||
## - write backup info to
|
||||
## -
|
||||
|
||||
label=`tune2fs -l $backup_partition | grep -e "Filesystem volume name:" | awk '{print$4}'`
|
||||
|
||||
echo >> $info_file
|
||||
echo -e "\tBackup Host.........: $BACKUP_HOST" >> $info_file
|
||||
echo -e "\tBackup Date.........: `/bin/date +'%d.%m.%Y'`" >> $info_file
|
||||
echo -e "\tBackup Time.........: `/bin/date +'%H:%M'` h" >> $info_file
|
||||
echo >> $info_file
|
||||
echo -e "\tbackup_disk_label...: $label" >> $info_file
|
||||
echo >> $info_file
|
||||
|
||||
#echo -e "\tBackup Size.........: `du -sm $backup_base_dir | awk '{print$1}' ` MB" >> $info_file
|
||||
|
||||
echo >> $info_file
|
||||
|
||||
## - save current backup_disk_label
|
||||
## -
|
||||
echo "$label" > $disk_label_log_file
|
||||
|
||||
if cp $info_file $backup_base_dir > /dev/null ; then
|
||||
echolog "write backup info to $backup_base_dir/`basename $info_file` .. [ ok ] \n"
|
||||
else
|
||||
echolog "[Error]: write backup info to $backup_base_dir/`basename $info_file` ..[ failed ]\n"
|
||||
fi
|
||||
|
||||
rm -f $info_file
|
||||
label="$(tune2fs -l $backup_partition | grep -e "Filesystem volume name:" | awk '{print$4}')"
|
||||
elif $remote_disk ; then
|
||||
label="$backup_resource"
|
||||
elif $intern_disk ; then
|
||||
label="$backup_partition"
|
||||
else
|
||||
label="$backup_base_dir"
|
||||
fi
|
||||
|
||||
echo >> $info_file
|
||||
echo -e "\tBackup Host...............: $BACKUP_HOST" >> $info_file
|
||||
echo -e "\tBackup Date...............: `/bin/date +'%d.%m.%Y'`" >> $info_file
|
||||
echo -e "\tBackup Time...............: `/bin/date +'%H:%M'` h" >> $info_file
|
||||
echo >> $info_file
|
||||
echo -e "\tBackup resource / Label...: $label" >> $info_file
|
||||
echo >> $info_file
|
||||
|
||||
#echo -e "\tBackup Size.........: `du -sm $backup_base_dir | awk '{print$1}' ` MB" >> $info_file
|
||||
|
||||
echo >> $info_file
|
||||
|
||||
## - save current backup_disk_label
|
||||
## -
|
||||
echo "$label" > $disk_label_log_file
|
||||
|
||||
if cp $info_file $backup_base_dir > /dev/null ; then
|
||||
echolog "write backup info to $backup_base_dir/`basename $info_file` .. [ ok ] \n"
|
||||
else
|
||||
echolog "[Error]: write backup info to $backup_base_dir/`basename $info_file` ..[ failed ]\n"
|
||||
fi
|
||||
|
||||
rm -f $info_file
|
||||
|
||||
echolog "\nend backup \"$company\" : $root_backup_date ( ${root_end_h}:${root_end_m} h ) - duration: ${root_h} h : ${root_m} min : ${root_s} sec\n\n"
|
||||
|
||||
|
||||
@@ -351,8 +396,8 @@ if $extern_usb_disk || $extern_sata_disk ; then
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
$umount $backup_partition 2> /dev/null
|
||||
elif $remote_disk || $intern_disk ; then
|
||||
$umount $backup_mountpoint 2> /dev/null
|
||||
fi
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user