--如果xp_cmdshell没有启用,请先启用 sp_configure 'show advanced options',1 RECONFIGURE GO sp_configure 'xp_cmdshell',1 RECONFIGURE --目标共享目录:\\172.16.1.63\Media2\zengsj 共享目录账号密码:administrator\000000 --1.先创建映射--EXEC MASTER.dbo.xp_cmdshell 'net use \\服务器IP\共享文件夹 用户密码 /user:服务器IP\登录用户名' EXEC MASTER.dbo.xp_cmdshell 'net use \\172.16.1.63\Media2\zengsj "000000" /user:172.16.1.63\administrator' --2.利用映射备份数据库 BACKUP DATABASE affair_stydy to disk='\\172.16.1.63\Media2\zengsj\demo_backup_2023_02_14.bak' --全备份 BACKUP DATABASE TestBackup] TO DISK = N'D:\database\demo_backup_2023_02_14.bak' WITH DIFFERENTIAL --差异备份 --3.删除映射 EXEC MASTER.dbo.xp_cmdshell 'net use \\172.16.1.63\Media2/zengsj/ delete'
原文引用:https://www.cnblogs.com/champaign/p/15161199.html
标签:cmdshell,--,备份,172.16,SERVER,1.63,SQL,xp From: https://www.cnblogs.com/wendus/p/17119370.html