i want to use tape backup without a changer. For a small installation ( complete backup fits on one tape ) i want to create something with minimal user interaction.
X tapes are available and in the worst case, the user should be able to insert a random tape and take one offline.
The only thing he must take care of, is that a new tape is inserted and no tape stays ejected.
Only with the gui something like this seems not to be possible, as a job starts a single pool with attached named tapes and then expects the right names at execution.
Did i overlook something?
I helped myself with an unelegant script:
( edited version from 05.05.24 without using jobs, better error capturing )
This seems to work, but is there a simpler way to achieve my goal?
Greetings
X tapes are available and in the worst case, the user should be able to insert a random tape and take one offline.
The only thing he must take care of, is that a new tape is inserted and no tape stays ejected.
Only with the gui something like this seems not to be possible, as a job starts a single pool with attached named tapes and then expects the right names at execution.
Did i overlook something?
I helped myself with an unelegant script:
( edited version from 05.05.24 without using jobs, better error capturing )
Bash:
# edited on 05.05.24
#!/bin/bash
# date of execution
date=$(date)
# sometimes proxmox-backup-proxy is not answering proxmox-tape (GET /api2/json/tape/drive/LTO5/status?: 400 Bad Request:...timeout while trying to lock)
locked=$(proxmox-tape status --drive XXX 2>&1 >/dev/null | grep lock | awk -F' ' '{print $6}')
case $locked in
"lock" )
systemctl restart proxmox-backup-proxy
echo "proxmox-backup-proxy restarted"
;;
* )
echo "proxmox-backup-proxy ok, go on ..."
;;
esac
# check if tape device is accessible
deviceexists=$(proxmox-tape status --drive XXX 2>&1 >/dev/null | grep Error: | awk -F' ' '{print $1}')
case $deviceexists in
"Error:" )
echo "Backup am $date fehlgeschlagen. Das Bandlaufwerk ist nicht eingeschaltet oder verbunden. Bitte überprüfen." | mail -s "Backup: Bandlaufwerk ist nicht eingeschaltet." user@domain.de
echo "device missing, email sent"
exit 1
;;
* )
echo "device exists, go on ..."
;;
esac
# test if tape is inserted (capture stderr and search for "Error:"), send mail that user should insert a tape
notape=$(proxmox-tape read-label --drive XXX 2>&1 >/dev/null | grep Error: | awk -F' ' '{print $1}')
case $notape in
"Error:" )
echo "Backup am $date fehlgeschlagen. Es wurde kein Band gefunden. Bitte legen Sie ein neues Band in das Laufwerk" | mail -s "Backup: Bandlaufwerk ist leer. Bitte Band einlegen." user@domain.de
echo "tape missing, email sent"
exit 1
;;
* )
echo "tape exists, go on ..."
;;
esac
# bevore use create seperate mediapools for every tape with the name of the tape/barcode
# then "proxmox-tape read-label --drive XXX" in terminal to get uuids/label-text of all used tapes. They have to be listed here
# read name of inserted tape label-text, uuid and pool name
tapename=$(proxmox-tape read-label --drive XXX | grep -oP '(?<=label-text).*' | awk -F ' ' '{print $2}')
uuid=$(proxmox-tape read-label --drive XXX | grep -oP '(?<=uuid).*' | awk -F ' ' 'NR==1{print $2}')
poolname=$(proxmox-tape read-label --drive XXX | grep -oP '(?=pool).*' | awk -F ' ' '{print $3}')
case $uuid in
"07a772f5-fa67-46e6-a0c7-e74a8e69d658" )
proxmox-tape backup local-ds1 A22166L5 --drive XXX --notify-user root@pam
;;
"c63d5cef-e1fa-419d-a990-3f8d9fcb9be7" )
proxmox-tape backup local-ds1 A23490L5 --drive XXX --notify-user root@pam
;;
"9bed08cd-2138-483c-a3ab-71b961fd02b9" )
proxmox-tape backup local-ds1 A22943L5 --drive XXX --notify-user root@pam
;;
"2524e45d-ec9b-4fa3-8a29-475104cdb944" )
proxmox-tape backup local-ds1 A22396L5 --drive XXX --notify-user root@pam
;;
* )
echo "Backup am $date fehlgeschlagen. Es wurde ein unbekanntes Band mit dem Namen $tape und der UUID $uuid gefunden, zugehörig zum Pool $poolname. Bitte legen Sie ein passendes Band in das Laufwerk" | mail -s "Backup: falsches Band im Laufwerk." user@domain.de
echo "unknown tape $tapename with $uuid of pool $poolname found, mail sent"
exit 1
;;
esac
# eject tape
proxmox-tape eject --drive XXX
# notification
echo "Das Band $tapename wurde am $date für die Sicherung benutzt. Bitte legen Sie ein neues Band in das Laufwerk" | mail -s "Backup erfolgreich: Bitte Band wechseln" user@domain.de
This seems to work, but is there a simpler way to achieve my goal?
Greetings
Last edited: