Mirror batch of sql databases in one go

Guys

I am creating a new mirror sql server 2008 r2 instance the primary instance has over 100 databases running is there a way to create the mirror with out having to backup then copy the files then restore then create mirror individually for them all.

Any advice is welcome

Regards
DarrenJacksonAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Racim BOUDJAKDJIConnect With a Mentor Database Architect - Dba - Data ScientistCommented:
THe below should at least help you get automate the backup copy part

exec master..sp_msforeachdb 'if lower(''?'') not in (''master'', ''msdb'', ''model'', ''tempdb'')
begin
backup database [?] to disk =''C:\?.BAK''
exec xp_cmdshell ''xcopy C:\?.BAK D:\RESTORE_FOLDER''
end'

Open in new window


Not tested but that should help...
0
 
Haresh NikumbhConnect With a Mentor Sr. Tech leadCommented:
0
 
Racim BOUDJAKDJIConnect With a Mentor Database Architect - Dba - Data ScientistCommented:
You can automate the process but you will have to backup, copy (or put on a share drive) and restore each database you want to mirror.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
DarrenJacksonAuthor Commented:
Thanks guys for the input.

takecoffe I will look at this it may be of help.

Racimo I was hoping that I could make use of some utility to speed up the process as it could take me a few days to compete this task

but if it cant be done it cant be done
0
 
DarrenJacksonAuthor Commented:
Racimo thanks for this I will check this out as well

Regards
0
 
ZberteocConnect With a Mentor Commented:
First, you HAVE to do the backup and restore in mirroring. That is the way how mirroring works, based on primary backups restored on the mirror so the first step has to be done in FULL with NO RECOVERY option on mirror. There is no other way.

To help the process you could create a shared backup location between the 2 server directly accessible from both of them so that at least you can skip the copy part. The shared location could be either on the primary, on secondary or on a "third party" network location.
0
 
DarrenJacksonAuthor Commented:
Right have tested the above script and with a few tweaks I have got a working model I can use

thanks guys for the help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.