remove old qcows if filesize on server has changed

This commit is contained in:
Raphael Dannecker 2023-10-07 12:00:42 +02:00
parent 022e8ff19b
commit 3768d0e77b
2 changed files with 22 additions and 0 deletions

View file

@ -42,9 +42,14 @@ upload_image() {
cd /lmn/vm
# (re-) create torrent file
sudo -u lmnsynci /usr/local/bin/vmimage-torrent create "${VM_NAME}.qcow2"
# create size-information-file
stat -c%s "${VM_NAME}.qcow2" > "${VM_NAME}.qcow2.size"
chown lmnsynci:lmnsynci "${VM_NAME}.qcow2.size"
# Upload Torrent, qcow2 and machine-definition-XML
[[ -f "/lmn/vm/${VM_NAME}.qcow2.torrent" ]] && rsync -av --password-file=/etc/rsync.secret \
"/lmn/vm/${VM_NAME}.qcow2.torrent" rsync://vmuser@server:/vmimages-upload/
rsync -av --password-file=/etc/rsync.secret "/lmn/vm/${VM_NAME}.qcow2.size" \
rsync://vmuser@server:/vmimages-upload/
rsync -av --password-file=/etc/rsync.secret "/lmn/vm/${VM_NAME}.qcow2" \
rsync://vmuser@server:/vmimages-upload/
rsync -av --password-file=/etc/rsync.secret "/lmn/vm/${VM_NAME}.xml" \