Friday, May 23, 2014

How quickly free up disk space with transaction logs Exchange

If you have a critical situation occurred and an urgent need to release the disc with transaction logs, you can cheat Exchange server as if you made ​​a backup. To do this, follow these steps:

1. Example: Create a folder on drive "C:\Scripts"
2. "C:\Scripts" folder create a file "VSSClean.txt" with content (letters of your disks should be corrected):
# DiskShadow Script File to Fix VSS Writers (PLEASE Do NOT REMOVE)

begin backup
add volume D:
add volume E:
create
end backup
list shadows all
delete shadows all
# End of script

3. "C:\Scripts" folder create a file "VSSClean.cmd" with content:
diskshadow -s C:\Scripts\VSSClean.txt

4. Finally execute the file VSSClean.cmd

A good practice is to create a task on schedule to check the disk is full with logs. For example, the script below checks powershell disc name (in my case it "TLOGS") and if the space is less than 50 gigabytes script is run to remove the logs.

$disks = Get-WmiObject win32_logicaldisk | Where-Object { $_.drivetype -eq 3 }
foreach ($disk in $disks)
{
    $a1 = [math]::Round(($disk.FreeSpace/1073741824), 0)
    if ($disk.VolumeName -match "TLOGS" -and $a1 -le 50)
    {
        start-process C:\Scripts\VSSClean.cmd
    }
}

Download monitor_tlogs.ps1
Download VSSClean.cmd
Download VSSClean.txt

No comments:

Post a Comment