VMware Consolidated Backup and deleted files

As most of you know, when VMware Consolidated Backup dumps image level backups VCB only dumps used diskspace. Unfortunately for us VCB does this by checking at block level if it contains only zero’s or not. If it contains only zero’s the block is considered empty, but an Operating System doesn’t zero out the disk space that contained the files when a file is deleted. An Operating System only clears the pointers to these files. This is why you could have a disk with only 4GB of used space and a 6GB VCB dump. As of ESX 3.0.2 update 1 VMware reintroduced the shrink option in VMware Tools. Kind of a weird name “shrink” cause the vmdk doesn’t actually shrink, the unused space is just zeroed out.


I tested this and it works great, only downside is that you can’t schedule this shrink tool. Luckily for us there are more tools you can use to zero out your disk and save time writing the dumps to tape / disk and save diskspace. I re-wrote a vbs script, which was originally created by Doug Knox for defragmenting local disks to include zeroing out for every local disk in the server. The script uses the Sysinternals tool Sdelete, download it and copy it to c:\windows\system32\. It defragments the disk and than writes zero’s on all unused space.

sdelfrag.vbs:

Set WshShell = WScript.CreateObject("WScript.Shell")
Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
WshShell.RegWrite "HKCU\Software\Sysinternals\", 0, "REG_SZ"
WshShell.RegWrite "HKCU\Software\Sysinternals\SDelete\", 0, "REG_SZ"
WshShell.RegWrite "HKCU\Software\Sysinternals\SDelete\EulaAccepted", 1, "REG_DWORD"
For Each d in dc
If d.DriveType = 2 Then
Return = WshShell.Run("defrag " & d & " -f", 1, TRUE)'
Return = WshShell.Run("sdelete -c " & d, 1, TRUE)
End If
Next
Set WshShell = Nothing




You can leave a response, or trackback from your own site.

9 Responses to “VMware Consolidated Backup and deleted files”

  1. Don Morgan says:

    I have downloaded the sysinternals executeable, and placed it in windows\system32 folder. I have created the sdelfrag.vbs file including the text provided. However, when i try to run the .vbs it gives an error about an invalid character, line 1, character 37. Not sure if I am doing something wrong, or if I need some other windows component installed in order to run this vbscript.

    Thanks!

    Don

  2. Sorry forgot to include the code tag in wordpress, and it converted the quotes the wrong way should be solved!

  3. Nancy Kafer says:

    I’m getting the same error as Don. I saw your post about including the code tag. What do I need to do to fix this error?

    Thanks!
    Nancy

  4. Nancy Kafer says:

    Never mind. Turns out the problem was the fact that the code was saved in Wordpad instead of Notepad. Once that was fixed the script worked great.

  5. David Maldonado says:

    The error I got was:

    Line: 11
    Char: 1
    Error: Unable to wait for process
    Code: 80020009
    Source: WshShell.Run

    I changed
    Return = WshShell.Run(“sdelete -c ” & d, 1, TRUE)

    from TRUE to FALSE and it worked fine.

  6. [...] VCB informatie kwam ik de volgende post tegen op Duncan Epping van http://www.yellow-bricks.com zijn blog: vmware-consolidated-backup-and-deleted-files daar staat het volgende beschreven: I re-wrote a vbs script, which was originally created by Doug [...]

  7. Hi All,

    In order to use this script, I’m wondering of where should I run it before the VCB backup script take place then ?

    Shall I scheduled it manually 1 hour before I execute the VCB backup script ?

    Thanks.

  8. Tom says:

    This looks like something that would not be difficult for a PowerShell ninja to rewrite into PowerShell, then one could use it with PowerCLI or remote PowerShell??

    Would using this script overcome the potential problems of defragging a thin-provisioned disk??

    Thank you, Tom

Leave a Reply

Subscribe to RSS Feed Follow me on Twitter!