Solved

SQL SErver 2008 automated copy/restore

Posted on 2014-01-31
4
227 Views
Last Modified: 2014-01-31
Hi Experts,

I would like to copy a database and restore it on another database (on the same instance)everynight. How can I automate this?

Thx
0
Comment
Question by:dlan75
  • 2
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39824175
The easiest way would just be to setup a SQL Agent job to restore the backup over the existing database. I assume you already have a job to backup the main database, so you just need to grab that file and restore over the existing "copy" database.

You might have to code to figure out the name of the backup if you are including any timestamps, or have some naming convention in place.
0
 
LVL 12

Author Comment

by:dlan75
ID: 39824190
Thx for the fast repy.
Could you give me some kind of procedure?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39824205
It's difficult to be precise without knowing the make up of your database (number of data files, log files, locations, etc), but logically you want something like the following in the step of a SQL Agent job:
RESTORE DATABASE [YourCopyDatabaseName]
    FROM FILE = N'<path_and_name_of_your_backup_file'
    WITH
         MOVE '<logical_data_file_name>' TO '<physical_path_of_file_for_your_copy_database>'
         MOVE '<logical_log_file_name>' TO '<physical_path_of_file_for_your_copy_database>'
         REPLACE

Open in new window

More detailed info on the syntax and options are here: http://technet.microsoft.com/en-us/library/ms186858.aspx

Specifically you should be looking at examples D and E towards the bottom of the page.
0
 
LVL 12

Author Comment

by:dlan75
ID: 39824401
thx will make my way around that :-)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now