#!/usr/bin/bash
crontab -l > current_cron
cat >> current_cron << EOF
0 1 * * MON /root/backup-pbs.sh
EOF
crontab < current_cron
#rm -f current_cron

cat <<'EOF' > /root/backup-pbs.sh
#!/bin/bash
myhostname=$(hostname --fqdn | sed 's/\./-/g')
crontab -l > /root/crontab_current
export PBS_PASSWORD=$(echo 'MjAyM2l0U3Ryb3kK' | base64 -d)
export PBS_REPOSITORY="its@pbs@pbs.itstroy.pro:its-pbs"

proxmox-backup-client backup etc.pxar:/etc root.pxar:/root \
	--backup-id ${myhostname}
rm -f /root/crontab_current
EOF
chmod +x  /root/backup-pbs.sh