Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
Backups
»
How to automate a backup on prod and a...
How to automate a backup on prod and a restore on test?
Rate Topic
Display Mode
Topic Options
Author
Message
kevinsql7
kevinsql7
Posted Thursday, September 03, 2009 8:14 AM
SSC Veteran
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 1:32 PM
Points: 271,
Visits: 248
We are running SQL Server 2000 (SP4) on Windows Server 2003.
I am looking for a simple, easy to implement method that would allow me to automatically restore the production sql server backups to the test databases. Currently, I back up the sql server databases on the production server and then xcopy the backups (just for storage on another box) to the test server. Note the backup file name contains the date and time stamp (pubs_backup_200909020421.BAK) so the restore script would have to reference this exact name in a scheduled process. (I currently use the SQL Maintenance Plans on the Production Server to create my sql server backups with the date time stamp as part of the backup file name.)
I would think I would have to use a script to backup the database on the production server, xcopy the backup to the test server, and then use a script to restore the database on the test server.
1) On Production Server:
USE pubs
BACKUP DATABASE pubs TO
DISK= 'd:\sqlbackups\pubs_backup_200902031724.bak';
GO
RESTORE VERIFYONLY FROM DISK = 'd:\sqlbackups\pubs_backup_200902031724.bak';
2) On Test Server;
Scheduled XCopy Process which copies the backup file from production server to test server.
3) On Test Server:
RESTORE DATABASE pubs
FROM DISK = 'd:\sqlbackups\pubs_backup_200902031724.bak';
Please provide advice especially with how to handle the date time stamp placed on the backup file name by the SQL Maintenance Plans.
Or, should I backup each daily file to a name like: 'd:\sqlbackups\pubs_backup_sunday.bak'
And then have a scheduled restore script to restore this particular daily backup file name.
Lastly, is there a way to spool the output of the backup, verify and restore commands to a text file?
Thanks, Kevin
Post #782209
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Thursday, September 03, 2009 8:26 AM
SSC-Dedicated
Group: Administrators
Last Login: Today @ 9:00 AM
Points: 31,410,
Visits: 13,728
I'd keep things the way they are. Then use VBScript (FileSystemObject) or Powershell to find the latest backup (not hard to do, loop files, find last one) and copy that to the test machine with a set name (LatestProdBackup.bak).
Set a restore script to restore this.
Use separate names on production, same name on test, some tweaking to do in the restore, remove users, sync logins, etc., but not that hard.
Follow me on Twitter:
@way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
Post #782223
Sarab_SQLGeek
Sarab_SQLGeek
Posted Thursday, September 03, 2009 11:30 AM
Old Hand
Group: General Forum Members
Last Login: Saturday, May 18, 2013 3:05 AM
Points: 368,
Visits: 520
Hi,
I've done this in my prod. and reporting. Not so difficult, just follow these steps (modify as per your needs)
we take diff backup every night on our prod. so that we can prepare the reporting.
1. Disable the log backup on prod.
2. Take the Backup of the DB with a preset name in to a folder lets say : latest_backup
3. initiate the process of copying the backup to destination server after intigrity checks (you'll face no problem because you've taken the backup with a pre-defined name which will remain the same.)
4. After copy finish rename the backup file on prod. and move it to another folder so that every time you'll have only one backup in Latest_backup folder
(You can also skip to move file to another folder I do this for some specific requirement)
5. remove all user sessions on destination DB (this can be easily achived by a constomized sp by which i use to kill all user sessions on my reporting server except some specific accounts)
6. REstore the DB using a predefined query since the name of the backup file is still pre-defined
7. rename the backup file at the destination server and again you've the option to move it to another folder.
Regards,
Sarabpreet Singh
SQLServerGeeks.com/blogs/sarab
www.Sarabpreet.com
Twitter: @Sarab_SQLGeek
Post #782417
kevinsql7
kevinsql7
Posted Thursday, September 03, 2009 12:12 PM
SSC Veteran
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 1:32 PM
Points: 271,
Visits: 248
Sarabpreet,
Thanks for your response. I have two questions; what do you mean when you say:
1. Disable the log backup on prod.
I am taking a nightly full database backup and log file backup even though we are not using the log backups to retore. So, basically, I have a full database backup.
Also, what do you mean when you say to restore the database using a query.
6. Restore the DB using a predefined query since the name of the backup file is still pre-defined.
I normally use a Restore Command.
Thanks, Kevin
Post #782465
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Thursday, September 03, 2009 12:55 PM
SSC-Dedicated
Group: Administrators
Last Login: Today @ 9:00 AM
Points: 31,410,
Visits: 13,728
You should not need to disable the log backup.
I think for #2, he means a RESTORE command as the query. It's not a query per se, but a batch command.
Follow me on Twitter:
@way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
Post #782495
kevinsql7
kevinsql7
Posted Thursday, September 03, 2009 2:28 PM
SSC Veteran
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 1:32 PM
Points: 271,
Visits: 248
Just curious, when you say to 'disable a log backup', do you mean to stop the SQL Maintenance Plan from creating the log backup?
Kevin
Post #782561
Sarab_SQLGeek
Sarab_SQLGeek
Posted Friday, September 04, 2009 1:59 AM
Old Hand
Group: General Forum Members
Last Login: Saturday, May 18, 2013 3:05 AM
Points: 368,
Visits: 520
kevinsql7 (9/3/2009)
Sarabpreet,
Thanks for your response. I have two questions; what do you mean when you say:
1. Disable the log backup on prod.
My DB size is around 800 GBs and our Diff. backup takes 2-3hrs time to complete that too with the help of Red-Gate, now during this time our log backup has to wait and just to avoid this i disable the job. (I think if any backup is running on a DB you can't run any other backup on the same DB)
I am taking a nightly full database backup and log file backup even though we are not using the log backups to retore. So, basically, I have a full database backup.
So in your case you don't have to worry about this.
Also, what do you mean when you say to restore the database using a query.
6. Restore the DB using a predefined query since the name of the backup file is still pre-defined.
Steve is right, i was refering to RESTORE Command....My mistake
Regards,
Sarabpreet Singh
SQLServerGeeks.com/blogs/sarab
www.Sarabpreet.com
Twitter: @Sarab_SQLGeek
Post #782762
saly1
saly1
Posted Wednesday, April 11, 2012 1:54 PM
Forum Newbie
Group: General Forum Members
Last Login: Friday, May 04, 2012 3:41 PM
Points: 3,
Visits: 48
Good stuff people. Thanks!
Post #1281940
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.