first steps
This commit is contained in:
parent
9979682a49
commit
7d190f6332
35
libvirt-zsh-backup.sh
Normal file
35
libvirt-zsh-backup.sh
Normal 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")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user