SQL Server Remote Backup Database

Source: Internet
Author: User

There is often a need to back up the database regularly. Scheduled backup to the local, or is quite easy, the scheduled task can be completed, but if the machine is hung, the backup to the machine is meaningless, then need to consider the backup to the LAN, other computers.

Below to share a copy on the Internet after the simple collation of the code, with SQL Server agent in the job function, has been running stably for one weeks, the hourly backup.

--Create a network map (y is the drive letter; the name of the shared folder after the IP address; password is the password, double quotation marks; account is the login name of the remote computer) exec master. xp_cmdshell ' net use Y: \\192.168.0.69\sqlbackup "password"/user:192.168.0.69\account '--file name by date time (note the folder in the path, Need to be established first) declare @filename varchar () Select @filename = ' Y:\DB\ ' + replace (replace (varchar, GETDATE (),  (), '-', '), ' ', '-'), ': ', ') + '. Bak '--Perform a backup (db is the name of the database to be backed up) backup database [db] to disk = @filename--delete network map (y is drive letter, IBID.) exec Master.. xp_cmdshell ' net use Y:/delete '

This article is from the "Rain Wandering Blog" blog, please be sure to keep this source http://kingrain.blog.51cto.com/91779/1614012

SQL Server Remote Backup Database

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.