November 7, 2017 at 12:47 am
Dear all,
I was requested by my company to create a solution that is able to backup a database from PROD into a destination folder and create another one that is able to restore that database from that same folder into below environments like (dev or test).
Probably this as already been developed by someone. Do you know if there is any free solution already developed with this cahracteristics?
Thank you
November 7, 2017 at 2:10 am
river1 - Tuesday, November 7, 2017 12:47 AMDear all,I was requested by my company to create a solution that is able to backup a database from PROD into a destination folder and create another one that is able to restore that database from that same folder into below environments like (dev or test).
Probably this as already been developed by someone. Do you know if there is any free solution already developed with this cahracteristics?
Thank you
Look up one of two solutions, Ola Holengren or Minion Backup. Minion has a free and a paid version. Ola's scripts are just free. I prefer Minion.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
November 7, 2017 at 2:23 am
As for the restore part, yes, it's been done before, but it's only a few lines of code. Just query the backupset and backupmediafamily tables on the source server to get the most recent backup, then restore it on the destination server. You'll need to choose a way of making sure there are no users in the destination database before you restore over it.
John
November 7, 2017 at 10:36 am
John Mitchell-245523 - Tuesday, November 7, 2017 2:23 AMAs for the restore part, yes, it's been done before, but it's only a few lines of code. Just query the backupset and backupmediafamily tables on the source server to get the most recent backup, then restore it on the destination server. You'll need to choose a way of making sure there are no users in the destination database before you restore over it.John
Thank you John for your reply. You say "Just query the backupset and backupmediafamily tables on the source server to get the most recent backup" there is No way to just see this by lloking at the files inside a directory?
What I want is:
Restore database DBName from \\servername\G$\ but I am want just to restore the most recent full backup. Can I look at the files instead of qury the server it self? If only in server, can you please let me know what is the table? thank you
November 8, 2017 at 1:56 am
What You are suggesting is that I query in the PROD server a table or a view that have all the infromation about the backups and then take that one. But can I look instead to the files? is there a way to see what is the most recent file inside a folder? If not, when you refer to query the PROD , what is the table or view? thank you
November 8, 2017 at 2:12 am
river1 - Wednesday, November 8, 2017 1:56 AMWhat You are suggesting is that I query in the PROD server a table or a view that have all the infromation about the backups and then take that one. But can I look instead to the files? is there a way to see what is the most recent file inside a folder? If not, when you refer to query the PROD , what is the table or view? thank you
Yes, but bear in mind that this method is not as reliable. What if the most recent backup of the database was made to a different folder? What if someone made a backup of the database to a file with a misleading name - for example a full backup to the file MyDatabase.TRN? If you decide to do this anyway, you can use xp_cmdshell to run a dir command and dump the results into a temp table. Or you can use Powershell or even SSIS.
when you refer to query the PROD , what is the table or view?
"Just query the backupset and backupmediafamily tables on the source server to get the most recent backup". They're in msdb.
John
November 8, 2017 at 2:57 am
I think I will use the method you suggested: backupset and backupmediafamily
But why two tables? can't I find all the infromation in just one table?
November 8, 2017 at 3:18 am
Let me also put another question. To be able to query the PROD server from DEV and Test servers I need to have a linked server or make an openquery . There is no other way, correct?
like:
select * from [PRODServerName].msdb.dbo.backupset
November 8, 2017 at 3:29 am
river1 - Wednesday, November 8, 2017 2:57 AMBut why two tables? can't I find all the infromation in just one table?
Because MSDB is designed in such a way that you need to look at two tables.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 8, 2017 at 3:54 am
river1 - Wednesday, November 8, 2017 3:18 AMLet me also put another question. To be able to query the PROD server from DEV and Test servers I need to have a linked server or make an openquery . There is no other way, correct?
November 8, 2017 at 6:05 am
river1 - Tuesday, November 7, 2017 12:47 AMDear all,I was requested by my company to create a solution that is able to backup a database from PROD into a destination folder and create another one that is able to restore that database from that same folder into below environments like (dev or test).
Probably this as already been developed by someone. Do you know if there is any free solution already developed with this cahracteristics?
Thank you
If there's any PII in the production databases, then it takes a whole lot more than a simple backup and restore. You MUST protect PII.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 8, 2017 at 7:03 am
are you using a 3th party backup solution or native SQLserver backups ?
Plug in into your existing backup infrastructure !
Doing that you can use it to test your DRP with regards to the database restore(s) needed. ( timing / completeness / accessibility / usability / .... )
As a shortcut you may think only restores of full backups would be sufficient and it may even be a starting point, but don't be fooled, you will rather quick actually need PIT-restores.
We have put in place naming conventions for folders, files, locations, ... to facilitate such usage for all our instances and DEV-instances service accounts are only granted read access to the non-dev folders at the safe-zone.
We use powershell + SMO to assemble the requested files and perform the restores ( including checkdb, and authorisation sync at the target instance plus additional scripts for PII if needed )
If you want a system that actually makes a backup on the fly and restores that to your target location, have a look at dbatools.io
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
November 8, 2017 at 7:32 am
Hello Guys,
Than you very much for your answers.
Now before restore is done, I need to guaranty that no connections are in place.
I was thinking about: ALTER DATABASE [YourDatabaseName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
This WITH ROLLBACK IMMEDIATE will kill all the connections, correct?
Thank you
November 8, 2017 at 7:45 am
river1 - Wednesday, November 8, 2017 7:32 AMHello Guys,Than you very much for your answers.
Now before restore is done, I need to guaranty that no connections are in place.
I was thinking about: ALTER DATABASE [YourDatabaseName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
This WITH ROLLBACK IMMEDIATE will kill all the connections, correct?
Thank you
Correct
November 8, 2017 at 7:46 am
There's nothing to stop you trying these things out... but yes, it will.
John
Viewing 15 posts - 1 through 15 (of 41 total)
You must be logged in to reply to this topic. Login to reply