Is it possible to disable the regular access to backup storage?

atl

Active Member
Dec 2, 2015
9
4
43
Is it possible to disable or prevent the regular access of Proxmox VE to the configured backup storage (directory)?

Background: I want to make backups to an external USB drive. If no backup runs, the disk should go into the idle mode to save power and life time. The disk is mounted via systems-automount and should unmount on idle. But the regular check of the backup storage prevents the disk to go idle. Is there a way to let the backup storage untouched if no backup is running?

My storage configuration:
Code:
dir: backup
        path /media/backup
        content backup
        prune-backups keep-all=1
        shared 0
        is_mountpoint 1
        mkdir 0
 
you can disable/enable it (either on a schedule that matches your backup schedule, or via a vzdump hookscript - but the latter requires a bit of patience since the required hook script phase is not yet part of any released version ;))
 
@fabian, thanks. I've took a look and tested it. But it doesn't work as expected. The backup job quits with the following error:
Code:
TASK ERROR: could not activate storage 'backup-to-usb': storage 'backup-to-usb' is disabled

The storage configuration is as following:
Code:
dir: backup-to-usb
        disable
        path /media/backup
        content backup
        is_mountpoint 1
        mkdir 0
        prune-backups keep-last=5
        shared 0

If I enable the storage 'backup-to-usb' all is working. But then the storage keeps mounted and the backup drive don't goes into idle mode. If I disable the storage, the automount works and unmount the drive so it can go in idle mode. I believe, the PVE is checking the storage availability before starting backup. Maybe, I've patched the wrong VZDump.pm (/usr/share/perl5/PVE/VZDump.pm), because there are 3 of them:
Code:
root@vimas:~# find /usr/ -name VZDump.pm
/usr/share/perl5/PVE/VZDump.pm
/usr/share/perl5/PVE/API2/VZDump.pm
/usr/share/perl5/PVE/Jobs/VZDump.pm


Would it be possible to integrate a storage option (like check_path 0), that prevents PVE to regularly check the storage path, so that a drive can go idle or an auto-mount path can unmount?
 
you need to handle the enabling/disabling in the hook script, and for the enabling to work you need 'job-init' support in pve-manager, which hasn't been released yet..
 
Hi.

I've patched the files /usr/share/perl5/PVE/VZDump.pm and vzdump-hook-script.pl like you showed in the link above. If I use the disabled storage ("backup-to-usb") in a backup job, I see the error above:

Code:
TASK ERROR: could not activate storage 'backup-to-usb': storage 'backup-to-usb' is disabled

If I use an active storage ("backup"), I see the following:

Code:
INFO: starting new backup job: vzdump 1010 --node vimas --quiet 1 --mode snapshot --mailnotification always --compress zstd --storage backup --mailto adm@atlnet.de
INFO: HOOK: job-start
INFO: HOOK-ENV: dumpdir=/storage/backup/proxmox/dump;storeid=backup;
INFO: Starting Backup of VM 1010 (lxc)
INFO: Backup started at 2022-02-02 16:40:01
INFO: status = running
INFO: CT Name: finance
INFO: including mount point rootfs ('/') in backup
INFO: backup mode: snapshot
INFO: ionice priority: 7
INFO: HOOK: backup-start snapshot 1010
INFO: HOOK-ENV: vmtype=lxc;dumpdir=/storage/backup/proxmox/dump;storeid=backup;hostname=finance;target=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.tar.zst;logfile=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.log;
INFO: HOOK: pre-stop snapshot 1010
INFO: HOOK-ENV: vmtype=lxc;dumpdir=/storage/backup/proxmox/dump;storeid=backup;hostname=finance;target=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.tar.zst;logfile=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.log;
INFO: create storage snapshot 'vzdump'
  Logical volume "snap_vm-1010-disk-0_vzdump" created.
INFO: HOOK: pre-restart snapshot 1010
INFO: HOOK-ENV: vmtype=lxc;dumpdir=/storage/backup/proxmox/dump;storeid=backup;hostname=finance;target=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.tar.zst;logfile=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.log;
INFO: HOOK: post-restart snapshot 1010
INFO: HOOK-ENV: vmtype=lxc;dumpdir=/storage/backup/proxmox/dump;storeid=backup;hostname=finance;target=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.tar.zst;logfile=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.log;
INFO: creating vzdump archive '/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.tar.zst'
INFO: Total bytes written: 981319680 (936MiB, 95MiB/s)
INFO: archive file size: 514MB
INFO: prune older backups with retention: keep-last=3
INFO: removing backup 'backup:backup/vzdump-lxc-1010-2022_02_02-16_25_01.tar.zst'
INFO: pruned 1 backup(s) not covered by keep-retention policy
INFO: HOOK: backup-end snapshot 1010
INFO: HOOK-ENV: vmtype=lxc;dumpdir=/storage/backup/proxmox/dump;storeid=backup;hostname=finance;target=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.tar.zst;logfile=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.log;
INFO: cleanup temporary 'vzdump' snapshot
  Logical volume "snap_vm-1010-disk-0_vzdump" successfully removed
INFO: Finished Backup of VM 1010 (00:00:11)
INFO: Backup finished at 2022-02-02 16:40:12
INFO: HOOK: log-end snapshot 1010
INFO: HOOK-ENV: vmtype=lxc;dumpdir=/storage/backup/proxmox/dump;storeid=backup;hostname=finance;target=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.tar.zst;logfile=/storage/backup/proxmox/dump/vzdump-lxc-1010-2022_02_02-16_40_01.log;
INFO: HOOK: job-end
INFO: HOOK-ENV: dumpdir=/storage/backup/proxmox/dump;storeid=backup;
INFO: Backup job finished successfully
TASK OK

The "job-init" phase is not there. Maybe the patch for VZDump.pm is wrong. I'va attached the patched VZDump.pm, the vzdump-hook-script.pl and the vzdump.conf as ZIP file.
 

Attachments

  • patched-vzdump-hook.zip
    17.4 KB · Views: 5
@fabian, it works now! Maybe it missed a PVE reboot or something. I've added the following lines to the vzdump-hook-script.pl to mount and unmount the storage:
Code:
    if ($phase eq 'job-init') {
        if ($storeid eq 'backup-to-usb') {
            system ("/usr/sbin/pvesm set $storeid --disable 0") == 0 ||
                die "enabling storage $storeid failed";
        }
    }

    if (($phase eq 'job-end') || ($phase eq 'job-abort')) {
        if ($storeid eq 'backup-to-usb') {
            system ("/usr/sbin/pvesm set $storeid --disable 1") == 0 ||
                die "disabling storage $storeid failed";
        }
    }

In the backup log I see now the 'job-init' phase:
Code:
INFO: HOOK: job-init
INFO: HOOK-ENV: storeid=backup-to-usb;
INFO: starting new backup job: vzdump 1002 --storage backup-to-usb --compress zstd --mode snapshot --mailnotification always --node midipve --quiet 1 --mailto adm@atlnet.de
INFO: HOOK: job-start
...
INFO: Finished Backup of VM 1002 (00:00:45)
INFO: Backup finished at 2022-02-07 21:50:47
INFO: HOOK: log-end snapshot 1002
INFO: HOOK-ENV: vmtype=lxc;dumpdir=/media/backup/dump;storeid=backup-to-usb;hostname=ldap;target=/media/backup/dump/vzdump-lxc-1002-2022_02_07-21_50_02.tar.zst;logfile=/media/backup/dump/vzdump-lxc-1002-2022_02_07-21_50_02.log;
INFO: HOOK: job-end
INFO: HOOK-ENV: dumpdir=/media/backup/dump;storeid=backup-to-usb;
INFO: Backup job finished successfully
TASK OK

It works now, like I wished:
* the scheduled backups activate the storage before backups starting and deactivating after backup again
* manually I can activate the storage and do backup or/and restore and at the end I can deactivate the storage again
* some minutes after storage deactivation the hard disk goes into sleep.

That's phantastic! Thank you for this. And I can't wait for the release this feature. :)
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!