Thursday, March 11, 2010

Documenting Exchange 2003 Users in preparation for migrations

You learn something new every day. Today, I got schooled in Exchange 2003 data collection. Of course, I am familiar with ExBPA. However, I had never seen this great script that collects SG/DB paths, and database sizes.

Then after being so used to Exchange 2007 and using Powershell cmdlets like get-mailboxstatistics and Glen's infamous mbsizereportv5.ps1 script, I was looking for the same in Exchange 2003 and facepalm'd myself when it was as simple as right click export.

Wednesday, March 10, 2010

Exchange 2010 DAG backups using Windows Server Backup

I wrote a while back on Exchange backups for 2007 and 2010 using Windows Server backup. Then I wrote here about product support for Exchange backups.

That first link is a little dated as the screens are from Windows 2008 and Exchange 2007 SP2. The Windows 2008 R2 screens are slightly different.

Rehashing the differences only, the VSS Full options are in a slightly different place:

Under Advanced Settings, there is an exclusion tab (I leave mine blank, but I could exclude things like Exchange binaries, etc) but more importantly is the VSS Full backup option:

Beyond that, the next new bit of information is about backing up DAG copies. Microsoft states that the Windows Server Backup (WSB) does not support passive database copies.

"However, the built-in support for Windows Server Backup is for active copies only. You can't use Windows Server Backup to back up passive copies."

This leaves you with minimal options.. If I have in this example, 3 databases, and 3 servers, I need to either move all the databases to one server and back it all up, or I need to back have backup jobs on each server, only backing up the disk with an active database.

The problem with the latter option is that the databases might move as maintenance or issues occur, and then you would have a failed job on those databases.

So I opted to move all the databases to be active on one server, run a complete backup, and then re-disperse the databases.

Here's the batch script I created. A few things to know here.

1) Learn how to use wbadmin.exe
2) You will need to change the volumes to match your server. Running mountvol.exe from an elevated command prompt will list all volumes on your server for you. Do note, the -allCritical does not automatically choose drives without system files on it (aka, Exchange disks)
3) You will need to change the username/password seen in the script to match your environment. User rights should be Backup Operators, and Exchange Org Administrator.

rem - Launch Powershell with Exchange cmdlets and run ps1 script to move all databases to on server

PowerShell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; c:\installers\move-databasestoexch1.ps1"

rem - Launch a backup
rem - determined volume mount points using moutvol.exe

wbadmin start backup -backupTarget:\\bdc\Exchangebackups\exch1 -include:\\?\Volume{1be73a5a-052f-11df-82c2-806e6f6e6963}\,\\?\Volume{26934b04-09f5-11df-a2b7-002564f8c664}\,\\?\Volume{26934b0b-09f5-11df-a2b7-002564f8c664}\,\\?\Volume{26934b0e-09f5-11df-a2b7-002564f8c664}\,\\?\Volume{1be73a5b-052f-11df-82c2-806e6f6e6963}\ -password:yescleartext -vssFull -quiet

rem - Launch Powershell with Exchange cmdlets and run ps1 script to move all databases back to separate servers.

PowerShell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; c:\installers\move-databasestopreferred.ps1"

Here's the move-databasestoexch1.ps1 script:

Move-ActiveMailboxDatabase DB1 -ActivateOnServer EXCH1 -MountDialOverride:None -Confirm:$false
Move-ActiveMailboxDatabase DB2 -ActivateOnServer EXCH1 -MountDialOverride:None -Confirm:$false
Move-ActiveMailboxDatabase DB3 -ActivateOnServer EXCH1 -MountDialOverride:None -Confirm:$false

And the move-databasetopreferred.ps1 script:
Move-ActiveMailboxDatabase DB1 -ActivateOnServer EXCH1 -MountDialOverride:None -Confirm:$false
Move-ActiveMailboxDatabase DB2 -ActivateOnServer EXCH2 -MountDialOverride:None -Confirm:$false
Move-ActiveMailboxDatabase DB3 -ActivateOnServer EXCH3 -MountDialOverride:None -Confirm:$false

I was able to schedule the backup using task scheduler and it works!

It certainly is not elegant. I would much prefer a backup product that looks for active mailbox databases and backs up accordingly. I would also enjoy not having a password in clear text in a batch file as a backup solution. But it works for now. I am planning on adding a "DAG support" column to my backup product matrix soon, and I will say "with scripting" for Windows Server Backup and link to this article.

Wednesday, March 03, 2010

PowerShell for Backup Planning

To size a backup system, you need to decide on a few key pieces of information: retention range, amount in GB of file data to be backed up & change rate on that data. For applications, you will need to know SQL database sizes and change rates. Same for Exchange.

luckily with powershell, it's quick and easy. I'm a lazy scripter so I'm sure this script could be much improved, but it worked for my purposes.

to send server name, volume name, volume size, and free space to a .csv file:

ForEach ($item in $computer)
$disk = get-wmiobject -credential $credential -query "select * from win32_logicaldisk where DriveType='3'" -computername $item
foreach($drive in $disk)
$item + "," + $drive.Name + "," + [int]($drive.size/1gb) +"," +[int]($drive.freespace/1gb)|out-file test.csv -append

This script will ask you to login with administrator credentials, then output information for all local hard drives (no removable drives or CD-ROMs), and output it to a .csv file.

For clusters, it will only retrieve the primary member's information.

What about SQL? We can simply search for .mdf files and list their sizes. We could also use this same bit to search for LDF files or any other file type. This will output to a .csv file the Server name, the path of the .mdf file, and the file size.

foreach ($svr in $computer)
{$dbFiles = Get-WmiObject -credential $credential -Class CIM_DataFile -Filter "Extension = 'mdf'" -ComputerName $svr;
$dbFiles | ForEach-Object { ($_.csname) + "," + ($_.Name) + "," + ($_.filesize/1gb)}| out-file testsql.csv -append


Notice that both scripts loop through an array to find data. You could also use an active directory query to populate the array instead of entering the names manually.

by the way, I love how I can convert bytes to GB just by dividing by "1GB" - powershell has built in constants for translating file sizes. You can also divide by MB or KB.