update 20160920
This commit is contained in:
64
borgbackup.sh
Normal file
64
borgbackup.sh
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
MountScript1="$1"
|
||||
UmountScript1="$2"
|
||||
MountScript2="$3"
|
||||
UmountScript2="$4"
|
||||
SCRPATHPREFIX="$5"
|
||||
REPOSITORYPATH="$6"
|
||||
REPOSITORYNAME="$(basename ${REPOSITORYPATH})"
|
||||
REPOSITORYPATH="${REPOSITORYPATH}/backup"
|
||||
REPOSITORYNAMENOW="${REPOSITORYNAME}-$(date +%Y-%m-%d)"
|
||||
|
||||
red=`tput setaf 1`
|
||||
green=`tput setaf 2`
|
||||
yellow=`tput setaf 3`
|
||||
reset=`tput sgr0`
|
||||
|
||||
|
||||
echo "${green}### start borg backup${reset}"
|
||||
|
||||
CMD=("sudo" "sh" "${MountScript1}")
|
||||
if ! "${CMD[@]}"; then
|
||||
sudo sh "${UmountScript1}"
|
||||
echo "${red}Error(1): execution of mount script ${yellow} ${MountScript1} ${red} failed${reset}"
|
||||
exit 1
|
||||
else
|
||||
echo "${green}Succesfull(1): mount script ${yellow} ${MountScript1} ${green} execution was successfull.${reset}"
|
||||
fi
|
||||
|
||||
CMD=("sudo" "sh" "${MountScript2}")
|
||||
if ! "${CMD[@]}"; then
|
||||
sudo sh "${UmountScript1}"
|
||||
sudo sh "${UmountScript2}"
|
||||
echo "${red}Error(1): execution of mount script ${yellow} ${MountScript2} ${red} failed${reset}"
|
||||
exit 1
|
||||
else
|
||||
echo "${green}Succesfull(1): mount script ${yellow} ${MountScript2} ${green} execution was successfull.${reset}"
|
||||
fi
|
||||
|
||||
CMD=("borg" "create" "-v" "--compression" "lzma,9" "${REPOSITORYPATH}::${REPOSITORYNAMENOW}" "${SCRPATHPREFIX}/backup/system-home-snapshot/dev" "${SCRPATHPREFIX}/backup/system-home-snapshot/home" "${SCRPATHPREFIX}/backup/system-home-snapshot/game/.pwsafe" "${SCRPATHPREFIX}/backup/media-docs-snapshot")
|
||||
if ! "${CMD[@]}"; then
|
||||
sudo sh "${UmountScript1}"
|
||||
sudo sh "${UmountScript2}"
|
||||
echo "${red}Error(1): creation of repo ${yellow}${REPOSITORYNAMENOW}${red} failed${reset}"
|
||||
exit 1
|
||||
else
|
||||
echo "${green}Succesfull(1):repo ${yellow}${REPOSITORYNAMENOW}${green} created${reset}"
|
||||
fi
|
||||
|
||||
echo "${green}### prune old borg backup${reset}"
|
||||
CMD=("borg" "prune" "-v" "${REPOSITORYPATH}" "--prefix" "${REPOSITORYNAME}" "--keep-daily=")
|
||||
if ! "${CMD[@]}"; then
|
||||
sudo sh "${UmountScript1}"
|
||||
sudo sh "${UmountScript2}"
|
||||
echo "${red}Error(2): prune of repo ${yellow}${REPOSITORYNAME}${red} failed${reset}"
|
||||
exit 1
|
||||
else
|
||||
echo "${green}Succesfull(2): prune of repo ${yellow}${REPOSITORYNAME}${green} was Succesfull${reset}"
|
||||
fi
|
||||
|
||||
echo "${green}### unmount folders${reset}"
|
||||
sudo sh "${UmountScript1}"
|
||||
sudo sh "${UmountScript2}"
|
||||
|
||||
echo "${green}### finished borg backup${reset}"
|
||||
48
cloneBackup.sh
Normal file
48
cloneBackup.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/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}"
|
||||
51
cloneBackup_copyBox.sh
Executable file
51
cloneBackup_copyBox.sh
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
MountScript1="$1"
|
||||
UmountScript1="$2"
|
||||
MountScript2="$3"
|
||||
UmountScript2="$4"
|
||||
CloneMntSrc="$5"
|
||||
CloneMntDst="$6"
|
||||
|
||||
red=`tput setaf 1`
|
||||
green=`tput setaf 2`
|
||||
yellow=`tput setaf 3`
|
||||
reset=`tput sgr0`
|
||||
|
||||
echo "${green}### start clone backup${reset}"
|
||||
|
||||
CMD=("sudo" "sh" "${MountScript1}")
|
||||
if ! "${CMD[@]}"; then
|
||||
sudo sh "${UmountScript1}"
|
||||
echo "${red}Error(1): execution of mount script ${yellow} ${MountScript1} ${red} failed${reset}"
|
||||
exit 1
|
||||
else
|
||||
echo "${green}Succesfull(1): mount script ${yellow} ${MountScript1} ${green} execution was successfull.${reset}"
|
||||
fi
|
||||
|
||||
CMD=("sudo" "sh" "${MountScript2}")
|
||||
if ! "${CMD[@]}"; then
|
||||
sudo sh "${UmountScript1}"
|
||||
sudo sh "${UmountScript2}"
|
||||
echo "${red}Error(1): execution of mount script ${yellow} ${MountScript2} ${red} failed${reset}"
|
||||
exit 1
|
||||
else
|
||||
echo "${green}Succesfull(1): mount script ${yellow} ${MountScript2} ${green} execution was successfull.${reset}"
|
||||
fi
|
||||
|
||||
echo "${green}--- start rsync-clonebackup from ${yellow}${CloneMntSrc}${green} to ${yellow}${CloneMntDst}${reset}"
|
||||
CMD=("sudo" "rsync" "-PWavxh" "--delete" "--progress" "-e" "ssh" "${CloneMntSrc}" "${CloneMntDst}")
|
||||
if ! "${CMD[@]}"; then
|
||||
sudo sh "${UmountScript1}"
|
||||
sudo sh "${UmountScript2}"
|
||||
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}"
|
||||
sudo sh "${UmountScript1}"
|
||||
sudo sh "${UmountScript2}"
|
||||
|
||||
echo "${green}### finished clone backup${reset}"
|
||||
2
connect2CopyBox.sh
Executable file
2
connect2CopyBox.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
ssh -t copybox@stubbfelpi.lan tmux a -t copyBox
|
||||
51
copybox@stubbfelpi.lan
Executable file
51
copybox@stubbfelpi.lan
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
MountScript1="$1"
|
||||
UmountScript1="$2"
|
||||
MountScript2="$3"
|
||||
UmountScript2="$4"
|
||||
CloneMntSrc="$5"
|
||||
CloneMntDst="$6"
|
||||
|
||||
red=`tput setaf 1`
|
||||
green=`tput setaf 2`
|
||||
yellow=`tput setaf 3`
|
||||
reset=`tput sgr0`
|
||||
|
||||
echo "${green}### start clone backup${reset}"
|
||||
|
||||
CMD=("sudo" "sh" "${MountScript1}")
|
||||
if ! "${CMD[@]}"; then
|
||||
sudo sh "${UmountScript1}"
|
||||
echo "${red}Error(1): execution of mount script ${yellow} ${MountScript1} ${red} failed${reset}"
|
||||
exit 1
|
||||
else
|
||||
echo "${green}Succesfull(1): mount script ${yellow} ${MountScript1} ${green} execution was successfull.${reset}"
|
||||
fi
|
||||
|
||||
CMD=("sudo" "sh" "${MountScript2}")
|
||||
if ! "${CMD[@]}"; then
|
||||
sudo sh "${UmountScript1}"
|
||||
sudo sh "${UmountScript2}"
|
||||
echo "${red}Error(1): execution of mount script ${yellow} ${MountScript2} ${red} failed${reset}"
|
||||
exit 1
|
||||
else
|
||||
echo "${green}Succesfull(1): mount script ${yellow} ${MountScript2} ${green} execution was successfull.${reset}"
|
||||
fi
|
||||
|
||||
echo "${green}--- start rsync-clonebackup from ${yellow}${CloneMntSrc}${green} to ${yellow}${CloneMntDst}${reset}"
|
||||
CMD=("sudo" "rsync" "-PWavxh" "--delete" "--progress" "-e" "ssh" "${CloneMntSrc}" "${CloneMntDst}")
|
||||
if ! "${CMD[@]}"; then
|
||||
sudo sh "${UmountScript1}"
|
||||
sudo sh "${UmountScript2}"
|
||||
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}"
|
||||
sudo sh "${UmountScript1}"
|
||||
sudo sh "${UmountScript2}"
|
||||
|
||||
echo "${green}### finished clone backup${reset}"
|
||||
@@ -83,7 +83,7 @@ else
|
||||
fi
|
||||
|
||||
echo "${green}--- start rsync-backup from ${yellow}$MLVPATH${green} to ${yellow}$ZPATH${reset}"
|
||||
CMD=("sudo" "rsync" "-Pavxh" "--delete" "--progress" "-e" "ssh" "$MLVPATH" "$ZPATH")
|
||||
CMD=("sudo" "rsync" "-PWavxh" "--delete" "--progress" "-e" "ssh" "$MLVPATH" "$ZPATH")
|
||||
if ! "${CMD[@]}"; then
|
||||
echo "${red}Error(4): rsync-backup aborted${pink}"
|
||||
unMountDir $blue "Cleanup"
|
||||
|
||||
Reference in New Issue
Block a user