Page 1 sur 1

Delete old backup (windows server Backup)

Posté : sam. févr. 18, 2017 11:45 am
par hmi
indows server backup has been failing when this particular drive has been used as the target drive. The drive has worked in the past as it was properly set up as part of a backup set. I suspect it is failing because it is full.

When doing a wbadmin get disks command, the disk is listed as:

Total space: 931.51 GB

Used space: 931.46 GB

Volumes: > not mounted > [servername]

I have tried to run the following command to delete all but 10 of the most recent backups on the drive - wbadmin delete backup -KeepVersions:10 -backupTarget:"\\?\Volume{diskguid}\" - however, I get an error saying the backup location could not be found because I suspect the volume says it is not mounted, even though it shows up when I do the get disks command.

The event viewer error ID is 517.

script
$Days = 30
$TargetFolder = "G:\backups"

$Now = Get-Date
$LastWrite = $Now.AddDays(-$Days)
$Files = get-childitem $TargetFolder -include *.bkf | Where {$_.LastWriteTime -le "$LastWrite"}

foreach ($File in $Files)
{ write-host "Deleting File $File" -foregroundcolor ";Red";
Remove-Item $File
}