49 lines
1.4 KiB
Bash
49 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
MountScript="$1"
|
|
UmountScript="$2"
|
|
CloneMnt="$3"
|
|
|
|
red=`tput setaf 1`
|
|
green=`tput setaf 2`
|
|
yellow=`tput setaf 3`
|
|
reset=`tput sgr0`
|
|
|
|
echo "${green}### start clone backup${reset}"
|
|
|
|
CMD=("sudo" "sh" "${MountScript}")
|
|
if ! "${CMD[@]}"; then
|
|
sudo sh "${UmountScript}"
|
|
echo "${red}Error(1): execution of mount script ${yellow} ${MountScript} ${red} failed${reset}"
|
|
exit 1
|
|
else
|
|
echo "${green}Succesfull(1): mount script ${yellow} ${MountScript} ${green} execution was successfull.${reset}"
|
|
fi
|
|
|
|
CMD=("ssh" "-t" "root.router" "./mount_backup.sh")
|
|
if ! "${CMD[@]}"; then
|
|
ssh root.router "./umount_backup.sh"
|
|
sudo sh "${UmountScript}"
|
|
echo "${red}Error(2): remote mount failed${reset}"
|
|
exit 1
|
|
else
|
|
echo "${green}Succesfull(2): remote mount success.${reset}"
|
|
fi
|
|
|
|
echo "${green}--- start rsync-clonebackup from ${yellow}root.router:/mnt/backup${green} to ${yellow}$CloneMnt${reset}"
|
|
CMD=("sudo" "rsync" "-PWavxh" "--delete" "--progress" "-e" "ssh" "root.router:/mnt/backup" "$CloneMnt")
|
|
if ! "${CMD[@]}"; then
|
|
ssh root.router "./umount_backup.sh"
|
|
sudo sh "${UmountScript}"
|
|
echo "${red}Error(4): rsync-clonebackup aborted${reset}"
|
|
exit 1
|
|
else
|
|
echo "${green}Succesfull(4): rdiff-backup finished${reset}"
|
|
fi
|
|
|
|
echo "${green}### unmount folders${reset}"
|
|
ssh root.router "./umount_backup.sh"
|
|
sudo sh "${UmountScript}"
|
|
|
|
echo "${green}### finished clone backup${reset}"
|