update 20160602

This commit is contained in:
stubbfel
2016-06-02 22:35:22 +02:00
parent 7e38f51896
commit 784c32a214
5 changed files with 127 additions and 5 deletions

19
backup_lv_z.sh Normal file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
VG=$1
LV=$2
BPATH=$3
SNAME="${VG}-${LV}-snapshot"
OLVPATH="/dev/${VG}/${LV}"
MLVPATH="/mnt/${SNAME}"
SPATH="/dev/${VG}/${SNAME}"
ZPATH="${BPATH}/${SNAME}"
sudo lvcreate -L10G -s -n $SNAME $OLVPATH
sudo mkdir -p $MLVPATH
sudo mount $SPATH $MLVPATH
sudo rdiff --check-destination-dir --compare-hash $MLVPATH $ZPATH
sudo umount $MLVPATH
sudo rmdir $MLVPATH
sudo lvremove -f $SPATH

View File

@@ -3,8 +3,8 @@ sudo sh backup_lv.sh system root /run/mount/backup
sudo sh backup_lv.sh system home /run/mount/backup
sudo sh backup_lv.sh tank playonlinux /run/mount/backup
sudo sh backup_lv.sh tank steamgames /run/mount/backup
sudo sh backup_lv.sh media audio /run/mount/backup
sudo sh backup_lv.sh media books /run/mount/backup
sudo sh backup_lv.sh media docs /run/mount/backup
sudo sh backup_lv.sh media projects /run/mount/backup
sudo sh backup_lv.sh media video /run/mount/backup
#sudo sh backup_lv.sh media audio /run/mount/backup
#sudo sh backup_lv.sh media books /run/mount/backup
#sudo sh backup_lv.sh media docs /run/mount/backup
#sudo sh backup_lv.sh media projects /run/mount/backup
#sudo sh backup_lv.sh media video /run/mount/backup

View File

@@ -0,0 +1,3 @@
#!/bin/bash
for service in `journalctl -b | grep quick | grep "\.service" | cut -d ' ' -f 6 | cut -d ':' -f 1 | sort | uniq`; do systemctl status $service; done > reason.txt

1
playradio.sh Normal file
View File

@@ -0,0 +1 @@
./rtl_fm -f 96.3e6 -M wbfm -s 200000 -r 48000 - | aplay -r 48 -f S16_LE

99
rdiff_backup_lv.sh Normal file
View File

@@ -0,0 +1,99 @@
#!/bin/bash
VG=$1
LV=$2
BPATH=$3
SNAME="${VG}-${LV}-snapshot"
OLVPATH="/dev/${VG}/${LV}"
MLVPATH="/mnt/${SNAME}"
SPATH="/dev/${VG}/${SNAME}"
ZPATH="${BPATH}/${SNAME}"
red=`tput setaf 1`
blue=`tput setaf 4`
green=`tput setaf 2`
yellow=`tput setaf 3`
pink=`tput setaf 5`
reset=`tput sgr0`
function removeSnapshot
{
COLOR="$1"
STEP="$2"
CMD="sudo lvremove -f $SPATH"
if ! $CMD; then
echo "${red}Error(${STEP}): removed snapshot - ${yellow}$SPATH${red} failed${reset}"
exit 1
else
echo "${COLOR}Succesfull(${STEP}): removed snapshot - ${yellow}$SPATH${reset}"
fi
}
function removeMountDir
{
COLOR="$1"
STEP="$2"
CMD=" sudo rmdir $MLVPATH"
if ! $CMD; then
echo "${red}Error(${STEP}): removed mount folder - ${yellow}$SPATH${red} failed${reset}"
exit 1
else
echo "${COLOR}Succesfull(${STEP}): removed mount folder - ${yellow}$MLVPATH${pink}"
fi
}
function unMountDir
{
COLOR="$1"
STEP="$2"
CMD=" sudo umount $MLVPATH"
if ! $CMD; then
echo "${red}Error(${STEP}): unmounted - ${yellow}$MLVPATH${red} failed${reset}"
exit 1
else
echo "${COLOR}Succesfull(${STEP}): unmounted - ${yellow}$MLVPATH${pink}"
fi
}
echo "${green}=== start backup for ${yellow}$OLVPATH${pink}"
CMD=" sudo lvcreate -L10G -s -n $SNAME $OLVPATH"
if ! $CMD; then
echo "${red}Error(1): snapshot ${yellow}$SNAME${green} failed${reset}"
exit 1
else
echo "${green}Succesfull(1): snapshot ${yellow}$SNAME${green} created.${pink}"
fi
CMD=" sudo mkdir -p $MLVPATH"
if ! $CMD; then
echo "${red}Error(2): snapshot mount folder ${yellow}$MLVPATH${green} failed${pink}"
removeSnapshot $blue "Cleanup"
exit 1
else
echo "${green}Succesfull(2): snapshot mount folder ${yellow}$MLVPATH${green} created.${pink}"
fi
CMD=" sudo mount $SPATH $MLVPATH"
if ! $CMD; then
echo "${red}Error(3): mount ${yellow}$SPATH${red} to ${yellow}$MLVPATH${red} failed${pink}"
removeMountDir $blue "Cleanup"
removeSnapshot $blue "Cleanup"
exit 1
else
echo "${green}Succesfull(3): mount ${yellow}$SPATH${green} to ${yellow}$MLVPATH${pink}"
fi
echo "${green}--- start rdiff-backup from ${yellow}$MLVPATH${green} to ${yellow}$ZPATH${pink}"
CMD=" sudo rdiff $MLVPATH $ZPATH"
if ! $CMD; then
echo "${red}Error(4): rdiff-backup aborted${pink}"
unMountDir $blue "Cleanup"
removeMountDir $blue "Cleanup"
removeSnapshot $blue "Cleanup"
exit 1
else
echo "${green}Succesfull(4): rdiff-backup finished${pink}"
fi
unMountDir $green "5"
removeMountDir $green "6"
removeSnapshot $green "7"