mirror of
https://github.com/erenfro/gen2stage4.git
synced 2024-11-21 22:25:35 -05:00
Merge pull request #5 from dave-kennedy/master
shortened output notification, optionally excluding /lost+found
This commit is contained in:
commit
1b0e4d3c20
2 changed files with 38 additions and 18 deletions
|
@ -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
|
||||
|
||||
|
|
47
mkstage4.sh
47
mkstage4.sh
|
@ -10,10 +10,20 @@ fi
|
|||
#set flag variables to null
|
||||
EXCLUDE_BOOT=0
|
||||
EXCLUDE_CONNMAN=0
|
||||
EXCLUDE_LOST=0
|
||||
QUIET=0
|
||||
USAGE="usage:\n\
|
||||
`basename $0` [-q -c -b] [-s || -t <target-mountpoint>] <archive-filename> [custom-tar-options]\n\
|
||||
-q: activates quiet mode (no confirmation).\n\
|
||||
-c: excludes connman network lists.\n\
|
||||
-b: excludes boot directory.\n\
|
||||
-l: excludes lost+found directory.\n\
|
||||
-s: makes tarball of current system.\n\
|
||||
-t: makes tarball of system located at the <target-mountpoint>.\n\
|
||||
-h: displays help message."
|
||||
|
||||
# reads options:
|
||||
while getopts ':t:sqc' flag; do
|
||||
while getopts ':t:sqcblh' flag; do
|
||||
case "${flag}" in
|
||||
t)
|
||||
TARGET="$OPTARG"
|
||||
|
@ -30,6 +40,13 @@ while getopts ':t:sqc' flag; do
|
|||
b)
|
||||
EXCLUDE_BOOT=1
|
||||
;;
|
||||
l)
|
||||
EXCLUDE_LOST=1
|
||||
;;
|
||||
h)
|
||||
echo -e "$USAGE"
|
||||
exit 0
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
|
@ -41,6 +58,13 @@ while getopts ':t:sqc' flag; do
|
|||
esac
|
||||
done
|
||||
|
||||
if [ "$TARGET" == "" ]
|
||||
then
|
||||
echo "`basename $0`: no target specified."
|
||||
echo -e "$USAGE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shifts pointer to read mandatory output file specification
|
||||
shift $(($OPTIND - 1))
|
||||
ARCHIVE=$1
|
||||
|
@ -49,13 +73,7 @@ ARCHIVE=$1
|
|||
if [ "$ARCHIVE" == "" ]
|
||||
then
|
||||
echo "`basename $0`: no archive file name specified."
|
||||
echo "syntax:"
|
||||
echo "\$ `basename $0` [-q -c -b] [-s || -t <target-mountpoint>] <archive-filename> [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 <target-mountpoint>."
|
||||
echo -e "$USAGE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -80,7 +98,6 @@ shift;OPTIONS="$@"
|
|||
EXCLUDES="\
|
||||
--exclude=.bash_history \
|
||||
--exclude=dev/* \
|
||||
--exclude=lost+found \
|
||||
--exclude=media/* \
|
||||
--exclude=mnt/*/* \
|
||||
--exclude=proc/* \
|
||||
|
@ -104,7 +121,12 @@ fi
|
|||
|
||||
if [ ${EXCLUDE_BOOT} -eq 1 ]
|
||||
then
|
||||
EXCLUDES+=" --exclude=$boot/*"
|
||||
EXCLUDES+=" --exclude=boot/*"
|
||||
fi
|
||||
|
||||
if [ ${EXCLUDE_LOST} -eq 1 ]
|
||||
then
|
||||
EXCLUDES+=" --exclude=lost+found"
|
||||
fi
|
||||
|
||||
# Generic tar options:
|
||||
|
@ -117,15 +139,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: "
|
||||
|
|
Loading…
Reference in a new issue