Restore, List Archives, Content
This commit is contained in:
1 parent
ab61e0e916
commit
328936748e
7 files changed
+123
-66
No files matched your search
@@ -3,37 +3,28 @@
|
||||
# entrypoint for all actions
|
||||
#
|
||||
|
||||
VER="2.1.0"
|
||||
|
||||
show_help() {
|
||||
echo "usage: $0 options"
|
||||
echo " -d, --daily start daily backup on local machine"
|
||||
echo " -w, --weekly start weekly backup on local machine"
|
||||
echo " --list list archives"
|
||||
echo ' --content <archive> '
|
||||
echo " show contents of archive"
|
||||
echo ' -r, --restore <archive> <file(s)> '
|
||||
echo " restore files from archive to pwd"
|
||||
echo " -h, -?. --help show this help"
|
||||
echo " "
|
||||
echo " Script muss auf dem jeweiligen Server ausgeführt werden (ggf. via ssh)."
|
||||
echo " "
|
||||
}
|
||||
|
||||
#
|
||||
# Script muss unter root bzw. sudo laufen, sonst gibt es jede Menge Probleme
|
||||
# mit Zugriff auf die diversen Verzeichnisse.
|
||||
#
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "**"
|
||||
echo "** ERROR: script has to be run as superuser!"
|
||||
echo "**"
|
||||
exit 100
|
||||
fi
|
||||
VER="2.1.2"
|
||||
|
||||
HERE=$(dirname "$0")
|
||||
THIS_SCRIPT=$0
|
||||
|
||||
show_help() {
|
||||
echo "Server Backup $VER"
|
||||
echo "usage: $0 options"
|
||||
echo " -d, --daily start daily backup on local machine"
|
||||
echo " -w, --weekly start weekly backup on local machine"
|
||||
echo " -e, --export export backups to USB-HDD"
|
||||
echo " -l, --list list archives"
|
||||
echo ' -c, --content <archive> '
|
||||
echo " show contents of archive (path from $NAS_ROOT)"
|
||||
echo ' -r, --restore <archive> <file(s)> '
|
||||
echo " restore files from archive to $RESTORE_PATH"
|
||||
echo " -h, -?. --help show this help"
|
||||
echo " "
|
||||
echo " -d, -w, -e must be run as superuser."
|
||||
echo " "
|
||||
}
|
||||
|
||||
if [ -f $HERE/main.inc.sh ]; then
|
||||
. $HERE/main.inc.sh
|
||||
else
|
||||
@@ -56,9 +47,6 @@ else
|
||||
exit 102
|
||||
fi
|
||||
|
||||
LOG_FILE_PATH="$(realpath $HERE/../../../log/backup)"
|
||||
log_file_name="$LOG_FILE_PATH/$HOST_NAME-$(date '+%Y-%m-%d_%H%M')"
|
||||
LOG_FILE="${log_file_name}.log"
|
||||
|
||||
file=
|
||||
archive=
|
||||
@@ -71,29 +59,29 @@ while :; do
|
||||
;;
|
||||
-d|--daily)
|
||||
MAIL_LOG_FILE="${log_file_name}.auto.log"
|
||||
check_root
|
||||
backup_daily
|
||||
break
|
||||
;;
|
||||
-w|--weekly)
|
||||
MAIL_LOG_FILE="${log_file_name}.auto.log"
|
||||
check_root
|
||||
backup_weekly
|
||||
break
|
||||
;;
|
||||
-e|--export)
|
||||
MAIL_LOG_FILE="${log_file_name}.auto.log"
|
||||
check_root
|
||||
export_backups
|
||||
break
|
||||
;;
|
||||
--list)
|
||||
list_archives "$NAS_ROOT/daily/$HOST_NAME"
|
||||
if [ -d "$NAS_ROOT/weekly/$HOST_NAME" ]; then
|
||||
list_archives "$NAS_ROOT/weekly/$HOST_NAME"
|
||||
fi
|
||||
-l|--list)
|
||||
list_archives
|
||||
break;
|
||||
;;
|
||||
--content)
|
||||
-c|--content)
|
||||
if [ "$2" ]; then
|
||||
list_archive_content "$NAS_ROOT" "$2"
|
||||
list_archive_content "$2"
|
||||
else
|
||||
echo 'ERROR: "--content" requires a non-empty option argument.'
|
||||
fi
|
||||
@@ -102,13 +90,20 @@ while :; do
|
||||
-r|--restore)
|
||||
if [ "$2" ]; then
|
||||
archive=$2
|
||||
shift
|
||||
shift 2
|
||||
restore "$archive" "$@"
|
||||
else
|
||||
echo 'ERROR: "--restore" requires a non-empty option argument.'
|
||||
fi
|
||||
break
|
||||
;;
|
||||
--rx)
|
||||
MAIL_LOG_FILE="${log_file_name}.auto.log"
|
||||
check_root
|
||||
shift
|
||||
do_restore $@
|
||||
break
|
||||
;;
|
||||
--) # End of all options.
|
||||
shift
|
||||
break
|
||||
|
||||
Reference in new issue
Block a user