Restore DB from backup with move - need to set to single user mode first and then reset to multiuser?

Im going to restore a recent backup from a production server DB to a test server DB and I want to do it through tsql.  The DB already exists on the test server, I just want to overwrite it with a fresh copy.  There may or may not be some activity
on the test server that is connected to the database, but its not important and can be abandoned/discarded.
This is what Im getting ready to do
First, get an idea of what the file paths are specified in the backup file
RESTORE FILELISTONLY FROM DISK = 'file_back_to_backup here .back .dat etc'
Then, set the DB to singleuser mode, and discard any connections/transactions currently started
ALTER DATABASE MyDBName
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE
Then, do the restore, specifying the paths to the mdf/ldf files that already exist.
RESTORE DATABASE MyDBName
FROM DISK
WITH MOVE 'db logical name' TO 'new data path .mdf', MOVE 'log logical name' TO 'new log path.ldf';
Questions:
(1) If I specify the data and log file paths as ones that already exist, will they be overwritten?  This is what I want, as I just want to copy the prod db over to the test server.
(2) Do I need to explicitly reset the DB back to multiuser mode, or does this happen after the restore?
(3) Anything missing from the above script(s) ?  Suggestions?

Questions:
(1) If I specify the data and log file paths as ones that already exist, will they be overwritten?  This is what I want, as I just want to copy the prod db over to the test server.
(2) Do I need to explicitly reset the DB back to multiuser mode, or does this happen after the restore?
(3) Anything missing from the above script(s) ?  Suggestions?
1.Just restore the backup with REPLACE command and it will overwrite the current database.
2.No , database will be automatically put to Multi user mode if you are restoring with recovery
3. Single user script is fine .Change restore script like no need to use with move option
restore database db_name from disk='location' with replace
Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers
I think I will still need WITH MOVE, as the files in the backup are using a different path than where they are located on the test server, correct?
RESTORE DATABASE MyDBName
FROM DISK
WITH MOVE 'db logical name' TO 'new data path .mdf', MOVE 'log logical name' TO 'new log path.ldf' WITH
REPLACE;

Similar Messages

  • Had 3G, moved to 3GS.  Backed up 3G and restored 3GS from backup with no problem.  When I want to add songs, I get itunes message that the new iphone is synced to another computer and now wants to erase everything.  How can I add music?

    Had 3G, moved to 3GS.  Backed up 3G and restored 3GS from backup with no problem on a Dell computer.  But now when I want to add songs, I get itunes message of death that the new iphone is synced to another computer and now wants to erase everything.  How can I add music without erasing everything on my new iphone?

    Yes, I was aware of this but the phrase "Any items imported from audio CDs or acquired from other sources will not copy from your device to the iTunes library." is what worries me.  Will this eliminate my Notes, Calendar Events, etc or will it apply mostly just to the music?

  • Can't log in with valid password, can't boot from disk, can't access disk utility, in single user mode can't reset password as appears locked in caps mode with '?' for forward slash, can anyone help?

    Can't log in with valid password, can't boot from disk, can't access disk utility, in single user mode can't reset password as appears locked in caps mode with '?' for forward slash, can anyone help?

    Which keyboard layout you were using? German, French ... I suppose your layout is reset to the default: US and you are unable to find the "?" or "/" ...
    Please have a look into the keyboard viewer, to see how the layout of your keyboard is actually.
    marek

  • Internal HD on mac mini not well... need to boot in Single User Mode

    Internal HD on mac mini not well... need to boot in Single User Mode.
    I only have a Bluetooth Keyboard and Bluetooth Mouse so when I try to boot in Single User Mode (to do the /sbin/fsck hard drive fix thing) it doesn't see the Bluetooth Keyboard. What's the solution?
    I also used SuperDuper to use as a boot drive but it won't unmount my internal HD. arghh..
    Help

    I have a corrupt drive and was unable to repair all the errors after booting from OS X installer disk and choosing Disk Utility...
    I followed the "boot into single user mode" instructions hoping to complete my repair with fsck, however once I got to the localhost:/ root# prompt, my keyboard seemed to be unrecognized!
    I tried 3 different USB keyboards - original Apple USB keyboard, Kensington Mac USB keyboard and an old SGI USB windows keyboard. All were able to enter the apple-S key to get into single user mode but NONE of them were able to type any commands whatsoever.....
    I'm thinking my only option is to boot the mini as a target drive off my laptop and try to backup my 30GB of music and photos before wiping the drive...
    2nd option might be to try Disk Warrior for $79??
    Anyone else have ideas for me?

  • Can't boot computer with 10.5 install CD or Single User Mode, or Safe Mode.

    Ive written a couple times about this and responded to people who have similiar queeries but i just havent gotten any answers.
    I cannot log onto my computer, I boot up and get a blue screen, with a nice black arrow. Thats as far as i can get. Obviously happening to lots of people..So, ive tried rebooting holding the C key and with 10.5 install CD, ive tried Unix (command-S), Ive tried resetting PR Ram, ive tried mantra recitation and cooing to my laptop; ive tried all the shortcuts in Oreilly's book and the only thing that DOES work is holding the OPTION key while rebooting. This brings up a nice icon of a padlock and a place to type letters or words and then there is another arrow in a box. Is this Open Firmware? I dont have an open firmware password...Ive tried entering my user password but it doenst accept it. ( I did change my password last week, did that create these problems???) how do i by pass that password????? Is it open firmware? (the date reads 1904 when i do the command option-O F command, and i cant get beyond that either...HELP!!

    Hello,
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Utilities from the Installer menu at the top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access the Menubar at top.
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Reset Password from the Installer menu at the top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Reset Password.
    Space between mount & -uw, space between -uw & the /
    rm /var/db/.applesetupdone
    Space after rm, before the 1st /

  • 5s: I restored an old backup with an invalid Apple ID. How to clear memory and start fresh?

    I'm changing jobs, so I bought a new 5s to replace the 5 I need to return.  When I got home, I restored an iTunes phone backup that contained my old Apple ID - which is now invalid.  The 5s is now set up to "Find My iPhone", but linked to the old Apple ID.  How to erase the phone?  Can the carrier store (AT&T) do it?  Or should I go to the Apple Store?  Thanks in advance,  -ds

    Welcome to the Apple community.
    Unfortunately you cannot transfer purchases from one account to another.
    Are you aware that the iCloud accounts and the iTunes accounts are different accounts, and that you can retain your iTunes account ID for iTunes and use your new ID for iCloud.

  • Unable to boot normally - Always need to boot with Single User Mode

    Hi Community,
    Since last few days, I am unable to boot my Macbook Pro normally, running latest version of OS X Yosemite. When I boot, it goes to grey screen with Apple logo and progress bar, once the progress completes to 100% (after 5-10 minutes which is very longer than usual), it asks me to 'Select  language' which seems like fresh installation of OS X. In that case, when I click next and it doesn't detect my SSD (blank list of select installation disk/drive).
    After reading some threads, I found work-around and always need to boot into Single user mode (by pressing Command+S during power on) and then need to run following commands...
    /sbin/fsck -fy
    /sbin/mount -uw /
    "device is write protected" numerous times
    reboot
    and then only it loads OS X and displays login screen. This happens all the times and I need to follow above steps always to get login screen.
    How can I fix this?

    Please help me out here. I tried booting it off a USB flash drive with ATV flash but that gave me some errors and prompted me to login with username [email protected] with password frontrow
    But I am not sure how to get to login using a suitable input. I tried to telnet it using my PC over network but I dont think it has initialized anything (like wifi or network) at the prompt. Would it take USB keyboard input? All I can do is remove the power and restart it with the usb flash out and get into then get into the recovery loop. I am not sure replacing the hard-drive would help. Any help would be greatly appreciated.
    Thanks
    Sinu

  • I just upgraded to the 5s but the sales lady did not restore from my last backup with my 4s. How do I get my pictures and settings restored?

    I just upgraded to the 5s but the sales lady did not restore from my last backup with my 4s. How do I get my pictures and settings restored? I cannot seem to get it to give me that option. Can anyone tell me what to do? Thanks so much!

    If the phone has already been set up, you will need to go to Settings > General > Reset > Erase All Content and Settings to be able to go through the setup again. This time use Restore from Backup.
    This will walk you through the setup screens:
    Getting Started and Get-Started Apps

  • Where is the data file for the address book located, I need to restore mine from backup but don't know where it is.

    Where is the data file for the address book located, I need to restore mine from backup but don't know where it is to do so.  Putting my Mac Pro onto icloud synching contacts resulted in duplicate and triplicates of the same cards.  I have a few THOUSAND contacts and the last time this happened was on mobile me.  that had a function where you could replace info on the mobile me server with info on the computer.  I see no way to do that on the new cloud.

    In the stupidly hidden user's Library->/Application Support/AddressBook/ labeled as AddressBook-v22.abcddb
    For TM restores, see Pondini's TM FAQs for starters, since I don't use TM.

  • Using InDesign CS4 on iMac. Had to restore computer from backup. Licensing has stopped working. Error code 150:30. How can I reestablish my license?

    Using InDesign CS4 on iMac. Had to restore computer from backup. Licensing has stopped working. Error code 150:30. How can I reestablish my license?

    You'll need to have a chat with Adobe Support. Here's a link:
    https://helpx.adobe.com/contact.html?step=ZNA_downloading-installing-setting-up_licensing- activation
    We can't help you with that here.

  • Recovering Mac HD via Time Machine Backup fails because "Restore system from backup" doesn't show in Utilities Menu of original install. DVD

    Hi, after serious problems (troubleshooting didn't help) with my iMac G5 (PPC) running Mac OS X Leopard I've tried to recover my Mac HD via Time Machine (exactly as described by David Pogue on page 242 of the Leopard Missing Manual). However, "Restore system from backup" in the Utilities Menu of my original Leopard installation DVD failed to show up. What can I do?
    Any assistance will be greatly appreciated -
    Ballant

    Hi Ballant,
    I'm not very good with TM, nor a fan of it, but our resident king of TM, Pondini, has a vast array of very well done TM trouble shootings...
    http://pondini.org/TM/Troubleshooting.html

  • When restore iPhone from backup, why it copying every single app

    when restore iPhone from backup, why it is copying every single app from library? any way to restore whatever was backed up from iPhone?

    How to restore from backup without sync all my apps? I recently upraded firmware to IOS 7, and then tried to restore from my privouse backup. But it everytime, when it's saying you are successfully restored. but I when I unlock my phone all app icon are dark gray color, means nothing restored and then itunes automactically copying all my app to iPhone like 100+ apps, I dont need all of them.
    Again, How to restore from backup without sync all my apps? 

  • Restore Files from Backup on Vista Home Premium ; HP Pavilion m8120n

    Hello,
    I backed up files on HP personal media drive M:HP8120 and did a full System Recovery on my HP Pavilion m8120n. Now when I attempt to restore files from a backup made on this computer, the message says there are no backups available on this computer.  I tried advanced restore/Restore files from backup made on another computer or restore files for all users on this computer.  I can see the file in Select the Backup set to restore window.  I select the file and in the next window, select the date to restore from, I get the message “Backup location is not available.”  If I click next, in the select the files and folders to restore window, nothing is listed.  However, I get the opportunity to restore everything in this backup -- add files, add folders, etc. If I click add folders, I don’t see drive M: but I see drive C: and D:. 
    At this point I am at a loss.  Can anyone shed light on my situation?

    Thanks for the info. It appears that your Time-Warner router is serving a public IP address.
    My suggestion is to use the D-Link wireless-router for your local LAN (connect the Time-Warner to the WAN input of the D-Link). If you're concerned about speed issues, you can connect your laptop into the LAN bridge of the D-Link.
    If you're worried about speed, you can do a simple before and after experiment to see if the D-link is degrading your I/O throughput. I've used sites speedtest.net with good success in troubleshooting bandwidth issues.
    Regards / Jim B / Wireless Enthusiasts
    ( While I'm an embedded wireless systems engineer at work, on this forum I do not represent my former employer, Hewlett-Packard, or my current employer, Microsoft )
    + Click the White Kudos star on the left as a way to say "thank you" for helpful posts.

  • "Restore system from backup" doesn't work

    Hi folks! I've got a strange little problem and my normal rampage through Google hasn't dug up anything, so I figured I'd ask it here.
    I currently have an early 2011 MacBookPro running 10.6.8 on an Intel SSD. A few days ago I figured I'd install an XP boot camp partition for the occasional bout of gaming (mmm... Skyrim... *dreamy look*)
    So I made my Time Machine backup up-to-date, burned a CD with drivers, and let Disk Utility play with the partitions. Only thing was it said it couldn't do the job due to space issues and suggested I wipe the disk first.
    Ok, no problem. My Time Machine backup was snug and secure and I've got plenty of install experience. I popped in the Lion DVD I'd burned for my other iMac and booted from it. Strangely, it give me an installation error (I guess it tries to install automatically without user interaction). But that's fine since I didn't want to install Lion anyway (I'm addicted to SL's Spaces). So I ran Disk Utility again with the partitions the way Boot Camp had advised (GUID, 2 partitions). This also worked without a problem.
    Then I attempted the option "Restore system from backup" in the Utilities menu, and lo and behold: nothing happens. Nothing happened at all. No drive spin-up, no color wheel, no indication of any activity whatsoever. If I select any of the other options, it opens promptly, but clicking the restore option is as productive as a glob of ant spit on a meteor strike.
    So I figure, still no worries, maybe the Lion disk has issues. So I take out my Snow Leopard DVD and boot from that. Never gave problems before, but alas: the iMac refuses to boot from it and starts throwing out 3 beeps every 5 seconds or so. (Googling the beeps pointed me to memory issues. Wait.. Whut?!?)
    Okaaay. Then I tried it with my Leopard DVD. Once again, won't boot, beeps.
    The Lion DVD seems to be the only DVD I can boot my mac from. The only thing I can guess at is that Apple prevents us from installing with older DVD's because of driver issues, which makes sense I guess. But I had Snow Leopard running fine up until now. I've tried several different partitioning schemes including the default one for an installation, but no cigar. Both Disk Utility and futil show both drives are visible and ok.
    Anyone have any ideas? Thanks in advance for your time!
    regards,
    Meindert Honig

    lepkitty wrote:
    you should see the time machine come up and be able to select a date on the rite. the screen should look like its something out of star trek with several windows going back into a star like looking thing. if you see that then you want to do is select a date then click restore. you will be promoted that doing this will erase the computer, thats ok! its going to erase it and replace it with what your restoring.
    You're mixing two very different things. You get the +Star Wars+ display, with the timeline on the right, only when browsing via +Enter Time Machine.+ Restoring something from there +*does not erase your entire computer!+* It only replaces what you've selected to restore.
    If you do a full system restore (meaning boot volume), starting with your Install disc (per #14 in the Frequently Asked Questions *User Tip,* also at the top of this forum), there is no "Star Wars" display, and only the drive/partition that you select as a destination for the restore is erased.

  • Restoring iphone from backup

    is anyone else having trouble restoring iphone from backup since 2.0. it worked fine with 1.4 but i have tried it once with 2.0 and once 2.0.1 both times it said my backup was corrupt. this is getting real annoying.

    I'm about to just thow my iphone 3G out the window. I cannot upgrade the software without it hanging up and not finishing. Then I am forced to try to restore the phone, and it will not restore. I am taking it to an apple genius again today to get it restored. I have not gotten any information that has helped resolve this issue. I've been on the phone with a tier 1 and tier 2 support person for 4 hours about 3 weeks ago and I'm now in the same boat again. Any info on how to make this work would be greatly appreciated!!

Maybe you are looking for

  • What cable do i need for a dual monitor iMac late 2013

    Hi there I am wondering if I can set up a dual monitor for my imac late 2013. I'm quite new to macs so bear with me. I'm a university student studying maya (digital vfx animation) and I need desperately to hve a dual set up. My mac is the 21.5inches.

  • Refresh af:selectOneChoice in backed bean (JDev 10.1.3.5)

    I have jspx with af:selectOneChoice named Status. When user changes value of selectOneChoice from IN_WORK to COMPLETED, I check business rules. If some rules are violated, I show error messages and I want to set value of af:selectOneChoice back to IN

  • VARCHAR2 MAX LENGTH

    Hi, I have a variable l_body in my pl/sql code with varchar2(32767). it displays max. 44 lines, more than 44 lines it gives buffer size error. if I use clob data type then it gives value or numeric erro on more than 44 lines. code is below regards l_

  • Capture realime data by using CDC

    Hi experts i have one doubt. how to capture the real time data by using CDC and how can we schedule that scenario(we dont know the exact time when new transactions occurs) i have emp and look up table dept using lookup condition and applied CDC also

  • Can't receive account verification e-mail?

    Im trying to get icloud up and running but can't get e-mail verification of my account. Any ideas????