From 48285ed37f78efacbde4468a23a578e27a340fba Mon Sep 17 00:00:00 2001 From: syamgk Date: Mon, 13 Apr 2015 11:43:01 +0530 Subject: Added backup script --- incremental-complete-backup/backup-tool.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 incremental-complete-backup/backup-tool.sh diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh new file mode 100644 index 0000000..b357e88 --- /dev/null +++ b/incremental-complete-backup/backup-tool.sh @@ -0,0 +1,6 @@ +#!/bin/bash +#***********************************************# +# Gui tool to create backups of FOSSEE laptop # +# to external storage media. # +# # +#***********************************************# -- cgit From 0c779cb8dbc21021e48d80912cb31f3640557355 Mon Sep 17 00:00:00 2001 From: syamgk Date: Mon, 13 Apr 2015 12:09:45 +0530 Subject: created gui skelton --- incremental-complete-backup/backup-tool.sh | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index b357e88..0899fa4 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -4,3 +4,46 @@ # to external storage media. # # # #***********************************************# + +#functions() +# --------------------------------------------------------- # +# selection_menu () # +# shows the menu with two options. # +# Parameter: $1(title) $2(option1) $3(option2) # +# change the value of $result to 1 or 2 according to option # +# selected. # +# --------------------------------------------------------- # +selection_menu() { +choice="$(zenity --width=600 --height=200 --list --radiolist --title="$1" --text "Choose : " --hide-header --column "selection" --column "options" FALSE "$2" FALSE "$3")" + +case "${choice}" in + $2 ) + result="1" + ;; + $3 ) + result="2" + ;; +esac +} +################################################################################### +# Execution starts here. + +zenity --width=600 --height=200 --info --text "You need an 8Gb or above external storage device (sdcard /pendrive) to continue" +selection_menu "Select Backup mode" "Incremental Backup" "Complete Backup" +case "${result}" in + "1" ) #Incremental + selection_menu "Incremental Backup options" "Continue with previous backup storage[if you have a previous incremental backup] " "Create a new backup by formating the storage" + case "${result}" in + "1" ) #continue rsync the storage + echo "rsync" + ;; + "2" ) #start new rsync + echo "start inc Bkup" + ;; + esac + ;;#Complete + "2" ) + echo "Do a complete Backup" + ;; +esac + -- cgit From e2c3cd33d3698e1cf375573401a49cafd801b6ea Mon Sep 17 00:00:00 2001 From: syamgk Date: Mon, 13 Apr 2015 15:28:16 +0530 Subject: add more function. added functions selection_menu, sudoAccess, removeSDCARD, insertSDCARD, sizeofSDCARD. --- incremental-complete-backup/backup-tool.sh | 125 ++++++++++++++++++++++++++--- 1 file changed, 115 insertions(+), 10 deletions(-) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index 0899fa4..65a21b3 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -5,30 +5,135 @@ # # #***********************************************# -#functions() -# --------------------------------------------------------- # -# selection_menu () # -# shows the menu with two options. # -# Parameter: $1(title) $2(option1) $3(option2) # -# change the value of $result to 1 or 2 according to option # -# selected. # -# --------------------------------------------------------- # +# functions() +# ########### +# ------------------------------------------------------------# +# selection_menu () # +# shows the menu with two options. # +# Parameter: $1(title) $2(option1) $3(option2) # +# change the value of $result to 1 or 2 according to option # +# selected. # +# ------------------------------------------------------------# selection_menu() { choice="$(zenity --width=600 --height=200 --list --radiolist --title="$1" --text "Choose : " --hide-header --column "selection" --column "options" FALSE "$2" FALSE "$3")" case "${choice}" in $2 ) - result="1" + result="1" # if option1 is selected. ;; $3 ) - result="2" + result="2" # if option2 is selected. ;; esac } +# ------------------------------------------------------------# +# sudoAccess () # +# get the sudo password from user via zenity window and # +# stores in a global variable ($password). # +# # +# ------------------------------------------------------------# +sudoAccess() { +# Remove any previous sudo passwords +sudo -K +# In case of wrong password, else condition will fail(return 1) +# and executes from beginning +while true +do +# Get password from user +password=$(zenity --title "Enter your password to continue" --password) +# zenity dialog button 'Cancel' returns 1, and 'Yes' returns 0. +# Check for zenity 'Cancel' option +if [ $? -eq 1 ] +then +exit 0 +else +# sending user entered password to 'echo' command to verify +# password, if wrong it will repeat from beginning +echo $password | sudo -S echo "test">/dev/null +if [ $? -eq 0 ] +then +break +fi +fi +done +} +# ------------------------------------------------------------# +# Prompt a dialog box asking user to remove all the external # +# media and after that stores the size of disk without media # +# on $sizeofDiskBeforeSDCARD # +# ------------------------------------------------------------# +removeSDCARD() { +# The dialog box below will ask user to remove drive(sdcard) +zenity --question --title "Remove media" \ +--text "Please remove your drive(sdcard) if connected, +then press YES to continue" +# Checking the return value of zenity dialog, same as previous function +if [ $? -eq 1 ] +then +exit 0 +else +# This will return size of disk without our media +sizeofDiskBeforeSDCARD=$(echo $password | sudo -S sfdisk -s\ +| tail -1 | awk '{print $2}') +fi +} +# ------------------------------------------------------------# +# Prompt a dialog box asking user to connect the required # +# media stores the size of disk after inserting the media # +# on $sizeofDiskAfterSDCARD. # +# ------------------------------------------------------------# +insertSDCARD() { +# The dialog box below will ask user to insert sdcard +zenity --question --title "Insert media" --text "Now please insert your drive(sdcard) back,\ +then press YES to continue" +# Checking the button selected in zenity dialog +if [ $? -eq 1 ] +then +exit 0 +else +# sfdisk prints the total disk space in KB +sizeofDiskAfterSDCARD=$(echo $password | sudo -S sfdisk -s\ +| tail -1 | awk '{print $2}') +fi +} +# ------------------------------------------------------------# +# Prompt a dialog box showing the size of detected media in # +# GB. After calculating difference of sizeofDiskBeforeSDCARD # +# and sizeofDiskAfterSDCARD # +# ------------------------------------------------------------# +SizeofSDCARD() { +# verifying new device by finding difference in size +# before and after insertion +sizeSDCARDKbytes=$(($sizeofDiskAfterSDCARD - $sizeofDiskBeforeSDCARD)) +# Converting into GB first +sizeSDCARD=$(echo "scale=2;$sizeSDCARDKbytes/1048576" | bc) +# Converting sizeSDCARD to integer, so as to use in conditional statement, +# if any card is detected it will go inside 'else' statement +if [ $(echo $sizeSDCARD |cut -f 1 -d '.') -eq 0 ] +then +zenity --info --title "Info" --text "No media found, please check and restart application" +exit 0 +else +zenity --question --title "Info" --text "A device of $sizeSDCARD GB is detected, the size will be less \ +than actual size of your device. Would you like to continue? \ +Press 'YES' to continue or 'NO' to quit !" +# If 'NO' is selected in zenity dialog then exit +if [ $? -eq 1 ] +then +exit 0 +fi +fi +} + + ################################################################################### # Execution starts here. zenity --width=600 --height=200 --info --text "You need an 8Gb or above external storage device (sdcard /pendrive) to continue" +sudoAccess +removeSDCARD +insertSDCARD +SizeofSDCARD selection_menu "Select Backup mode" "Incremental Backup" "Complete Backup" case "${result}" in "1" ) #Incremental -- cgit From 654b41a7c211d444ad65f20d737ff09ba4a836c0 Mon Sep 17 00:00:00 2001 From: syamgk Date: Wed, 15 Apr 2015 15:28:39 +0530 Subject: Added commands to track rootfs,device and some rough rsync commands on place. --- incremental-complete-backup/backup-tool.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index 65a21b3..859334a 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -73,13 +73,14 @@ then exit 0 else # This will return size of disk without our media +umount /media/$USER/* # to unmount all external media. sizeofDiskBeforeSDCARD=$(echo $password | sudo -S sfdisk -s\ | tail -1 | awk '{print $2}') fi } # ------------------------------------------------------------# # Prompt a dialog box asking user to connect the required # -# media stores the size of disk after inserting the media # +# media & stores the size of disk after inserting the media # # on $sizeofDiskAfterSDCARD. # # ------------------------------------------------------------# insertSDCARD() { @@ -129,7 +130,7 @@ fi ################################################################################### # Execution starts here. -zenity --width=600 --height=200 --info --text "You need an 8Gb or above external storage device (sdcard /pendrive) to continue" +zenity --width=600 --height=200 --info --text "You need an 8GB or above external storage device (sdcard /pendrive) to continue" sudoAccess removeSDCARD insertSDCARD @@ -139,16 +140,27 @@ case "${result}" in "1" ) #Incremental selection_menu "Incremental Backup options" "Continue with previous backup storage[if you have a previous incremental backup] " "Create a new backup by formating the storage" case "${result}" in - "1" ) #continue rsync the storage - echo "rsync" + "1" ) # check for mac_id matching & proceed to rsync + rootfs_path=`mount | grep ext|cut -d" " -f3` # tracking the rootfs mount path + mac_id=`cat /sys/class/net/eth0/address` # macid of the machine + if [ "$rootfs_path" == "" ] || [ "$mac_id" -ne `cat $rootfs_path/opt/.Hw_addr.txt` ]; + then + zenity --width=600 --height=100 --info --text "Your storage media doesnot contain matching backup from this machine" + else +# rsync -avzr / $rootfs_path + fi ;; "2" ) #start new rsync + cat /sys/class/net/eth0/address > /opt/.Hw_addr.txt # storing mac_id b4 copy + umount /media/$USER/* + echo $password echo "start inc Bkup" ;; esac - ;;#Complete - "2" ) + ;; + "2" ) #Complete echo "Do a complete Backup" + sudo tar -cpzf /media/student//FirmwareInstall/ubuntu/ubuntu13.04.tar --one-file-system / ;; esac -- cgit From 5c3632ea672a86f851ad0b1eb6f39e2f13da242e Mon Sep 17 00:00:00 2001 From: syamgk Date: Thu, 16 Apr 2015 16:53:41 +0530 Subject: added formating functionality --- incremental-complete-backup/backup-tool.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index 859334a..69a7f23 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -1,4 +1,4 @@ -#!/bin/bash +:!/bin/bash #***********************************************# # Gui tool to create backups of FOSSEE laptop # # to external storage media. # @@ -135,6 +135,7 @@ sudoAccess removeSDCARD insertSDCARD SizeofSDCARD +dev_name=`lsblk |head -2|tail -1|cut -d" " -f1` # tracking device name selection_menu "Select Backup mode" "Incremental Backup" "Complete Backup" case "${result}" in "1" ) #Incremental @@ -144,23 +145,24 @@ case "${result}" in rootfs_path=`mount | grep ext|cut -d" " -f3` # tracking the rootfs mount path mac_id=`cat /sys/class/net/eth0/address` # macid of the machine if [ "$rootfs_path" == "" ] || [ "$mac_id" -ne `cat $rootfs_path/opt/.Hw_addr.txt` ]; - then + then # (no rootfs) or ( macids not matching) zenity --width=600 --height=100 --info --text "Your storage media doesnot contain matching backup from this machine" + exit else -# rsync -avzr / $rootfs_path + rsync -avzr / $rootfs_path fi ;; "2" ) #start new rsync cat /sys/class/net/eth0/address > /opt/.Hw_addr.txt # storing mac_id b4 copy umount /media/$USER/* - echo $password + for each in $(seq 1 $(ls -1 /dev/$dev_name* |sesd 1d|wc -l));do parted -s /dev/$dev_name rm $each;done echo "start inc Bkup" ;; esac ;; "2" ) #Complete + for each in $(seq 1 $(ls -1 /dev/$dev_name* |sesd 1d|wc -l));do parted -s /dev/$dev_name rm $each;done echo "Do a complete Backup" sudo tar -cpzf /media/student//FirmwareInstall/ubuntu/ubuntu13.04.tar --one-file-system / ;; esac - -- cgit From 828d8f5acd064c2681667954605113a1c95ea6d9 Mon Sep 17 00:00:00 2001 From: syamgk Date: Thu, 16 Apr 2015 20:20:12 +0530 Subject: changed loops and conditions --- incremental-complete-backup/backup-tool.sh | 46 +++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index 69a7f23..3a9a840 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -1,4 +1,4 @@ -:!/bin/bash +#!/bin/bash #***********************************************# # Gui tool to create backups of FOSSEE laptop # # to external storage media. # @@ -125,7 +125,20 @@ exit 0 fi fi } - +# ------------------------------------------------------------# +# unmount the mounted partitions, create new partition table # +# format 1st partition to vfat, 2nd to ext4 and mount under # +# /mnt # +# ------------------------------------------------------------# +formatExternalmedia() { +umount /media/$USER/* +echo $password |sudo -S mkdir -p /mnt/boot /mnt/rootfs +echo -e "o\nn\np\n1\n\n+100M\nn\np\n2\n\n\nw"|sudo fdisk /dev/$dev_name # delete old partition table and creating new +sudo mkfs.vfat /dev/$dev_name*1 +sudo mkfs -t ext4 /dev/$dev_name*2 +sudo mount /dev/$dev_name*1 /mnt/boot +sudo mount /dev/$dev_name*2 /mnt/rootfs +} ################################################################################### # Execution starts here. @@ -144,25 +157,36 @@ case "${result}" in "1" ) # check for mac_id matching & proceed to rsync rootfs_path=`mount | grep ext|cut -d" " -f3` # tracking the rootfs mount path mac_id=`cat /sys/class/net/eth0/address` # macid of the machine - if [ "$rootfs_path" == "" ] || [ "$mac_id" -ne `cat $rootfs_path/opt/.Hw_addr.txt` ]; - then # (no rootfs) or ( macids not matching) + if [ "$rootfs_path" == "" ] || [ ! -e $rootfs_path/opt/.Hw_addr.txt ]; + then # (no rootfs) or ( Hw_addr.txt not exists) zenity --width=600 --height=100 --info --text "Your storage media doesnot contain matching backup from this machine" exit + elif [ "$mac_id" == "$(cat $rootfs_path/opt/.Hw_addr.txt)" ]; # if macids are matching + then + echo "match found" + sudo rsync -latgrzpo --exclude='/tmp' --exclude='/dev' --exclude='/proc' --exclude='/sys' /opt $rootfs_path else - rsync -avzr / $rootfs_path + zenity --width=600 --height=100 --info --text "Your storage media doesnot contain matching backup from this machine" + exit fi ;; "2" ) #start new rsync cat /sys/class/net/eth0/address > /opt/.Hw_addr.txt # storing mac_id b4 copy - umount /media/$USER/* - for each in $(seq 1 $(ls -1 /dev/$dev_name* |sesd 1d|wc -l));do parted -s /dev/$dev_name rm $each;done - echo "start inc Bkup" + formatExternalmedia + echo $rootfs_path + sudo rsync -latgrzpo --exclude='/tmp' --exclude='/dev' --exclude='/proc' --exclude='/sys' /opt /mnt/rootfs/ + sync + sudo umount /mnt/* + sudo rm -rf /mnt/* ;; esac ;; "2" ) #Complete - for each in $(seq 1 $(ls -1 /dev/$dev_name* |sesd 1d|wc -l));do parted -s /dev/$dev_name rm $each;done - echo "Do a complete Backup" - sudo tar -cpzf /media/student//FirmwareInstall/ubuntu/ubuntu13.04.tar --one-file-system / + formatExternalmedia + sudo tar -cpzf /mnt/rootfs/ubuntu13.04.tar --one-file-system / + sync + sudo umount /mnt/* + sudo rm -rf /mnt/* ;; esac +zenity --width=600 --height=100 --info --text "Done ! " -- cgit From 32b4b8c6d97e349882b5481d0d703537019e125d Mon Sep 17 00:00:00 2001 From: syamgk Date: Fri, 17 Apr 2015 14:21:22 +0530 Subject: Fix comments Change some comments --- incremental-complete-backup/backup-tool.sh | 43 ++++++++++++++---------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index 3a9a840..36098cb 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -8,7 +8,7 @@ # functions() # ########### # ------------------------------------------------------------# -# selection_menu () # +# selection_menu() # # shows the menu with two options. # # Parameter: $1(title) $2(option1) $3(option2) # # change the value of $result to 1 or 2 according to option # @@ -16,7 +16,6 @@ # ------------------------------------------------------------# selection_menu() { choice="$(zenity --width=600 --height=200 --list --radiolist --title="$1" --text "Choose : " --hide-header --column "selection" --column "options" FALSE "$2" FALSE "$3")" - case "${choice}" in $2 ) result="1" # if option1 is selected. @@ -27,10 +26,8 @@ case "${choice}" in esac } # ------------------------------------------------------------# -# sudoAccess () # -# get the sudo password from user via zenity window and # -# stores in a global variable ($password). # -# # +# sudoAccess() get the sudo password from user via zenity # +# window and stores in a global variable ($password). # # ------------------------------------------------------------# sudoAccess() { # Remove any previous sudo passwords @@ -58,9 +55,9 @@ fi done } # ------------------------------------------------------------# -# Prompt a dialog box asking user to remove all the external # -# media and after that stores the size of disk without media # -# on $sizeofDiskBeforeSDCARD # +# removeSDCARD() Prompt a dialog box asking user to remove # +# all the external media and after that stores the size of # +# disk without media on $sizeofDiskBeforeSDCARD # # ------------------------------------------------------------# removeSDCARD() { # The dialog box below will ask user to remove drive(sdcard) @@ -79,9 +76,9 @@ sizeofDiskBeforeSDCARD=$(echo $password | sudo -S sfdisk -s\ fi } # ------------------------------------------------------------# -# Prompt a dialog box asking user to connect the required # -# media & stores the size of disk after inserting the media # -# on $sizeofDiskAfterSDCARD. # +# insertSDCARD() Prompt a dialog box asking user to connect # +# the required media & stores the size of disk after inserting# +# the media on $sizeofDiskAfterSDCARD. # # ------------------------------------------------------------# insertSDCARD() { # The dialog box below will ask user to insert sdcard @@ -98,9 +95,9 @@ sizeofDiskAfterSDCARD=$(echo $password | sudo -S sfdisk -s\ fi } # ------------------------------------------------------------# -# Prompt a dialog box showing the size of detected media in # -# GB. After calculating difference of sizeofDiskBeforeSDCARD # -# and sizeofDiskAfterSDCARD # +# SizeofSDCARD() Prompt a dialog box showing the size of # +# detected media in GB. After calculating difference of # +# sizeofDiskBeforeSDCARD and sizeofDiskAfterSDCARD # # ------------------------------------------------------------# SizeofSDCARD() { # verifying new device by finding difference in size @@ -126,9 +123,9 @@ fi fi } # ------------------------------------------------------------# -# unmount the mounted partitions, create new partition table # -# format 1st partition to vfat, 2nd to ext4 and mount under # -# /mnt # +# formatExternalmedia() unmount the mounted partitions, create# +# new partition table format 1st partition to vfat, # +# 2nd to ext4 and mount under /mnt # # ------------------------------------------------------------# formatExternalmedia() { umount /media/$USER/* @@ -151,14 +148,14 @@ SizeofSDCARD dev_name=`lsblk |head -2|tail -1|cut -d" " -f1` # tracking device name selection_menu "Select Backup mode" "Incremental Backup" "Complete Backup" case "${result}" in - "1" ) #Incremental + "1" ) # Incremental selection_menu "Incremental Backup options" "Continue with previous backup storage[if you have a previous incremental backup] " "Create a new backup by formating the storage" case "${result}" in - "1" ) # check for mac_id matching & proceed to rsync + "1" ) # "Continue with previous backup": check for mac_id matching & proceed to rsync rootfs_path=`mount | grep ext|cut -d" " -f3` # tracking the rootfs mount path mac_id=`cat /sys/class/net/eth0/address` # macid of the machine if [ "$rootfs_path" == "" ] || [ ! -e $rootfs_path/opt/.Hw_addr.txt ]; - then # (no rootfs) or ( Hw_addr.txt not exists) + then # (no rootfs) or ( /media/rootfs/Hw_addr.txt not exists) zenity --width=600 --height=100 --info --text "Your storage media doesnot contain matching backup from this machine" exit elif [ "$mac_id" == "$(cat $rootfs_path/opt/.Hw_addr.txt)" ]; # if macids are matching @@ -170,7 +167,7 @@ case "${result}" in exit fi ;; - "2" ) #start new rsync + "2" ) # "new incremental backup" start new rsync cat /sys/class/net/eth0/address > /opt/.Hw_addr.txt # storing mac_id b4 copy formatExternalmedia echo $rootfs_path @@ -181,7 +178,7 @@ case "${result}" in ;; esac ;; - "2" ) #Complete + "2" ) # Complete formatExternalmedia sudo tar -cpzf /mnt/rootfs/ubuntu13.04.tar --one-file-system / sync -- cgit From e9edc39ef48d25e6d413dd55ba9cdc848f0d94ef Mon Sep 17 00:00:00 2001 From: syamgk Date: Mon, 20 Apr 2015 14:41:03 +0530 Subject: add formattofat() & made changes on complete back fix conditional in SizeofSDcard --- incremental-complete-backup/backup-tool.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index 36098cb..3ab213d 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -107,7 +107,7 @@ sizeSDCARDKbytes=$(($sizeofDiskAfterSDCARD - $sizeofDiskBeforeSDCARD)) sizeSDCARD=$(echo "scale=2;$sizeSDCARDKbytes/1048576" | bc) # Converting sizeSDCARD to integer, so as to use in conditional statement, # if any card is detected it will go inside 'else' statement -if [ $(echo $sizeSDCARD |cut -f 1 -d '.') -eq 0 ] +if [ $(echo $sizeSDCARD |cut -f 1 -d '.') -le 0 ] then zenity --info --title "Info" --text "No media found, please check and restart application" exit 0 @@ -136,6 +136,18 @@ sudo mkfs -t ext4 /dev/$dev_name*2 sudo mount /dev/$dev_name*1 /mnt/boot sudo mount /dev/$dev_name*2 /mnt/rootfs } +# ------------------------------------------------------------# +# formattofat() unmount the mounted partitions, create # +# new partition table format 1st partition to vfat, # +# # +# ------------------------------------------------------------# +formattofat() { +umount /media/$USER/* +echo $password |sudo -S mkdir -p /mnt/boot +echo -e "o\nn\np\n1\n\n\nw"|sudo fdisk /dev/$dev_name # delete old partition table and creating new +sudo mkfs.vfat /dev/$dev_name*1 +sudo mount -t vfat /dev/$dev_name*1 /mnt/boot -o rw,uid=1000,gid=1000 +} ################################################################################### # Execution starts here. @@ -155,7 +167,7 @@ case "${result}" in rootfs_path=`mount | grep ext|cut -d" " -f3` # tracking the rootfs mount path mac_id=`cat /sys/class/net/eth0/address` # macid of the machine if [ "$rootfs_path" == "" ] || [ ! -e $rootfs_path/opt/.Hw_addr.txt ]; - then # (no rootfs) or ( /media/rootfs/Hw_addr.txt not exists) + then # (no rootfs) or ( rootfs doesn't contain Hw_addr.txt ) zenity --width=600 --height=100 --info --text "Your storage media doesnot contain matching backup from this machine" exit elif [ "$mac_id" == "$(cat $rootfs_path/opt/.Hw_addr.txt)" ]; # if macids are matching @@ -179,10 +191,12 @@ case "${result}" in esac ;; "2" ) # Complete - formatExternalmedia - sudo tar -cpzf /mnt/rootfs/ubuntu13.04.tar --one-file-system / + formattofat + sudo rsync -latgrzpo /opt/fossee-os/* /mnt/boot/ + #rm -f /etc/udev/rules.d/70-persistent-net.rules + sudo tar -cpzf /mnt/boot/fossee-os.tar --one-file-system / sync - sudo umount /mnt/* + echo $password |sudo umount /mnt/* # refresh sudo access sudo rm -rf /mnt/* ;; esac -- cgit From 858b11aaed048092a955c7367ede9f335dbc497c Mon Sep 17 00:00:00 2001 From: syamgk Date: Mon, 20 Apr 2015 14:56:31 +0530 Subject: Change format function names: formatExternalmedia() -> formatforIncremental() formattofat() -> formatforComplete() --- incremental-complete-backup/backup-tool.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index 3ab213d..3788407 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -123,11 +123,11 @@ fi fi } # ------------------------------------------------------------# -# formatExternalmedia() unmount the mounted partitions, create# -# new partition table format 1st partition to vfat, # +# formatforIncremental() unmount the mounted partitions, # +# create new partition table format 1st partition to vfat, # # 2nd to ext4 and mount under /mnt # # ------------------------------------------------------------# -formatExternalmedia() { +formatforIncremental() { umount /media/$USER/* echo $password |sudo -S mkdir -p /mnt/boot /mnt/rootfs echo -e "o\nn\np\n1\n\n+100M\nn\np\n2\n\n\nw"|sudo fdisk /dev/$dev_name # delete old partition table and creating new @@ -137,13 +137,13 @@ sudo mount /dev/$dev_name*1 /mnt/boot sudo mount /dev/$dev_name*2 /mnt/rootfs } # ------------------------------------------------------------# -# formattofat() unmount the mounted partitions, create # +# formatforComplete() unmount the mounted partitions, create # # new partition table format 1st partition to vfat, # # # # ------------------------------------------------------------# -formattofat() { +formatforComplete() { umount /media/$USER/* -echo $password |sudo -S mkdir -p /mnt/boot +echo $password |sudo -S mkdir -p /mnt/boot echo -e "o\nn\np\n1\n\n\nw"|sudo fdisk /dev/$dev_name # delete old partition table and creating new sudo mkfs.vfat /dev/$dev_name*1 sudo mount -t vfat /dev/$dev_name*1 /mnt/boot -o rw,uid=1000,gid=1000 @@ -181,7 +181,7 @@ case "${result}" in ;; "2" ) # "new incremental backup" start new rsync cat /sys/class/net/eth0/address > /opt/.Hw_addr.txt # storing mac_id b4 copy - formatExternalmedia + formatforIncremental echo $rootfs_path sudo rsync -latgrzpo --exclude='/tmp' --exclude='/dev' --exclude='/proc' --exclude='/sys' /opt /mnt/rootfs/ sync @@ -191,7 +191,7 @@ case "${result}" in esac ;; "2" ) # Complete - formattofat + formatforComplete sudo rsync -latgrzpo /opt/fossee-os/* /mnt/boot/ #rm -f /etc/udev/rules.d/70-persistent-net.rules sudo tar -cpzf /mnt/boot/fossee-os.tar --one-file-system / -- cgit From dec9b1688a4d46ba1028081fdb3c4c08d1d21ad7 Mon Sep 17 00:00:00 2001 From: Syam.G.Krishnan Date: Tue, 21 Apr 2015 10:11:03 +0530 Subject: Rename "rootfs".tar --- incremental-complete-backup/backup-tool.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index 3788407..e8a4adb 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -194,7 +194,7 @@ case "${result}" in formatforComplete sudo rsync -latgrzpo /opt/fossee-os/* /mnt/boot/ #rm -f /etc/udev/rules.d/70-persistent-net.rules - sudo tar -cpzf /mnt/boot/fossee-os.tar --one-file-system / + sudo tar -cpzf /mnt/boot/fossee-os.tar.gz --one-file-system / sync echo $password |sudo umount /mnt/* # refresh sudo access sudo rm -rf /mnt/* -- cgit From f1fa1975ae42221ecf01754904d35c1fa24bd834 Mon Sep 17 00:00:00 2001 From: syam Date: Fri, 24 Apr 2015 11:29:39 +0530 Subject: Change rsync and mount Modified the exclude option in rsync command , added more options to mount for read,write. --- incremental-complete-backup/backup-tool.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index e8a4adb..e86c5b2 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -133,7 +133,7 @@ echo $password |sudo -S mkdir -p /mnt/boot /mnt/rootfs echo -e "o\nn\np\n1\n\n+100M\nn\np\n2\n\n\nw"|sudo fdisk /dev/$dev_name # delete old partition table and creating new sudo mkfs.vfat /dev/$dev_name*1 sudo mkfs -t ext4 /dev/$dev_name*2 -sudo mount /dev/$dev_name*1 /mnt/boot +sudo mount -t vfat /dev/$dev_name*1 /mnt/boot -o rw,uid=1000,gid=1000 sudo mount /dev/$dev_name*2 /mnt/rootfs } # ------------------------------------------------------------# @@ -173,7 +173,7 @@ case "${result}" in elif [ "$mac_id" == "$(cat $rootfs_path/opt/.Hw_addr.txt)" ]; # if macids are matching then echo "match found" - sudo rsync -latgrzpo --exclude='/tmp' --exclude='/dev' --exclude='/proc' --exclude='/sys' /opt $rootfs_path + sudo rsync -latgrzpo --exclude='/tmp' --exclude='/dev' --exclude='/proc' --exclude='/sys' / $rootfs_path else zenity --width=600 --height=100 --info --text "Your storage media doesnot contain matching backup from this machine" exit @@ -182,10 +182,10 @@ case "${result}" in "2" ) # "new incremental backup" start new rsync cat /sys/class/net/eth0/address > /opt/.Hw_addr.txt # storing mac_id b4 copy formatforIncremental - echo $rootfs_path - sudo rsync -latgrzpo --exclude='/tmp' --exclude='/dev' --exclude='/proc' --exclude='/sys' /opt /mnt/rootfs/ + sudo rsync -latgrzpo /opt/fossee-os/* /mnt/boot/ + sudo rsync -latgrzpo --exclude='/tmp/*' --exclude='/dev/*' --exclude='/proc/*' --exclude='/sys/*' / /mnt/rootfs/ sync - sudo umount /mnt/* + echo $password |sudo umount /mnt/* # refresh sudo access sudo rm -rf /mnt/* ;; esac @@ -193,7 +193,7 @@ case "${result}" in "2" ) # Complete formatforComplete sudo rsync -latgrzpo /opt/fossee-os/* /mnt/boot/ - #rm -f /etc/udev/rules.d/70-persistent-net.rules + rm -f /etc/udev/rules.d/70-persistent-net.rules sudo tar -cpzf /mnt/boot/fossee-os.tar.gz --one-file-system / sync echo $password |sudo umount /mnt/* # refresh sudo access -- cgit From cf12032dd4e6077893c480b5330875a8d71a40ab Mon Sep 17 00:00:00 2001 From: sgk Date: Fri, 24 Apr 2015 12:50:15 +0530 Subject: Fix $device_name fix tracking $device_name --- incremental-complete-backup/backup-tool.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index e86c5b2..70abeda 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -62,7 +62,7 @@ done removeSDCARD() { # The dialog box below will ask user to remove drive(sdcard) zenity --question --title "Remove media" \ ---text "Please remove your drive(sdcard) if connected, +--text "Please remove your drive (sdcard/pendrive) if connected, then press YES to continue" # Checking the return value of zenity dialog, same as previous function if [ $? -eq 1 ] @@ -82,7 +82,7 @@ fi # ------------------------------------------------------------# insertSDCARD() { # The dialog box below will ask user to insert sdcard -zenity --question --title "Insert media" --text "Now please insert your drive(sdcard) back,\ +zenity --question --title "Insert media" --text "Now please insert your drive(sdcard/pendrive) back,\ then press YES to continue" # Checking the button selected in zenity dialog if [ $? -eq 1 ] @@ -157,7 +157,16 @@ sudoAccess removeSDCARD insertSDCARD SizeofSDCARD -dev_name=`lsblk |head -2|tail -1|cut -d" " -f1` # tracking device name +if [ `ls /dev/mmc*` != "" ] ; +then # memory card detected + $dev_name=`ls /dev/mmc* |head -1` +elif [ `ls /dev/sd*` != "" ]; +then # pendrive detected + $dev_name=`ls /dev/sd* |head -1` +else + zenity --width=600 --height=100 --info --text "Device not found !" + exit +fi selection_menu "Select Backup mode" "Incremental Backup" "Complete Backup" case "${result}" in "1" ) # Incremental @@ -193,6 +202,9 @@ case "${result}" in "2" ) # Complete formatforComplete sudo rsync -latgrzpo /opt/fossee-os/* /mnt/boot/ + rm -r ~/.ssh ~/.mozilla ~/.config/chromium + rm -r ~/Templates ~/Downloads/* + rm ~/.vimrc ~/.viminfo rm -f /etc/udev/rules.d/70-persistent-net.rules sudo tar -cpzf /mnt/boot/fossee-os.tar.gz --one-file-system / sync -- cgit From 5a771443a1bb8731b7e227431e1e25933e5aa4db Mon Sep 17 00:00:00 2001 From: sgk Date: Fri, 24 Apr 2015 12:57:52 +0530 Subject: Remove pendrive support script wont work for pendrive. --- incremental-complete-backup/backup-tool.sh | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/incremental-complete-backup/backup-tool.sh b/incremental-complete-backup/backup-tool.sh index 70abeda..8775464 100644 --- a/incremental-complete-backup/backup-tool.sh +++ b/incremental-complete-backup/backup-tool.sh @@ -62,7 +62,7 @@ done removeSDCARD() { # The dialog box below will ask user to remove drive(sdcard) zenity --question --title "Remove media" \ ---text "Please remove your drive (sdcard/pendrive) if connected, +--text "Please remove your sdcard if connected, then press YES to continue" # Checking the return value of zenity dialog, same as previous function if [ $? -eq 1 ] @@ -82,7 +82,7 @@ fi # ------------------------------------------------------------# insertSDCARD() { # The dialog box below will ask user to insert sdcard -zenity --question --title "Insert media" --text "Now please insert your drive(sdcard/pendrive) back,\ +zenity --question --title "Insert media" --text "Now please insert your sdcard back,\ then press YES to continue" # Checking the button selected in zenity dialog if [ $? -eq 1 ] @@ -152,21 +152,12 @@ sudo mount -t vfat /dev/$dev_name*1 /mnt/boot -o rw,uid=1000,gid=1000 ################################################################################### # Execution starts here. -zenity --width=600 --height=200 --info --text "You need an 8GB or above external storage device (sdcard /pendrive) to continue" +zenity --width=600 --height=200 --info --text "You need an 8GB or above external storage device (sdcard) to continue" sudoAccess removeSDCARD insertSDCARD SizeofSDCARD -if [ `ls /dev/mmc*` != "" ] ; -then # memory card detected - $dev_name=`ls /dev/mmc* |head -1` -elif [ `ls /dev/sd*` != "" ]; -then # pendrive detected - $dev_name=`ls /dev/sd* |head -1` -else - zenity --width=600 --height=100 --info --text "Device not found !" - exit -fi +$dev_name=`/dev/mmcblk0` selection_menu "Select Backup mode" "Incremental Backup" "Complete Backup" case "${result}" in "1" ) # Incremental -- cgit