Skip to content

Previous backups from N days are not being deleted successfully when VM name contains an underscore character on the VM name #41

@svcabre

Description

@svcabre

Hello,

I tested your tool on latest published version (24.08.29) but when I execute with the following arguments:

.\Hyper-V-Backup.ps1 -BackupTo D:\HV_VM_BKPs\ -NoPerms -Keep 30 -Compress -L D:\scripts\logs\ -LogRotate 30

* BackupTo 
* -NoPerms
* - Keep 30 (last 30 days backups)
* - Compress
* - L
* - LogRotate 30 (last 30 days logs)

then previous backups older than 30 days, are not being successfully removed.

I think it could be happening when my VM is called SRV_DOMOTICS and then the function that this part of the code (line 637) has some issue due to the RemoveFilePat string defined there. Do you thing this is something you could improve. When a VM has underscore character on it?

        ## Remove previous backup files older than X days. -Keep and -Compress switch are configured.
        else {
            Write-Log -Type Info -Evt "(VM:$Vm) Removing compressed backups older than: $History days"

            ## Remove previous compressed backups older than the configured number of days.
            If ($ShortDate)
            {
                ReportRemove -RemoveDir $WorkDir -RemoveFilePat "-*-*-*.*" -RemoveDirOpt $false -RemoveHistory $History
            }

            else {
                ReportRemove -RemoveDir $WorkDir -RemoveFilePat "-*-*-*_*-*-*.*" -RemoveDirOpt $false -RemoveHistory $History
            }

Thanks,

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions