update help message and correctly set default backup location
This commit is contained in:
1 parent
80500254a7
commit
f53ffba649
1 file changed
+19
-2
+19
-2
@@ -8,18 +8,23 @@ main() {
|
||||
IFS="," read -r -a VM_FILTER <<< "$OPTARG"
|
||||
;;
|
||||
d)
|
||||
local backup_location="${OPTARG:-'.'}"
|
||||
local backup_location="${OPTARG}"
|
||||
backup_location="${backup_location%/}"
|
||||
;;
|
||||
t)
|
||||
declare -g TARGET="$OPTARG"
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
backup_location=${backup_location:-$PWD}
|
||||
|
||||
if [[ "${#VM_FILTER[*]}" -gt 0 ]]; then
|
||||
backup_vms "$backup_location" "${VM_FILTER[@]}"
|
||||
else
|
||||
@@ -36,7 +41,19 @@ list_vms() {
|
||||
lxc list -c n -f csv,noheader
|
||||
}
|
||||
|
||||
usage() { echo "Usage: ${0##*/} [-l <vm[,vm...]>] [-d <backup_dir>] [-t <lxc|incus>]"; exit 1; }
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: ${0##*/} [-l vm[,vm...]] [-d backup_dir] [-t lxc|incus] [-h]
|
||||
|
||||
Options:
|
||||
-l Comma-separated list of VMs to back up
|
||||
-d Directory where backups will be stored (default: current directory)
|
||||
-t Manager type: lxc or incus (default: lxc)
|
||||
-h Show this message
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
backup_vms() {
|
||||
local backup_location="$1"; shift
|
||||
|
||||
Reference in new issue
Block a user