evolinux-base: backup-server-state: add "force" mode

This commit is contained in:
Jérémy Lecour 2022-01-28 16:25:17 +01:00 committed by Jérémy Lecour
parent 359719d0d0
commit 6d5aa67045

View file

@ -31,6 +31,7 @@ Usage: ${PROGNAME} --backup-dir=/path/to/backup/directory [OPTIONS]
Options Options
-d, --backup-dir path to the directory where the backup will be stored -d, --backup-dir path to the directory where the backup will be stored
-f, --force keep existing backup directory and its content
--etc backup copy of /etc --etc backup copy of /etc
--no-etc no backup copy of /etc (default) --no-etc no backup copy of /etc (default)
--dpkg backup copy of /var/lib/dpkg --dpkg backup copy of /var/lib/dpkg
@ -703,8 +704,10 @@ main() {
fi fi
if [ -d "${backup_dir}" ]; then if [ -d "${backup_dir}" ]; then
echo "ERROR: The backup directory ${backup_dir} already exists. Delete it first." >&2 if [ "${FORCE}" != "1" ]; then
exit 2 echo "ERROR: The backup directory ${backup_dir} already exists. Delete it first." >&2
exit 2
fi
else else
create_backup_dir create_backup_dir
fi fi
@ -794,6 +797,10 @@ while :; do
VERBOSE=1 VERBOSE=1
;; ;;
-f|--force)
FORCE=1
;;
-d|--backup-dir) -d|--backup-dir)
# with value separated by space # with value separated by space
if [ -n "$2" ]; then if [ -n "$2" ]; then
@ -982,6 +989,7 @@ done
# Default values # Default values
: "${VERBOSE:=0}" : "${VERBOSE:=0}"
: "${FORCE:=0}"
: "${DO_ETC:=0}" : "${DO_ETC:=0}"
: "${DO_DPKG_FULL:=0}" : "${DO_DPKG_FULL:=0}"
: "${DO_DPKG_STATUS:=1}" : "${DO_DPKG_STATUS:=1}"