How can I remotely back up a database to a local database?

Source: Internet
Author: User

How can I remotely back up a database to a local database?

How to remotely back up a database to a local database

-- 1. Enable xp_mongoshelluse masterEXEC sp_configure 'show advanced options', 1 reconfigure with overrideexec sp_configure 'xp _ mongoshell', 1 reconfigure with overrideexec sp_configure 'show advanced options', 0 RECONFIGURE WITH OVERRIDE

-- 2. Back up data using variables: declare @ db sysnamedeclare @ dbpath varchar (120) set @ db = 'shenyin' -- the file name is based on the database name + date YYYYMMDD + Extension set @ dbpath = 'd: \ '+ @ db + convert (varchar (10 ), getdate (), 112) + '. bak'

-- 3. Create a exec ing exec master in SQL .. xp_mongoshell 'net use Y: \ 192.168.0.156 \ DBBackup "jindou"/user: 192.168.0.156 \ Administrator '/* Description: Y: is the ing network path corresponding to the local drive letter 192.168.0.156 is my local IP DBBackup is my local shared folder Administrator is Login User Name "jindou" is Administrator user password */-- 4, backup (@ db is the name of the database to be backed up) backup Database @ db To disk = @ dbpath -- 5, COPYdeclare @ copypath varchar (200) set @ copypath = 'copy' + @ dbpath + 'y: 'select @ copypathexec master .. xp_cmdshell @ copypath -- 6. Delete (this sentence can be removed) declare @ deletepath varchar (200) set @ deletepath = 'del '+ @ dbpathselect @ deletepathexec master .. xp_mongoshell @ deletepath -- 7. Delete the exec ing exec master after completion .. xp_mongoshell 'net use Y:/delete'

-- 8. Disable xp_mongoshelluse master EXEC sp_configure 'show advanced options', 1 reconfigure with override exec sp_configure 'xp _ mongoshell', 0 reconfigure with override exec sp_configure 'show advanced options ', 0 RECONFIGURE WITH OVERRIDE

Kneeling: SQL remote database backup to local data

1. You can back up the database on a remote server and download the. bak file to restore it locally.

2. Connect to the remote server and select the database to be backed up. Right-click and choose task> Generate a script.
Then execute the script according to the wizard, but set the data writing script option to TRUE on the "select script option" page,
Next, select the table, stored procedure, view, and so on you want to back up to find the last. SQL file to be generated, and execute it locally.

How can I back up the SQL database on a remote server to a local machine ??

There are multiple methods, two commonly used methods are:
1. the backup data from the database is in the file format. download it to your local computer and import it.
2. in the MSSQL installation path: MSSQL \ Data \ find the database you want, such as 111.ldf, 111.mdf, download to local, operate locally, attach the database, and select these two files.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.