From 926ffa1d340163aff8568dab9511440727d779d3 Mon Sep 17 00:00:00 2001 From: Dave Kennedy Date: Wed, 10 Feb 2016 23:39:12 -0700 Subject: [PATCH 1/8] Fixed -b --- mkstage4.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkstage4.sh b/mkstage4.sh index 6b37ef5..14330d9 100755 --- a/mkstage4.sh +++ b/mkstage4.sh @@ -13,7 +13,7 @@ EXCLUDE_CONNMAN=0 QUIET=0 # reads options: -while getopts ':t:sqc' flag; do +while getopts ':t:sqcb' flag; do case "${flag}" in t) TARGET="$OPTARG" @@ -104,7 +104,7 @@ fi if [ ${EXCLUDE_BOOT} -eq 1 ] then - EXCLUDES+=" --exclude=$boot/*" + EXCLUDES+=" --exclude=boot/*" fi # Generic tar options: From 5913503be2725e43b888fdaea5c081196ff36e09 Mon Sep 17 00:00:00 2001 From: Dave Kennedy Date: Wed, 10 Feb 2016 23:45:57 -0700 Subject: [PATCH 2/8] Don't run without a target --- mkstage4.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mkstage4.sh b/mkstage4.sh index 14330d9..e107edc 100755 --- a/mkstage4.sh +++ b/mkstage4.sh @@ -41,6 +41,19 @@ while getopts ':t:sqcb' flag; do esac done +if [ "$TARGET" == "" ] +then + echo "`basename $0`: no target specified." + echo "syntax:" + echo "\$ `basename $0` [-q -c -b] [-s || -t ] [custom-tar-options]" + echo "-q: activates quiet mode (no confirmation)." + echo "-c: excludes connman network lists." + echo "-b: excludes boot directory." + echo "-s: makes tarball of current system." + echo "-t: makes tarball of system located at the ." + exit 1 +fi + # shifts pointer to read mandatory output file specification shift $(($OPTIND - 1)) ARCHIVE=$1 From e070cc84e9ee3fdd8bedba5caebf45622d2d4da6 Mon Sep 17 00:00:00 2001 From: Dave Kennedy Date: Wed, 10 Feb 2016 23:51:15 -0700 Subject: [PATCH 3/8] Added help option --- mkstage4.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mkstage4.sh b/mkstage4.sh index e107edc..9cf74b0 100755 --- a/mkstage4.sh +++ b/mkstage4.sh @@ -11,9 +11,17 @@ fi EXCLUDE_BOOT=0 EXCLUDE_CONNMAN=0 QUIET=0 +USAGE="usage:\n\ + `basename $0` [-q -c -b] [-s || -t ] [custom-tar-options]\n\ + -q: activates quiet mode (no confirmation).\n\ + -c: excludes connman network lists.\n\ + -b: excludes boot directory.\n\ + -s: makes tarball of current system.\n\ + -t: makes tarball of system located at the .\n\ + -h: displays help message." # reads options: -while getopts ':t:sqcb' flag; do +while getopts ':t:sqcbh' flag; do case "${flag}" in t) TARGET="$OPTARG" @@ -30,6 +38,10 @@ while getopts ':t:sqcb' flag; do b) EXCLUDE_BOOT=1 ;; + h) + echo -e "$USAGE" + exit 0 + ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 @@ -44,13 +56,7 @@ done if [ "$TARGET" == "" ] then echo "`basename $0`: no target specified." - echo "syntax:" - echo "\$ `basename $0` [-q -c -b] [-s || -t ] [custom-tar-options]" - echo "-q: activates quiet mode (no confirmation)." - echo "-c: excludes connman network lists." - echo "-b: excludes boot directory." - echo "-s: makes tarball of current system." - echo "-t: makes tarball of system located at the ." + echo -e "$USAGE" exit 1 fi @@ -62,13 +68,7 @@ ARCHIVE=$1 if [ "$ARCHIVE" == "" ] then echo "`basename $0`: no archive file name specified." - echo "syntax:" - echo "\$ `basename $0` [-q -c -b] [-s || -t ] [custom-tar-options]" - echo "-q: activates quiet mode (no confirmation)." - echo "-c: excludes connman network lists." - echo "-b: excludes boot directory." - echo "-s: makes tarball of current system." - echo "-t: makes tarball of system located at the ." + echo -e "$USAGE" exit 1 fi From 721a2f2bef0b57291e7c11be1545cc3a79ac6208 Mon Sep 17 00:00:00 2001 From: Dave Kennedy Date: Wed, 10 Feb 2016 23:52:59 -0700 Subject: [PATCH 4/8] Exclude files under directory, not directory itself --- mkstage4.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkstage4.sh b/mkstage4.sh index 9cf74b0..83b5c3c 100755 --- a/mkstage4.sh +++ b/mkstage4.sh @@ -93,7 +93,7 @@ shift;OPTIONS="$@" EXCLUDES="\ --exclude=.bash_history \ --exclude=dev/* \ ---exclude=lost+found \ +--exclude=lost+found/* \ --exclude=media/* \ --exclude=mnt/*/* \ --exclude=proc/* \ From 9b160a089eaf342b3f5f3218116b2a608e428913 Mon Sep 17 00:00:00 2001 From: Dave Kennedy Date: Wed, 10 Feb 2016 23:55:30 -0700 Subject: [PATCH 5/8] Consider it tested --- mkstage4.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mkstage4.sh b/mkstage4.sh index 83b5c3c..9443d66 100755 --- a/mkstage4.sh +++ b/mkstage4.sh @@ -130,15 +130,12 @@ then echo "located under the following directory?" echo "$TARGET" echo "" - echo "!!! The option --exclude=/mnt/*/* is not yet tested! It should" - echo "include all the mount points, but exclude mounted data." - echo "" echo "WARNING: since all data is saved by default the user should exclude all" echo "security- or privacy-related files and directories, which are not" echo "already excluded by mkstage4 options (such as -c), manually per cmdline." echo "example: \$ `basename $0` -s /my-backup --exclude=/etc/ssh/ssh_host*" echo "" - echo -e "COMMAND LINE PREVIEW:" + echo "COMMAND LINE PREVIEW:" echo "cd $TARGET && tar $TAR_OPTIONS $STAGE4_FILENAME * $EXCLUDES $OPTIONS" echo "" echo -n "Type \"yes\" to continue or anything else to quit: " From 4bdf2a8df5198dbf0e5907f8f8fe2346ba491a9f Mon Sep 17 00:00:00 2001 From: Dave Kennedy Date: Wed, 17 Feb 2016 22:45:51 -0700 Subject: [PATCH 6/8] Added option to include lost+found directory --- mkstage4.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mkstage4.sh b/mkstage4.sh index 9443d66..df92b7f 100755 --- a/mkstage4.sh +++ b/mkstage4.sh @@ -10,18 +10,20 @@ fi #set flag variables to null EXCLUDE_BOOT=0 EXCLUDE_CONNMAN=0 +EXCLUDE_LOST=1 QUIET=0 USAGE="usage:\n\ `basename $0` [-q -c -b] [-s || -t ] [custom-tar-options]\n\ -q: activates quiet mode (no confirmation).\n\ -c: excludes connman network lists.\n\ -b: excludes boot directory.\n\ + -l: includes lost+found directory.\n\ -s: makes tarball of current system.\n\ -t: makes tarball of system located at the .\n\ -h: displays help message." # reads options: -while getopts ':t:sqcbh' flag; do +while getopts ':t:sqcblh' flag; do case "${flag}" in t) TARGET="$OPTARG" @@ -38,6 +40,9 @@ while getopts ':t:sqcbh' flag; do b) EXCLUDE_BOOT=1 ;; + l) + EXCLUDE_LOST=0 + ;; h) echo -e "$USAGE" exit 0 @@ -93,7 +98,6 @@ shift;OPTIONS="$@" EXCLUDES="\ --exclude=.bash_history \ --exclude=dev/* \ ---exclude=lost+found/* \ --exclude=media/* \ --exclude=mnt/*/* \ --exclude=proc/* \ @@ -120,6 +124,11 @@ then EXCLUDES+=" --exclude=boot/*" fi +if [ ${EXCLUDE_LOST} -eq 1 ] +then + EXCLUDES+=" --exclude=lost+found" +fi + # Generic tar options: TAR_OPTIONS="-cjpP --ignore-failed-read -f" From 3004a76ff23cfa6a651b78cc2a21f27af6e30812 Mon Sep 17 00:00:00 2001 From: Dave Kennedy Date: Fri, 19 Feb 2016 13:15:25 -0700 Subject: [PATCH 7/8] Make options consistent --- mkstage4.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mkstage4.sh b/mkstage4.sh index df92b7f..6462b45 100755 --- a/mkstage4.sh +++ b/mkstage4.sh @@ -10,14 +10,14 @@ fi #set flag variables to null EXCLUDE_BOOT=0 EXCLUDE_CONNMAN=0 -EXCLUDE_LOST=1 +EXCLUDE_LOST=0 QUIET=0 USAGE="usage:\n\ `basename $0` [-q -c -b] [-s || -t ] [custom-tar-options]\n\ -q: activates quiet mode (no confirmation).\n\ -c: excludes connman network lists.\n\ -b: excludes boot directory.\n\ - -l: includes lost+found directory.\n\ + -l: excludes lost+found directory.\n\ -s: makes tarball of current system.\n\ -t: makes tarball of system located at the .\n\ -h: displays help message." @@ -41,7 +41,7 @@ while getopts ':t:sqcblh' flag; do EXCLUDE_BOOT=1 ;; l) - EXCLUDE_LOST=0 + EXCLUDE_LOST=1 ;; h) echo -e "$USAGE" From cf770db4493f8587219a680319e05f7538083324 Mon Sep 17 00:00:00 2001 From: Dave Kennedy Date: Fri, 19 Feb 2016 13:23:40 -0700 Subject: [PATCH 8/8] Updated readme --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 27d4be3..367dfea 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ emerge app-backup/mkstage4 ##Usage -*If you are running the script from the containing foler (first install method) please make sure you use the `./mkstage4.sh` command instead of just `mkstage4`!* +*If you are running the script from the containing folder (first install method) please make sure you use the `./mkstage4.sh` command instead of just `mkstage4`!* Archive your current system (mounted at /): @@ -40,9 +40,10 @@ mkstage4 -t /custom/mount/point archive_name Other options: -* `-q`: (quiet) runs without prompting for confirmation (careful!). -* `-b`: (no-boot) excludes the `/boot` (or `/cutom/mount/point/boot`) directory. -* `-c`: (no-connman) excludes connman saved networks directory. +* `-q`: runs without prompting for confirmation (careful!). +* `-b`: excludes the `/boot` (or `/cutom/mount/point/boot`) directory. +* `-c`: excludes connman saved networks directory. +* `-l`: excludes the `/lost+found` directory. ##Extract Tarball