Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make remote backup of mssql database

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to backup mssql database in different places". the explanation in this article is simple and clear, easy to learn and understand. please follow the idea of Xiaobian and go deep into it slowly to study and learn "how to backup mssql database in different places" together!

run SQL statements

declare @sql varchar(500)

select @sql='\\10.2.0.1\backup\dbname'+'_db_'+convert(varchar(10),getdate(),112) +

substring(convert(varchar(10),getdate(),108),1,2) +'.bak'

exec master.. xp_cmdshell 'net use \\10.2.0.1\backup 123123 /user:remotehost\hello'

backup database dbname to disk=@sql

--backup database, where 10.2.0.1 is the ip of the remote computer, backup is the name of the shared folder, dbname is the database to be backed up by the local sqlserver server, remotehost is the computer name of the remote computer, 123123 is the password,hello is the user name, please replace it with the actual environment data accordingly

go

declare @sql varchar(500)

select @sql='del '+'\\10.2.0.1\backup\dbname'+'_db_'+convert(varchar(10),dateadd(day,-7,getdate()),112) +

substring(convert(varchar(10),dateadd(day,-7,getdate()),108),1,2) +'.bak'

exec master.. xp_cmdshell @sql --Delete 7-day-old backups, i.e. keep only the 7 most recent backups

go

Thank you for reading, the above is "how to make remote backup of mssql database" content, after learning this article, I believe we have a deeper understanding of how to make remote backup of mssql database, and the specific use needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report