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"
|
IFS="," read -r -a VM_FILTER <<< "$OPTARG"
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
local backup_location="${OPTARG:-'.'}"
|
local backup_location="${OPTARG}"
|
||||||
backup_location="${backup_location%/}"
|
backup_location="${backup_location%/}"
|
||||||
;;
|
;;
|
||||||
t)
|
t)
|
||||||
declare -g TARGET="$OPTARG"
|
declare -g TARGET="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
backup_location=${backup_location:-$PWD}
|
||||||
|
|
||||||
if [[ "${#VM_FILTER[*]}" -gt 0 ]]; then
|
if [[ "${#VM_FILTER[*]}" -gt 0 ]]; then
|
||||||
backup_vms "$backup_location" "${VM_FILTER[@]}"
|
backup_vms "$backup_location" "${VM_FILTER[@]}"
|
||||||
else
|
else
|
||||||
@@ -36,7 +41,19 @@ list_vms() {
|
|||||||
lxc list -c n -f csv,noheader
|
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() {
|
backup_vms() {
|
||||||
local backup_location="$1"; shift
|
local backup_location="$1"; shift
|
||||||
|
|||||||
Reference in new issue
Block a user