<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FamousPhil.com Admin Blog and More &#187; script</title>
	<atom:link href="http://famousphil.com/blog/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>http://famousphil.com</link>
	<description>My Personal Blog</description>
	<lastBuildDate>Tue, 08 May 2012 03:26:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Revisiting Exchange 2010 SP1 PST Backups (Improved Script)</title>
		<link>http://famousphil.com/blog/2011/07/revisiting-exchange-2010-sp1-pst-backups-improved-script/</link>
		<comments>http://famousphil.com/blog/2011/07/revisiting-exchange-2010-sp1-pst-backups-improved-script/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 01:33:16 +0000</pubDate>
		<dc:creator>Famous Phil</dc:creator>
				<category><![CDATA[Hosting / Server Administration]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[exchange 2010]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[pst]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://famousphil.com/?p=1096</guid>
		<description><![CDATA[Phil revisits his Exchange 2010 SP1 PST backup script and introduces some server optimization tricks and an improved powershell script that emails detailed backup completion statuses. ]]></description>
			<content:encoded><![CDATA[<p>Over the past couple of months, I&#8217;ve found that the script that I posted at <a href="http://famousphil.com/blog/2011/01/a-decent-backup-strategy-for-exchange-2010-sp1/">http://famousphil.com/blog/2011/01/a-decent-backup-strategy-for-exchange-2010-sp1/</a> hasn&#8217;t been working perfectly for my needs.  This relatively short blog is kind of a back track blog to explain the issues and provide some fixes for them.</p>
<p>The original script I posted does not verify that the backups actually completed.  The emails I got were simply gibberish.  I was willing to accept that for a while until during monthly maintenance when I manually verify backups, I was finding that backups didn&#8217;t always complete.  I&#8217;ve tracked this down in the error logs and found that the memory in the server isn&#8217;t enough for the backups at times which has them fail at certain times.  Due to the lack of user base on my server (4 light users), I can&#8217;t justify adding more ram (I currently have 4GB) because I&#8217;d have to upgrade the entire server.  So instead, I did some RAM optimization and re-wrote the backup script to email me the actual backup names that completed successfully.</p>
<p>First for the tips.  I recently learned that Active Directory can be modified from the backend, so using this, I modified the Information Store service (store.exe) in Exchange to only use at most 512MB of ram.  I used the information at <a href="http://terrytlslau.blogspot.com/2011/03/limiting-exchange-server-2007-and-2010.html">http://terrytlslau.blogspot.com/2011/03/limiting-exchange-server-2007-and-2010.html</a> for doing this, I briefly repeat the procedure here in the even that this link is no longer reachable.</p>
<pre class="brush: bash; title: ; notranslate">
1. At Domain Controller, login as a Domain Administrator.
2. Click &quot;Start&quot;, enter &quot;adsiedit.msc&quot; into the search box, hit enter.
3. Right-click &quot;ADSI Edit&quot;, select &quot;Connect to&quot;.
4. Enable the Naming Context view, click ok to connect
4. Under the &quot;Naming Context&quot; menu, select &quot;Configuration&quot;.
6. Expand to &quot;Configuration &gt; Services &gt; Microsoft Exchange &gt;  &gt; Administrative Groups &gt; Exchnage Administrative Group &gt; Servers &gt;  &gt; InformationStore&quot;.
7. Right-click &quot;InformationStore&quot;, select &quot;Properties&quot;.
8. Select &quot;msExchESEParamCacheSizeMax&quot;.
9. This value is set in pages, in Exchange 2010 the size is 32KB/page; Exchange 2007 is 8KB/page.  Simply figure out the number of pages for the amount of ram you want to limit store.exe to using.

For instance, if you want to limit the Database Cache to 4 GB of an Exchange 2010 server, set msExchESEParamCacheSizeMax to 131072 (4 GB = 4.194.304 KB / 32 KB). If you want to limit the Database Cache to 2 GB of an Exchange 2007 server, set msExchESEParamCacheSizeMax to 262144 (2 GB = 2.097.152 KB / 8KB).
10. Ok everything and restart the Information Store service (possibly the server)
</pre>
<p>After limiting the Exchange Information Store service, I simply restarted the Information Store service and that seems to have fixed the gouging memory issue.</p>
<p>As a second optimization procedure, I started tackling the IIS Worker Processes.  Exchange has several application pools that it uses, you can think of an application pool in IIS as a separate instance of Tomcat or Apache for each website.  Application Pools isolate websites to that they can&#8217;t affect each other.  On the downside, application pools also hog a great amount of memory and for the features of Exchange that you may not use often (e.g. powershell, calendar, exchange control panel), it takes some time for these features to load initially (for me, its about 30 seconds).  My solution was to limit Exchange to two application pools.  For anything service related, I used the Exchange Service Pool (e.g. EWS, Powershell, Autodiscover), and anything client site based (e.g. OWA, Calendar, ECP, ActiveSync) in the OWA pool.  I still do not know if any update to Exchange may reverse this or break this, but I do keep it in mind during updates.  The result of doing this is that not only is memory consumption reduced significantly, but Outlook Web Access, Exchange&#8217;s Calendar display (for the public), and Exchange Control Panel all load much faster now since the overhead in IIS is already loaded.  Of course, I wouldn&#8217;t recommend doing this unless you can&#8217;t easily upgrade the amount of memory in your server.</p>
<p>Finally, I will leave you with an improved export script that replaces the script in my previous blog at <a href="http://famousphil.com/blog/2011/01/a-decent-backup-strategy-for-exchange-2010-sp1/">http://famousphil.com/blog/2011/01/a-decent-backup-strategy-for-exchange-2010-sp1/</a>.  This script verifies that all of the users were actually uploaded and emails the complete report to you (instead of some garble).  I&#8217;ve found it to be very helpful in determining if a mailbox was failing to export to a PST without having to login to the file server and check.  As always, use this script at your own risk, I am willing to provide limited support as time permits.</p>
<pre class="brush: powershell; title: ; notranslate">
# Exchange 2010 SP1 Mailbox Export Script
# Originally from Steve Goodman.
# Modified by Philip Matuskiewicz for Matthouse.us / famousphil.com 1/2/11 FIXED *7/2/11*

#define information here
$server = &quot;host.example.com&quot; #server hostname
$users = @(&quot;Joe&quot;, &quot;Mary&quot;, &quot;Phil&quot;) #users to archive
$destination = &quot;localhostpstbackups&quot; #network share to backup to
$emailfrom = &quot;server@yourdomain.com&quot;
$emailto = &quot;you@yourdomain.com&quot;
#define some internal variables
$output = &quot;&quot;
$error = 0
$date = Get-Date

#check for errors
if (!(Get-ExchangeServer $server -ErrorAction SilentlyContinue)){
    $output += &quot;Exchange Server $server not found`n&quot;;
	$error = 1
}
if (!(Get-MailboxDatabase -Server $server -ErrorAction SilentlyContinue)){
    $output += &quot;Exchange Server $server does not have mailbox databases&quot;;
	$error = 1
}

#create a batch job if the above tests succeeded
if ($error -ne 1){

	$jobname = &quot;Export_$($date.Year)-$($date.Month)-$($date.Day)_$($date.Hour)-$($date.Minute)-$($date.Second)&quot;
	$output += &quot;Job title is: '$($jobname)' `n&quot;
	Write-Output &quot;Job title is: '$($jobname)' &quot;

	foreach ($mailbox in $users){
		#remove existing PST file
		if (Get-Item &quot;$($destination)$($mailbox).PST&quot; -ErrorAction SilentlyContinue){
			Remove-Item &quot;$($destination)$($mailbox).PST&quot; -Confirm:$false
			$output += &quot;Existing PST was deleted (Normal): '$($mailbox)' `n&quot;
			Write-Output &quot;Existing PST was deleted (Normal): '$($mailbox)' &quot;
		} # end if

		#request a backup of the mailbox, Exclude the recoverable items / deleted items
		$mailboxjobname = &quot;$($mailbox)-$($jobname)&quot;
		New-MailboxExportRequest -BatchName $jobname -Mailbox $($mailbox) -FilePath &quot;$($destination)$($mailbox).PST&quot; -ExcludeDumpster -Name $mailboxjobname
		$output += &quot;Mailbox Queued: '$($mailbox)' `n&quot;
		Write-Output &quot;Mailbox Queued: '$($mailbox)' &quot;

	} #end foreach
} #end $error -ne 1

#wait for the jobs to complete
$time = 0;
while ((Get-MailboxExportRequest -BatchName $jobname | Where {$_.Status -eq &quot;Queued&quot; -or $_.Status -eq &quot;InProgress&quot;})){
	Write-Output &quot;Waiting on backup, it has been $($time) seconds&quot;
	$output += &quot;Waiting on backup, it has been $($time) seconds `n&quot;
	sleep 600 #10 minutes
	$time = $time + 720;
} #end while

#check for any jobs that didn't complete
$incomplete = Get-MailboxExportRequest -BatchName $jobname | Where {$_.Status -ne &quot;Completed&quot;} | Get-MailboxExportRequestStatistics | Format-List
$complete = Get-MailboxExportRequest -BatchName $jobname | Where {$_.Status -eq &quot;Completed&quot;} | Get-MailboxExportRequestStatistics | Format-List

if($incomplete){
	Write-Output &quot;ERROR: Something didn't complete, output is '$($incomplete)'&quot;
	$output += &quot;ERROR: Something didn't complete, output is '$($incomplete)' `n&quot;
}

if($complete){
	Write-Output &quot;Completed Successfully, output is '$($complete)'&quot;
	$output += &quot;Completed Successfully, output is '$($complete)' `n&quot;
}

# Remove Requests and clean up
Write-Output &quot;Cleaning up requests that were part of the job '$($jobname)'&quot;
$output += &quot;Cleaning up requests that were part of the job '$($jobname)' `n&quot;
Get-MailboxExportRequest -BatchName $jobname | Remove-MailboxExportRequest -Confirm:$false

#verify that all the PST files were created...
foreach ($mailbox in $users){
		#remove existing PST file
		if (Get-Item &quot;$($destination)$($mailbox).PST&quot; -ErrorAction SilentlyContinue){
			$output += &quot;PST FOUND!!!: '$($mailbox)' `n&quot;
			Write-Output &quot;PST FOUND!!!: '$($mailbox)' &quot;
		}else{
			$output += &quot;ERROR: PST NOT FOUND: '$($mailbox)' `n&quot;
			Write-Output &quot;ERROR: PST NOT FOUND: '$($mailbox)' &quot;
		}
}

$SmtpClient = new-object system.net.mail.smtpClient(&quot;double.matthouse.org&quot;)
$msg = new-object Net.Mail.MailMessage
$msg.From = &quot;$($emailfrom)&quot;
$msg.To.Add(&quot;$($emailto)&quot;)
$msg.Subject = &quot;EXCHANGE EMAIL BACKUP DETAILS&quot;
$msg.Body = $output
$SmtpClient.Send($msg)

Write-Output &quot;Script complete!&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://famousphil.com/blog/2011/07/revisiting-exchange-2010-sp1-pst-backups-improved-script/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Win Serv 2003 Backups over a network w/out being logged in</title>
		<link>http://famousphil.com/blog/2009/07/win-serv-2003-backups-over-a-network-wout-being-logged-in/</link>
		<comments>http://famousphil.com/blog/2009/07/win-serv-2003-backups-over-a-network-wout-being-logged-in/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 18:05:03 +0000</pubDate>
		<dc:creator>Famous Phil</dc:creator>
				<category><![CDATA[Hosting / Server Administration]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mapped network drive]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[ntbackup]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[server 2003]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://famousphil.com/blog/?p=233</guid>
		<description><![CDATA[Phil goes into technical details of how to backup a Windows server using the ntbackup utility over a network link without having to be logged into the server.]]></description>
			<content:encoded><![CDATA[<p>As you probably know by now, I have a Microsoft Exchange 2007 server.  With any kind of server, a backup and disaster recovery plan is a vital part of any kind of professional hosting.  Hosting email can be quite tricky as it is, but taking network backups was a new road that I&#8217;ve never covered in Windows.</p>
<p>First, I have a fairly simple environment set up for my backup.  I have a Linux backup server running samba sitting in Seattle (mthsweb2).  This server has the Windows IP white listed so that only my Windows server can connect to it to map a network share.  For those of you who don&#8217;t know what samba is, samba is a daemon in Linux that will allow Windows to naively connect to a Linux server for file sharing.  Samba is a very simple solution for mapping a network drive to Linux in Windows without needing any specialized software such as sftpdrive (not called something else).</p>
<p><span id="more-233"></span></p>
<p>I want to connect Windows to Linux so I mapped a network drive on the Windows server (and I made sure reconnect at login was checked).  I logged in using the proper credentials and saved them to my Windows user account.  I then proceeded to setup NTBackup (the Windows server backup utility).  Configuring NTBackup was quite simple, a few next&#8217;s and a couple of checks on my exchange server information, system state, and a few very important directories that hold onto ssl certificates for the server.  Naturally, the backup ran fine while I was logged in.  The problem was, when I was logged off the server, the backup failed because the network drive wasn&#8217;t there.</p>
<p>After some research, I found an easy way to solve this via batch scripting.  I could schedule a task in Windows that would run the batch script which would map the network drive for my system and execute NTBackup.  Below is the script  (you will need to customize the bold parts as described below):</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
@echo off</p>
<p>net use z: <strong>server</strong><strong>backup </strong>/persistent:yes</p>
<p><strong>C:WINDOWSsystem32ntbackup.exe backup &#8220;@C:Documents and SettingsadminLocal SettingsApplication DataMicrosoftWindows NTNTBackupdatad.bks&#8221; /a /d &#8220;Set created 7/10/2009 at 1:49 PM&#8221; /v:no /r:no /rs:no /hc:off /m normal /j &#8220;d&#8221; /l:s /f &#8220;C:Documents and SettingsadminMy DocumentsBackup.bkf&#8221;</strong></p>
<p>net use z: /d /y</p>
<p>exit<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Now that we have a script, what do we put in place of the bold remarks?  <strong>Server </strong>should be the IP Address of your remote file server.  This can either be a Linux server running samba or a Windows File Server.  Either method will require that you open up a range of file sharing ports on your firewall, I tend to just whitelist the ip of the server doing the backup from the backup server&#8217;s firewall.  If you are curious of the ports, I believe you need TCP ports 135-139 open for Windows file sharing to work, but there may be more.    The bolded <strong>backup</strong> is the path from the file sharing server to where you want to store your backup.</p>
<p>To get the <strong>other bolded part</strong>, you will need to login to Windows and map a network drive under the letter you used in the script (Z in this case).  Once the drive is mapped, make sure you save your login credidentials.  Now goto the system backup utility in start>programs>accessories>system.  Select your desired backup files and when you get to the location selection screen, make sure you save to the network drive letter you created.  Then when you get to the finish screen, click advanced.  Do a normal backup appending to existing backups (or whatever you desire).  Schedule the job for later (try a few days or a week later).  You will need to type in your username / password up to 4 times until you get past this screen to the finish screen.   Once done configuring your backup, goto start>programs>accessories>system -> scheduled tasks.  Double click the backup you made and you should see something like the blurb in the batch script above.  You will need to copy this entire line and paste it into this batch script.  After you have this line successfully saved into your script, you should disconnect the drive letter from my computer by right clicking the drive and selecting disconnect.</p>
<p>Now take the entire composed batch script and paste it into a new notepad document.  Now goto file > save as on notepad and save it to a file like backup.bat in the c drive or someplace where it will be easily findable.</p>
<p>Now you can go back to the scheduled tasks, remove that backup job (its not needed anymore) and remove it from the recycle bin.  Now create a new scheduled task.  This time select the bat script you made and schedule it as needed.  Its a fairly simple set of on screen instructions to follow.  Once this task is scheduled you&#8217;re all set.</p>
<p>If you wish to test the batch script before making it a scheduled task, simply click on it and your backup should run perfectly.</p>
<p>Thats all there is to it.  This was a 5 minute fix for me and I no longer have to worry about finding a third party solution to making stable backups of my operating system.  In addition to this backup method, you might want to look into running a mirror where 2 drives copy each other live.  This will also prevent against data loss provided there isn&#8217;t any danger in the server room such as fire or water damage.</p>
]]></content:encoded>
			<wfw:commentRss>http://famousphil.com/blog/2009/07/win-serv-2003-backups-over-a-network-wout-being-logged-in/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: famousphil.com @ 2012-05-23 08:51:31 by W3 Total Cache -->
