开发者

how to backup SQL database (tables, mappings, indices, etc.)

开发者 https://www.devze.com 2023-03-22 00:08 出处:网络
I am installing a service pack on our shopping cart. They recommend backing up the SQL database before installing. I know we have backups to tape drives done by our hosting company, but I want one I k

I am installing a service pack on our shopping cart. They recommend backing up the SQL database before installing. I know we have backups to tape drives done by our hosting company, but I want one I know the exact time stamp for and can access quickly if I need to reload it because of开发者_开发技巧 a goof during the upgrade. (I don't want to have the store down for any longer than needed.)

How do you recommend backing up a SQL database for easy reloading for someone who is used to just writing queries and stored procedures? (I'd like to get everything - mappings & indices, etc - because I wouldn't know what all of them are or how to recreate them.)

I access the database via Remote Desktop and can link my hard drive and DVD drives, if that helps. It's MSSQL 2008.

Thank you so much.

Best wishes, Andrea


BACKUP DATABASE databasename TO DISK='C:\somefile.bak' WITH COPY_ONLY, INIT, FORMAT, CHECKSUM

Obviosly replace databasename and the target C:\somefile.bak as appropriate. Remember, the file and path is on the server; connecting remotely won't change where backup file is stored--in other words it won't be on your local machine.

You can omit the WITH options if you want. Drop INIT if you don't want the target .bak file overwritten. COPY_ONLY isn't a big deal either way in your case. CHECKSUM is just for validating the data before it gets backed up, and may not matter if you don't have CHECKSUMs turned on for the database--though by default starting in MS SQL 2005 new databases were.

The MS documentation for BACKUP and RESTORE isn't too difficult to understand in its basic forms. You can also use the Management Studio Tasks->Back Up or Tasks->Restore GUI if you have access to it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号