#!/bin/bash
#
# ::do_not_edit::
# ::maintainer::
#
CMD=$(basename $0)
CMDVER="1.1"
CMDSTR="$CMV v$CMVVER (2026-08-01)"

set -e -u

. /etc/veeam/ku-veeam.cfg

# create / update default_repo
#
veeamconfig repository list | grep -q "^$repo_name\s" || {
	echo -e "\nmissing default repo '$repo_name', creating ...\n"
	veeam_create_default_repo
}



veeamconfig job list | grep -q "^$job_name " && {
	echo "
ERROR!	default job '$job_name' still exists, delete it firs, running

	  veeamconfig job delete --name $job_name

	or do a a full agent reset, runing

	  veeam_reset
" >&2
	exit 1
}

echo -e " creating 'filelevel' job: $job_name"

xmasks="*.tmp,*.lock"
[ "X$excludemasks" != "X" ] && xmasks=$xmasks,"$excludemasks"

xdirs=
[ "X$excludedirs" != "X" ] && xdirs="--excludedirs $excludedirs"

veeamconfig job create filelevel \
	--name $job_name \
	--reponame "default_repo" \
	--includedirs "$directories" \
	--excludemasks $xmasks \
	$xdirs \
	--maxdays $maxdays \
	--nosnap

veeamconfig job info --name $job_name

exit 0
