first steps

This commit is contained in:
Jochen Welzel 2021-01-06 07:57:50 +01:00
parent 9979682a49
commit 7d190f6332
1 changed files with 35 additions and 0 deletions

35
libvirt-zsh-backup.sh Normal file
View File

@ -0,0 +1,35 @@
#!/bin/bash
helpFunction()
{
echo ""
echo "Usage: $0 -v VmName -t TargetHost -d TargetDataset"
echo -e "\t-v Name of the vm to backup"
echo -e "\t-t Backup target host name"
echo -e "\t-s VM source zfs dataset"
echo -e "\t-d Backup target zfs dataset"
exit 1 # Exit script after printing help
}
while getopts "v:t:s:d:" opt
do
case "$opt" in
v ) VM="$OPTARG" ;;
t ) DESTHOST="$OPTARG" ;;
s ) SRCZFS="$OPTARG" ;;
d ) DESTZFS="$OPTARG" ;;
? ) helpFunction ;; # Print helpFunction in case parameter is non-existent
esac
done
# Print helpFunction in case parameters are empty
if [ -z "$VM" ] || [ -z "$DESTHOST" ] || [ -z "$DESTZFS" ] || [ -z "$SRCZFS" ]
then
echo "Some or all of the parameters are empty";
helpFunction
fi
DATE=$(date "+%Y%m%d")
DATE30=$(date -d "-30day" "+%Y%m%d")