Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # name: 04_system_backup.sh
- # path: /root/Configs/Backup_Scripts/04_system_backup.sh
- #### #### #### ####
- # usage: sh $0 $1 #as root
- #### #### #### ####
- # comment: backs up the complete system to the external hard-disk, partition1
- #### #### #### ####
- clear
- date
- echo "
- "
- ########
- # VARs
- ########
- BU_MP="/media/backup"
- BU_DEV=
- USER=`id -u`
- #########################################
- # Check for the conditio sine qua non
- #########################################
- if [ "$USER" -eq 0 ]
- then
- echo "you are root. All cool"
- if [ "$#" == 1 ]
- then
- BU_DEV="$1"
- echo "We will mount "$1" on "$BU_MP", correct? "
- read answer
- case "$answer" in
- "yes" | "y" | "Yes" ) echo "ok" ;;
- "no" | "n" | "No" ) echo " Check the code"
- exit 0 ;;
- * ) "you are too dumb to give a simple answer"
- exit 0 ;;
- esac
- else
- echo "You missed the device to be mounted. Do it now"
- fdisk -l
- echo -n "which one, full name, like /dev/sdx? "
- read BU_DEV
- echo "We will mount "$BU_DEV" on "$BU_MP", correct? "
- read answer
- case "$answer" in
- "yes" | "y" | "Yes") echo "ok" ;;
- "no" | "n" | "No" ) echo "Check the code"
- exit 0 ;;
- * ) echo "Visit a shrink"
- exit 0
- esac
- fi
- else
- echo "You need to run the script as root"
- echo " Add a device which shall be mounted "
- exit 0
- fi
- ##############################
- # Mount "$BU_DEV" on "$BU_MP"
- ##############################
- mount "$BU_DEV" "$BU_MP"
- ls /media/backup
- echo -n "Looks good, you wanna run rsync now? "
- read answer
- case "$answer" in
- "yes" | "y" | "Yes" ) echo "ok" ;;
- "No" | "n" | "No" ) echo "Check the code"
- umount "$BU_MP"
- exit 0 ;;
- * ) echo "Have a break, pal"
- umount "$BU_MP"
- exit 0
- esac
- ################################
- # run the Backup
- # remove " -n and > dry.txt once you know it works
- ##################################################
- rsync -auv -n --delete-after \
- --exclude="/home/m1arkust/[a-zA-Z0-9]*" \
- --exclude="/home/m1arkust/.VirtualBox/*" \
- --exclude="/home/xepanche/[a-zA-Z0-9]*" \
- --exclude="/proc/*" \
- --exclude="/lost+found/*" \
- --exclude="/dev/*" \
- --exclude="/mnt/*" \
- --exclude="/media/*" \
- --exclude="/sys/*" \
- --exclude="/tmp/*" \
- / /media/backup > dry.txt
- ######################
- # Last infos
- #######################
- echo "
- Rsync did finish, here is the actual content of "$BU_MP" "
- ls "$BU_MP"
- echo "
- If it is wrong you are on your own. "
- echo "
- "$BU_MP" will be umounted now"
- umount "$BU_MP"
- echo "
- Bye
- "
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement