• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Yellow Bricks

by Duncan Epping

  • Home
  • ESXTOP
  • Stickers/Shirts
  • Privacy Policy
  • About
  • Show Search
Hide Search

VMware Consolidated Backup and deleted files

Duncan Epping · Jan 4, 2008 ·

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

Related

BC-DR Scripting, VCB, VMware

Reader Interactions

Comments

  1. Don Morgan says

    1 February, 2008 at 23:54

    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. Duncan Epping says

    2 February, 2008 at 19:28

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

  3. Nancy Kafer says

    4 February, 2008 at 16:42

    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

    4 February, 2008 at 16:49

    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

    22 February, 2008 at 16:24

    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. Albert Widjaja says

    17 June, 2009 at 01:16

    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.

  7. Tom says

    21 July, 2010 at 13:40

    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

Primary Sidebar

About the author

Duncan Epping is a Chief Technologist in the Office of CTO of the Cloud Platform BU at VMware. He is a VCDX (# 007), the author of the "vSAN Deep Dive", the “vSphere Clustering Technical Deep Dive” series, and the host of the "Unexplored Territory" podcast.

Upcoming Events

May 24th – VMUG Poland
June 1st – VMUG Belgium

Recommended Reads

Sponsors

Want to support Yellow-Bricks? Buy an advert!

Advertisements

Copyright Yellow-Bricks.com © 2023 · Log in