Answered by:
Exchange 2010 Script to dismount database

Question
-
I want to do a flat file backup of my database on a weekly basis. I know there are other solution but my is for offsite backup purpose. The shadow copies are to large and are particular to a volume. I would like to do a scheduled task to dismount the database...... I will then run a batch file to copy the database to another location. This file will be backed up to a remote facility.
If I have done something wrong please let me know. I'm very new to these forums.
Thank youThursday, January 7, 2010 11:40 PM
Answers
-
Off the top of my head, you could do something like this:
$mdbs = get-mailboxdatabase <insert-server-name-here>
foreach ( $mdb in $mdbs )
{
dismount-database -confirm:$false $mdb
copy "$mdb.EdbFilePath" <some-destination-here>
mount-database $mdb
}
I haven't actually tried it though, and you may experience several headaches. What is the account that's running this scheduled task? Does it have permissions to enumerate the databases? To dismount/mount them? Does it have write-access to that location? And your database will be offline for all this time. Do you want it copying to the same location each time? If so, that will overwrite the previous backup. Is that OK with you?
You could get fancier by copying it locally first, mounting, and then copying remotely. That will minimize the downtime, but the other problems still remain.
Database availability groups may suit your needs better. The downside is cost (another exchange server and buying windows enterprise).
-martin
Legal Stuff: This posting is provided "AS IS" with no warranties, and confers no rights.- Proposed as answer by Allen Song Monday, January 11, 2010 9:10 AM
- Marked as answer by Allen Song Friday, January 15, 2010 8:17 AM
Friday, January 8, 2010 3:52 AM
All replies
-
Off the top of my head, you could do something like this:
$mdbs = get-mailboxdatabase <insert-server-name-here>
foreach ( $mdb in $mdbs )
{
dismount-database -confirm:$false $mdb
copy "$mdb.EdbFilePath" <some-destination-here>
mount-database $mdb
}
I haven't actually tried it though, and you may experience several headaches. What is the account that's running this scheduled task? Does it have permissions to enumerate the databases? To dismount/mount them? Does it have write-access to that location? And your database will be offline for all this time. Do you want it copying to the same location each time? If so, that will overwrite the previous backup. Is that OK with you?
You could get fancier by copying it locally first, mounting, and then copying remotely. That will minimize the downtime, but the other problems still remain.
Database availability groups may suit your needs better. The downside is cost (another exchange server and buying windows enterprise).
-martin
Legal Stuff: This posting is provided "AS IS" with no warranties, and confers no rights.- Proposed as answer by Allen Song Monday, January 11, 2010 9:10 AM
- Marked as answer by Allen Song Friday, January 15, 2010 8:17 AM
Friday, January 8, 2010 3:52 AM -
I prefer online backup so I suggest you to create separate volume for Exchange database and logs - in Windows 2008/2008R2 yoou always can shrink volume and move exchange stores and logs to new ones. I've done such a trick few times at many clients (the same situation is with Exchange 2007 SP2).
Even if someting goes wrong with your backup, users have constant access to Exchange mailboxes and you have no problems with them.
Regards, Konrad Sagala, MCT, 5xMCITP, MCTS: Exchange 2010Friday, January 8, 2010 9:09 AM -
Hello Konrad.
Could you please write in details how to do this trick with on-line exchange 2010 database backup ?
Dmitry.
Sunday, October 23, 2011 9:35 AM