备份
BACKUP DATABASE [msdb]
TO DISK = N'D:\liyuanshuai\test\sqlserver_bakfile\msdb20241219.bak'
WITH NOFORMAT, NOINIT, NAME = N'lys-完整 数据库 备份',
SKIP, NOREWIND, NOUNLOAD,
COMPRESSION,
STATS = 10
GO
然后删除2个测试的job,停止 SQL Server 代理(否则还原msdb库的时候会报错)
还原
USE [master]
RESTORE DATABASE [msdb]
FROM DISK = N'D:\liyuanshuai\test\sqlserver_bakfile\msdb20241219.bak'
WITH FILE = 1,
NOUNLOAD, STATS = 5GO
然后启动SQL Server 代理服务,刷新job后,删除的2个测试job就恢复了