Digressive / HyperV-Backup-Utility

Flexible Hyper-V Backup Utility
https://gal.vin/posts/vm-backup-for-hyper-v/
MIT License
120 stars 38 forks source link

When a Backup fails still deleats older archives. #13

Closed RJ-Make closed 2 years ago

RJ-Make commented 2 years ago

I think I just found a bug

It seems like if the backup fails (for whatever reason) the system will still delete older archives.

Looks like I started running into space errors on 12-19-2021 and didn't notice it. By 12-24-2021 the script deleted all archives (I had clean up at 3 days) over time (each failed backup)

I'm currently running a new backup with a new working directory location that should support the space needed. I'll report back when completed.

PS: The second log is with the latest version (thank you for adding the script version to the logs)

`2021-12-19 01:00:01 [INFO] Log started **** Running with the following config *****. Hostname:................XXXXXXXXX. Windows Version:.........10.0.19044. VMs to backup:........... .........................NextCloud_G2 Backup directory:........A:\ServerFolders\Acronis_Comp_BU\NextCloud_VM\BU\GEN_2. Working directory:.......G:\Hyper-V_BU_WrkDir. Backups to keep:.........3 days Logs directory:..........A:\ServerFolders\Acronis_Comp_BU\NextCloud_VM\BU\Logs. E-mail log to:...........No Config E-mail log from:.........No Config E-mail subject:..........Default SMTP server:.............No Config SMTP Port:...............Default SMTP user:...............No Config SMTP pwd file:...........No Config -UseSSL switch:..........False. -NoPerms switch:.........False. -ShortDate switch:.......False. -Compress switch:........True. -Sz switch:..............True. 7-zip installed:.........True. 7-zip Options:...........-t7z.


2021-12-19 01:00:02 [INFO] Process started. 2021-12-19 01:00:02 [INFO] Attempting to export NextCloud_G2 2021-12-19 01:00:13 [ERROR] Failed to copy files during export.

There is not enough disk space for copy under 'G:\Hyper-V_BU_WrkDir\NextCloud_G2'.

Failed to copy files: There is not enough space on the disk. (0x80070070).

There is not enough disk space for copy under 'G:\Hyper-V_BU_WrkDir\NextCloud_G2'. Required space is 255473.09 MB and available space is 189783.45 MB. 2021-12-19 01:00:13 [INFO] Removing compressed backups of NextCloud_G2 older than: 3 days

NextCloud_G2-2021-12-15_01-07-34.7z 12/15/2021 1:07:34 AM

NextCloud_G2-2021-12-15_01-07-34.7z 12/15/2021 2:58:56 AM

2021-12-19 01:00:13 [INFO] Compressing NextCloud_G2 backup using 7-Zip compression 2021-12-19 01:00:13 [INFO] Process finished. 2021-12-19 01:00:13 [INFO] Log finished`

Here is the log of a backup that failed right after the export was completed, but didn't make it too compression. The working directory was cleared, but no archive was created.

` 2022-01-03 09:20:57 [INFO] Log started **** Running with the following config *****. Utility Version:.........21.12.28 Hostname:................XXXXXXXXXXX. Windows Version:.........10.0.19044. VMs to backup:........... .........................NextCloud_G2 Backup directory:........A:\ServerFolders\Acronis_Comp_BU\NextCloud_VM\BU\GEN_2. Working directory:.......G:\Hyper-V_BU_WrkDir. Backups to keep:.........3 days Logs directory:..........A:\ServerFolders\Acronis_Comp_BU\NextCloud_VM\BU\Logs. E-mail log to:...........No Config E-mail log from:.........No Config E-mail subject:..........Default SMTP server:.............No Config SMTP Port:...............Default SMTP user:...............No Config SMTP pwd file:...........No Config -UseSSL switch:..........False. -NoPerms switch:.........False. -ShortDate switch:.......False. -Compress switch:........True. -Sz switch:..............True. 7-zip installed:.........True. 7-zip Options:...........-t7z.


2022-01-03 09:20:58 [INFO] Process started. 2022-01-03 09:20:58 [INFO] (VM:NextCloud_G2) Attempting to export VM 2022-01-03 09:51:29 [INFO] (VM:NextCloud_G2) Removing compressed backups older than: 3 days 2022-01-03 09:51:29 [INFO] (VM:NextCloud_G2) Compressing backup using 7-Zip compression 2022-01-03 09:51:29 [INFO] Process finished. 2022-01-03 09:51:29 [INFO] Log finished `

RJ-Make commented 2 years ago

I can confirm, after moving the working directory to larger drive, the backup succeeded.

Perhaps some 'checks and balances' in place before deleting any archives that meet the criteria until a successfully backup and move has completed.

itkroplis commented 2 years ago

A good idea would be to use external monitoring that looks for 1) log files (or no message, "not enough disk space"). 2) Check the backup disk for free space. 3) Check the backup folder for file creation last x hours/days. Alert about it. I don't like that the log here is not written in one file. This makes it difficult to follow.

RJ-Make commented 2 years ago

To be clear, this is a result of not enough space for the working directory, not the target directory.

The working directory size is a moving target and it involves the additional space required to perform the compression.

In my case, I was surprised to see It CAN take ~500 gigs of space to compress a ~300 gig VM.

Also, you don't get ANY errors or indication of the problem after all archives have been removed. This only took 3 backup cycles in my case.

The system silently fails after that.

itkroplis commented 2 years ago

Yes, there will be problems in this case. I use a 6TB HDD as a TEMP drive were to compress the VM.

Digressive commented 2 years ago

Just to update, working on this.

RJ-Make commented 2 years ago

Just to update, working on this.

Thank you for all your hard work, it's much appreciated.

Digressive commented 2 years ago

Latest version 22.01.19 checks for success or failure at multiple points and on fail will not remove older backups.

RJ-Make commented 2 years ago

Using and testing the latest version. Will report back after a bit.

Thanks for all your hard work!

RJ-Make commented 2 years ago

I have not run into any issue on this new version.

Thanks Again.