Monday, September 10, 2012

How to perform an offline Active Directory database defrag on a Windows 2008 domain controller

Like its predecessors, Windows Server 2008 keeps the Active Directory healthy by periodically performing an automated defragmentation. Although this defragmentation works, it does not compact the database.

Before you attempt an offline defragmentation, I strongly recommend making a full, system state backup of the domain controller.

Once you have created a backup of your domain controller, the next thing that you should do is to make note of the existing Active Directory database’s size. By default, the Active Directory database is located at C:\Windows\NTDS, although the DCPROMO process does allow you to choose a different location. The name of the actual database file is NTDS.DIT. A freshly installed Active Directory database on a Windows Server 2008 domain controller is about 12 MB in size, but the database can grow to be several GB in size, depending on the amount of data that is stored in the Active Directory.

Once you have noted the database’s size, you will have to create a directory that you can use as a temporary repository for a copy of the Active Directory database. When you perform an offline defragmentation, Windows does not alter the original Active Directory database. Instead it creates a defragmented copy database. I recommend creating a folder named TEMP beneath the C:\Windows\NTDS folder.

The next step in the process is to stop the Active Directory Domain Service. Unlike previous versions of Windows, Windows Server 2008 offers the ability to start and stop the Active Directory just as you would any other service. Depending on how your server is configured, there may be dependency services that Windows will also have to shut down.



When the Active Directory Domain Service finishes shutting down, open a Command Prompt window, and enter the command:

NTDSUTIL



The command prompt will now display an NTDSUTIL prompt.
Now enter the following command:
Activate Instance NTDS



At this point, NTDSUTIL will display a message stating that activate instance has been set to “NTDS”.
Now enter:
Files
Now enter:
Info



Now, to do the offline Defrag, enter the command:

Compact to c:\Windows\NTDS\temp



The whole process looks like this:


When the process completes, enter the Q command at the NTDSUTIL prompt to close NTDSUTIL. Next, verify that Windows has created a copy of the Active Directory database in the C:\Windows\NTDS\Temp folder. This copy is the defragmented version of the database. To use it, you must either delete or rename the original database (the one in C:\Windows\NTDS), and then copy the defragmented database from C:\Windows\NTDS\Temp to C:\Windows\NTDS. You must also either rename or delete the log files located in the C:\Windows\NTDS folder.


Now, REBOOT the server.  Done.




Sunday, September 9, 2012

How to correctly backup a Shoretel server

This post will show the proper way to backup a HQ Shoretel server.  The first method is a tried and true batch script method.  The second method here will address the correct backup method using Veeam Backup and Replication 6.1 U1 where your Shoretel servers are running in a VMware environment.  Veeam backup is a cut above the rest and I strongly urge it's use any time backups are required in a virtual environment.  ***10/3/2012 edit***  I have modified the script a bit in this blog and simplified the blog from the last edit.  In the old script I was stopping the database service twice to be sure the DB service was off, this does not seem to work in an environment where there is a DVS server.  Since the startup type is still set to automatic, when the DVS attempts to sync with the HQ, it will start some services back up.  The script reflects a better way to disable, and stop the services so you are sure to get a clean copy of "C:\shoreline data".  Also, I have removed the part in the script from the last edit where we were stopping the ST COM+ service.  This is not necessary and causes more problems than it's worth.

Method 1:  The batch script.

Shoretel uses MySQL to run it's back end database for configuration data and call records.  This is light years beyond the Access type database they used in the (very) early day's.  There is one issue though, MySQL does not have a VSS Writer.  (Volume Snapshot Service or Volume Shadow Copy Service or VSS) Log on to your Shoretel server and pull up a command prompt.  Type "vssadmin list writers".

No MySQL VSS!  This causes a problem when trying to backup the Shoretel data.  Without a snapshot, you can't copy the data while the database is running because it has files locked.  Tying to backup/copy Shoretel data while the database/Shoretel services are running will result in corrupt data in the backup, and possibly even corrupt live data.  To completely restore your Shoretel server from a disaster on a new server, all you need is a copy of the install software for the build you were running when you took the backup, and a good copy of the "C:\shoreline data".  Here is the batch script I use to backup my Shoretel servers:
----------code----------
@ECHO OFF

REM **********************************************************************
REM *****  Curt Corwin - Accent Information
REM *****  This script will run every Monday at 3:15am - Stay away form 2:00am
REM *****  This script was written for Shoretel 12.3 build 17.62.1400.0
REM **********************************************************************

echo Starting Backup Job %date% - %time%  >> c:\Accent-Scripts\ShoreTel-Backup-LOG.txt

echo Set Registry Start Type to Disable
sc config "ShoreTel-VmEmSync" start= demand
sc config "ShoreTel-CSISVMSVC" start= demand
sc config "ShoreTel-MYSQLCDR" start= demand
sc config "ShoreTel-TMS" start= demand
sc config "ShoreTel-MailServ" start= demand
sc config "ShoreTel-EventWatch" start= demand
sc config "ShoreTel-DirectorUtil" start= demand
sc config "ShoreTel-MYSQLConfig" start= demand
sc config "ShoreTel-WebFrameworkSvc" start= demand
sc config "ShoreTel-CDR" start= demand
sc config "ShoreTel-IPDS" start= demand
sc config "ShoreTel-CSISSVC" start= demand
sc config "ShoreTel-Zin" start= demand
sc config "ShoreTel-DBUpdateSvc" start= demand
sc config "ShoreTel-DRS" start= demand
sc config "ShoreTel-DTASSvc" start= demand
sc config "ShoreTel-EventSvc" start= demand
sc config "ShoreTel-IPCS" start= demand
sc config "ShoreTel-Notify" start= demand
sc config "ShoreTel-SoftSwitch" start= demand
sc config "ShoreTel-Portmap" start= demand
sc config "ShoreTel-RemoteLogSvc" start= demand
sc config "ShoreTel-TransportSvc" start= demand
sc config "ShoreTel-PortMgr" start= demand
sc config "ShoreTel-WGSvc" start= demand

echo Stopping ALL Shoretel services
net stop ShoreTel-VmEmSync
net stop ShoreTel-CSISVMSVC
net stop ShoreTel-MYSQLCDR
net stop ShoreTel-TMS
net stop ShoreTel-MailServ
net stop ShoreTel-EventWatch
net stop ShoreTel-DirectorUtil
net stop ShoreTel-MYSQLConfig
net stop ShoreTel-WebFrameworkSvc
net stop ShoreTel-CDR
net stop ShoreTel-IPDS
net stop ShoreTel-CSISSVC
net stop ShoreTel-Zin
net stop ShoreTel-DBUpdateSvc
net stop ShoreTel-DRS
net stop ShoreTel-DTASSvc
net stop ShoreTel-EventSvc
net stop ShoreTel-IPCS
net stop ShoreTel-Notify
net stop ShoreTel-SoftSwitch
net stop ShoreTel-Portmap
net stop ShoreTel-RemoteLogSvc
net stop ShoreTel-TransportSvc
net stop ShoreTel-PortMgr
net stop ShoreTel-WGSvc

echo Waiting 10 seconds
TIMEOUT /T 10

echo Remove last backup
RMDIR /S /Q "C:\Accent-Backups\Shoreline Data"

echo Wait for 10 seconds
TIMEOUT /T 10

echo Copy the goods to c:\Accent-Backups
xcopy "C:\Shoreline Data" "C:\Accent-Backups\Shoreline Data" /I /E /H /Y

echo Wait for 10 seconds
TIMEOUT /T 10

echo setting services to auto mode
sc config "ShoreTel-WGSvc" start= auto
sc config "ShoreTel-PortMgr" start= auto
sc config "ShoreTel-TransportSvc" start= auto
sc config "ShoreTel-RemoteLogSvc" start= auto
sc config "ShoreTel-Portmap" start= auto
sc config "ShoreTel-SoftSwitch" start= auto
sc config "ShoreTel-Notify" start= auto
sc config "ShoreTel-IPCS" start= auto
sc config "ShoreTel-EventSvc" start= auto
sc config "ShoreTel-DTASSvc" start= auto
sc config "ShoreTel-DRS" start= auto
sc config "ShoreTel-DBUpdateSvc" start= auto
sc config "ShoreTel-Zin" start= auto
sc config "ShoreTel-CSISSVC" start= auto
sc config "ShoreTel-IPDS" start= auto
sc config "ShoreTel-CDR" start= auto
sc config "ShoreTel-WebFrameworkSvc" start= auto
sc config "ShoreTel-MYSQLConfig" start= auto
sc config "ShoreTel-DirectorUtil" start= auto
sc config "ShoreTel-EventWatch" start= auto
sc config "ShoreTel-MailServ" start= auto
sc config "ShoreTel-TMS" start= auto
sc config "ShoreTel-MYSQLCDR" start= auto
sc config "ShoreTel-CSISVMSVC" start= auto
sc config "ShoreTel-VmEmSync" start= auto

echo Start all Shoretel services back up again
net start ShoreTel-WGSvc
net start ShoreTel-PortMgr
net start ShoreTel-TransportSvc
net start ShoreTel-RemoteLogSvc
net start ShoreTel-Portmap
net start ShoreTel-SoftSwitch
net start ShoreTel-Notify
net start ShoreTel-IPCS
net start ShoreTel-EventSvc
net start ShoreTel-DTASSvc
net start ShoreTel-DRS
net start ShoreTel-DBUpdateSvc
net start ShoreTel-Zin
net start ShoreTel-CSISSVC
net start ShoreTel-IPDS
net start ShoreTel-CDR
net start ShoreTel-WebFrameworkSvc
net start ShoreTel-MYSQLConfig
net start ShoreTel-DirectorUtil
net start ShoreTel-EventWatch
net start ShoreTel-MailServ
net start ShoreTel-TMS
net start ShoreTel-MYSQLCDR
net start ShoreTel-CSISVMSVC
net start ShoreTel-VmEmSync
echo.
echo Job Done %date% - %time%  >> c:\Accent-Scripts\ShoreTel-Backup-LOG.txt
echo. >> c:\Accent-Scripts\ShoreTel-Backup-LOG.txt
echo. >> c:\Accent-Scripts\ShoreTel-Backup-LOG.txt

----------code----------

This has been tested on Shoretel version 12.3. Other versions may need to stop/start services in a different order.
The script above will shutdown all Shoretel services, remove last backup, xcopy all "c:\shoreline data" to the backup folder, then start all services back up. It is meant to be run by the windows scheduler but can be run manually. It will create a log file recording start, and stop time. The log file can be deleted at any time. It is small, but will grow in time.

1. Create a directory under c:\ called "Accent-Backups".
2. Create a directory under c:\ called "Accent-Scripts".
3. Copy the script into "C:\Accent-Scripts" and name it so the file ends in .bat.
4. Run this manually or schedule an event to run it when ever you need. Stay away from 2:00am as database maintenance happens at that time. 3:15am is a good time. Log file will be in "C:\Accent-Scripts". The data in "C:\Accent-Backups" can then be copied or backed up at will. I usually keep a copy of the shoreline data and the current build I'm on together in a safe place.
Quick, easy, effective.


Method 2:  The Pre-Freeze and Post-Thaw batch script with Veeam and VMware.

All Windows servers (especially MSSQL and exchange) being backed up with Veeam should use the VSS backup option "Enable application-aware image processing".  All, except for Shoretel servers.  See below a screenshot of where to configure this in your Veean backup job:
However, this option should NOT be used to back up Shoretel servers because there is no VSS writer for MySQL.  What you'll end up with (at best) is crash consistent backup if you use this option with MySQL.  Windows will be restored correctly but because the MySQL files are locked open during backup time, and there is no way to snapshot the MySQL database and it's log files, you will not get a good backup.

So, how can we backup Shoretel servers with Veeam?  When creating a backup job for the Shoretel server, you need to use an option called "Enable VMWare Tools Quiescence".  Seen in the screen shot below:
The use of this option will call a script on the Shoretel server located in the VMWare Tools directory.  All scripts in this directory will be run in alphabetical order.  This script will shut down all Shoretel services before taking the snapshot for the backup, giving you a good backup of the data.  The scripts are called Freeze and Post-Thaw scripts.
Here is the script:
----------code----------
@ECHO OFF

REM ************************************************************************
REM *****  Curt Corwin - Accent Information
REM *****  This script will work with VMWare to freeze and thaw Shoretel during backups
REM *****  To be used with Veeam and the "Enable VMWare tools quiescence"option
REM ************************************************************************

if "%1" == "freeze" goto dofreeze
if "%1" == "freezeFail" goto dofreezeFail
if "%1" == "thaw" goto doThaw
goto EOF

:dofreeze
sc config "ShoreTel-VmEmSync" start= demand
sc config "ShoreTel-CSISVMSVC" start= demand
sc config "ShoreTel-MYSQLCDR" start= demand
sc config "ShoreTel-TMS" start= demand
sc config "ShoreTel-MailServ" start= demand
sc config "ShoreTel-EventWatch" start= demand
sc config "ShoreTel-DirectorUtil" start= demand
sc config "ShoreTel-MYSQLConfig" start= demand
sc config "ShoreTel-WebFrameworkSvc" start= demand
sc config "ShoreTel-CDR" start= demand
sc config "ShoreTel-IPDS" start= demand
sc config "ShoreTel-CSISSVC" start= demand
sc config "ShoreTel-Zin" start= demand
sc config "ShoreTel-DBUpdateSvc" start= demand
sc config "ShoreTel-DRS" start= demand
sc config "ShoreTel-DTASSvc" start= demand
sc config "ShoreTel-EventSvc" start= demand
sc config "ShoreTel-IPCS" start= demand
sc config "ShoreTel-Notify" start= demand
sc config "ShoreTel-SoftSwitch" start= demand
sc config "ShoreTel-Portmap" start= demand
sc config "ShoreTel-RemoteLogSvc" start= demand
sc config "ShoreTel-TransportSvc" start= demand
sc config "ShoreTel-PortMgr" start= demand
sc config "ShoreTel-WGSvc" start= demand
net stop ShoreTel-VmEmSync
net stop ShoreTel-CSISVMSVC
net stop ShoreTel-MYSQLCDR
net stop ShoreTel-TMS
net stop ShoreTel-MailServ
net stop ShoreTel-EventWatch
net stop ShoreTel-DirectorUtil
net stop ShoreTel-MYSQLConfig
net stop ShoreTel-WebFrameworkSvc
net stop ShoreTel-CDR
net stop ShoreTel-IPDS
net stop ShoreTel-CSISSVC
net stop ShoreTel-Zin
net stop ShoreTel-DBUpdateSvc
net stop ShoreTel-DRS
net stop ShoreTel-DTASSvc
net stop ShoreTel-EventSvc
net stop ShoreTel-IPCS
net stop ShoreTel-Notify
net stop ShoreTel-SoftSwitch
net stop ShoreTel-Portmap
net stop ShoreTel-RemoteLogSvc
net stop ShoreTel-TransportSvc
net stop ShoreTel-PortMgr
net stop ShoreTel-WGSvc
goto EOF

:dofreezeFail
sc config "ShoreTel-WGSvc" start= auto
sc config "ShoreTel-PortMgr" start= auto
sc config "ShoreTel-TransportSvc" start= auto
sc config "ShoreTel-RemoteLogSvc" start= auto
sc config "ShoreTel-Portmap" start= auto
sc config "ShoreTel-SoftSwitch" start= auto
sc config "ShoreTel-Notify" start= auto
sc config "ShoreTel-IPCS" start= auto
sc config "ShoreTel-EventSvc" start= auto
sc config "ShoreTel-DTASSvc" start= auto
sc config "ShoreTel-DRS" start= auto
sc config "ShoreTel-DBUpdateSvc" start= auto
sc config "ShoreTel-Zin" start= auto
sc config "ShoreTel-CSISSVC" start= auto
sc config "ShoreTel-IPDS" start= auto
sc config "ShoreTel-CDR" start= auto
sc config "ShoreTel-WebFrameworkSvc" start= auto
sc config "ShoreTel-MYSQLConfig" start= auto
sc config "ShoreTel-DirectorUtil" start= auto
sc config "ShoreTel-EventWatch" start= auto
sc config "ShoreTel-MailServ" start= auto
sc config "ShoreTel-TMS" start= auto
sc config "ShoreTel-MYSQLCDR" start= auto
sc config "ShoreTel-CSISVMSVC" start= auto
sc config "ShoreTel-VmEmSync" start= auto
net start ShoreTel-WGSvc
net start ShoreTel-PortMgr
net start ShoreTel-TransportSvc
net start ShoreTel-RemoteLogSvc
net start ShoreTel-Portmap
net start ShoreTel-SoftSwitch
net start ShoreTel-Notify
net start ShoreTel-IPCS
net start ShoreTel-EventSvc
net start ShoreTel-DTASSvc
net start ShoreTel-DRS
net start ShoreTel-DBUpdateSvc
net start ShoreTel-Zin
net start ShoreTel-CSISSVC
net start ShoreTel-IPDS
net start ShoreTel-CDR
net start ShoreTel-WebFrameworkSvc
net start ShoreTel-MYSQLConfig
net start ShoreTel-DirectorUtil
net start ShoreTel-EventWatch
net start ShoreTel-MailServ
net start ShoreTel-TMS
net start ShoreTel-MYSQLCDR
net start ShoreTel-CSISVMSVC
net start ShoreTel-VmEmSync
goto EOF

:doThaw
sc config "ShoreTel-WGSvc" start= auto
sc config "ShoreTel-PortMgr" start= auto
sc config "ShoreTel-TransportSvc" start= auto
sc config "ShoreTel-RemoteLogSvc" start= auto
sc config "ShoreTel-Portmap" start= auto
sc config "ShoreTel-SoftSwitch" start= auto
sc config "ShoreTel-Notify" start= auto
sc config "ShoreTel-IPCS" start= auto
sc config "ShoreTel-EventSvc" start= auto
sc config "ShoreTel-DTASSvc" start= auto
sc config "ShoreTel-DRS" start= auto
sc config "ShoreTel-DBUpdateSvc" start= auto
sc config "ShoreTel-Zin" start= auto
sc config "ShoreTel-CSISSVC" start= auto
sc config "ShoreTel-IPDS" start= auto
sc config "ShoreTel-CDR" start= auto
sc config "ShoreTel-WebFrameworkSvc" start= auto
sc config "ShoreTel-MYSQLConfig" start= auto
sc config "ShoreTel-DirectorUtil" start= auto
sc config "ShoreTel-EventWatch" start= auto
sc config "ShoreTel-MailServ" start= auto
sc config "ShoreTel-TMS" start= auto
sc config "ShoreTel-MYSQLCDR" start= auto
sc config "ShoreTel-CSISVMSVC" start= auto
sc config "ShoreTel-VmEmSync" start= auto
net start ShoreTel-WGSvc
net start ShoreTel-PortMgr
net start ShoreTel-TransportSvc
net start ShoreTel-RemoteLogSvc
net start ShoreTel-Portmap
net start ShoreTel-SoftSwitch
net start ShoreTel-Notify
net start ShoreTel-IPCS
net start ShoreTel-EventSvc
net start ShoreTel-DTASSvc
net start ShoreTel-DRS
net start ShoreTel-DBUpdateSvc
net start ShoreTel-Zin
net start ShoreTel-CSISSVC
net start ShoreTel-IPDS
net start ShoreTel-CDR
net start ShoreTel-WebFrameworkSvc
net start ShoreTel-MYSQLConfig
net start ShoreTel-DirectorUtil
net start ShoreTel-EventWatch
net start ShoreTel-MailServ
net start ShoreTel-TMS
net start ShoreTel-MYSQLCDR
net start ShoreTel-CSISVMSVC
net start ShoreTel-VmEmSync
goto EOF

:EOF
----------code----------

1. Navigate on the Shoretel server to "C:\program files\VMWare\VMware Tools" and create a directory called "backupScripts.d" and place the script there. Rename it to A-Backup-Shoretel.bat.

2. Inside of Veeam, create another job dedicated to backup Shoretel. Check the checkbox "Enable VMWare Tools Quiescence" and do not enable Application-Aware VSS backups. This should run all of the scripts inside of "C:\program files\VMWare\VMware Tools\backupScripts.d", giving you a good backup.  It will shutdown all Shoretel services, take the snapshot, start Shoretel services back up again, and complete the backup using the snapshot with MySQL/Shoretel services off.
See below for a video of this happening:




Tuesday, May 8, 2012

Latest addition to the CI collection

I found this at the Delaware flea market at the fairgrounds last Sunday for $8.  Ebay has them right now for quite a bit more.  This is circa 1902.  This went through the electrolysis tank and has 3 seasoning applications.  I have been looking for one of these for my collection!  Yay! 





Saturday, March 31, 2012

Awesome antique shop in Lancaster, OH.

I was passing thought Lancaster, OH the other day for work and I stumbled across this antique shop.

Its located at about coordinates 39.71697,-82.60681305555555.  For those of us that love cast iron, there is plenty scattered though out the building but in the lower level, there is a ton of it.  

I rummaged through a lot of it and decided on the following Griswold skillet.  Circa 1937-1957.  It sat flat with no wobble and there were no chips or cracks.




Rusty cruddy awesomeness!  I used my typical method of cleaning and the end result was as expected, and I added one more user to my collection.






Wednesday, March 21, 2012

Driving out of a storm.

Pictures of us driving out of a storm on 3/18/2012.




Some of my cast iron.

The following is a Griswold #666 breakfast skillet.  Circa 1940.  I love this piece.  Although the bacon section is a bit small, the area where I'm making eggs is perfect for sandwiches!


I'm starting to acquire so much cast iron, I'm having to hang it up to make room in the cabinet's.


Here is a video for those who say that everything sticks to cast iron.  I'm making fried potatoes here.  Potatoes are notorious for sticking to skillets, no matter how much oil you use.  Other than having a properly seasoned skillet, the trick is to preheat your skillet (as always) and dry your potatoes off with a paper towel. It also seems to help if you add the oil to a preheated skillet and then add the dry potatoes to the oil right away.



 




Here is one of my grandfathers smaller skillets, it's marked only with a "T".  It's probably an unmarked Wagner.  Circa 1925 - 1960.









Tuesday, March 13, 2012

Vulnerabilities in Remote Desktop Could Allow Remote Code Execution (2671387)

Remote exploit patched today that can allow an attacker (or zombie machine) to create admin accounts, and install software of choice on your servers accessible via remote desktop, without logging in!
Microsoft patch Tuesdays come and go.  Usually I pay no attention and carry on about my busy day. This one scared the $h!t out of me...  Patch em up boys (and gals)...  Especially if you have servers with RDP public facing!