SQLFullbackup
/* ==Scripting Parameters== Source Server Version : SQL Server 2016 (13.0.1601)
Source Database Engine Edition : Microsoft SQL Server Enterprise Edition
Source Database Engine Type : Standalone SQL Server Target Server Version : SQL Server 2016
Target Database Engine Edition : Microsoft SQL Server Enterprise Edition
Target Database Engine Type : Standalone SQL Server
*/ USE [msdb]
GO /****** Object: Job [FullBackup] Script Date: 9/11/2017 7:50:54 PM ******/
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
/****** Object: JobCategory [[Uncategorized (Local)]] Script Date: 9/11/2017 7:50:54 PM ******/
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
BEGIN
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'[Uncategorized (Local)]'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback END DECLARE @jobId BINARY(16)
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'FullBackup',
@enabled=1,
@notify_level_eventlog=0,
@notify_level_email=0,
@notify_level_netsend=0,
@notify_level_page=0,
@delete_level=0,
@description=N'No description available.',
@category_name=N'[Uncategorized (Local)]',
@owner_login_name=N'CLOUD-88\Administrator', @job_id = @jobId OUTPUT
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
/****** Object: Step [FullBackup] Script Date: 9/11/2017 7:50:54 PM ******/
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'FullBackup',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_success_step_id=0,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0, @subsystem=N'TSQL',
@command=N'BACKUP DATABASE [master] TO DISK = N''\\SQL-AGBACKUP\AG\master.bak'' WITH COPY_ONLY, NOFORMAT, NOINIT, NAME = N''master_backup'', SKIP, REWIND, NOUNLOAD, STATS = 10
GO
BACKUP DATABASE [model] TO DISK = N''\\SQL-AGBACKUP\AG\model.bak'' WITH COPY_ONLY, NOFORMAT, NOINIT, NAME = N''model_backup'', SKIP, REWIND, NOUNLOAD, STATS = 10
GO
BACKUP DATABASE [msdb] TO DISK = N''\\SQL-AGBACKUP\AG\msdb.bak'' WITH COPY_ONLY, NOFORMAT, NOINIT, NAME = N''msdb_backup'', SKIP, REWIND, NOUNLOAD, STATS = 10
GO
DECLARE @preferredReplica int SET @preferredReplica = (SELECT [master].sys.fn_hadr_backup_is_preferred_replica(''OnlineLoansCommon'')) IF (@preferredReplica = 1)
BEGIN
BACKUP DATABASE [OnlineLoansCommon] TO DISK = N''\\SQL-AGBACKUP\AG\OnlineLoansCommon.bak'' WITH COPY_ONLY, NOFORMAT, NOINIT, NAME = N''OnlineLoansCommon'', SKIP, REWIND, NOUNLOAD, STATS = 10
END
GO
DECLARE @preferredReplica int SET @preferredReplica = (SELECT [master].sys.fn_hadr_backup_is_preferred_replica(''OnlineLoansCommonQA'')) IF (@preferredReplica = 1)
BEGIN
BACKUP DATABASE [OnlineLoansCommonQA] TO DISK = N''\\SQL-AGBACKUP\AG\OnlineLoansCommonQA.bak'' WITH COPY_ONLY, NOFORMAT, NOINIT, NAME = N''OnlineLoansCommonQA'', SKIP, REWIND, NOUNLOAD, STATS = 10
END
',
@database_name=N'master',
@flags=0
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:
GO
SQLFullbackup的更多相关文章
随机推荐
- docker的网络访问
Docker的网络访问: #systemctl start docker #ifconfig [root@zizhen02 ~]# ifconfig docker0: flags=4099<U ...
- 西门子SCL读写DB数据
数据块间接寻址方式,仅供参考. STATUS_1:= DB11.DW[COUNTER]; //字节间接寻址STATUS_2:= DB12.DX[WNO, BITNO]; //位间接寻址,用户改变WNO ...
- 商品规格,自定义SKU类型
<html> <head> <script type="text/javascript" src="http://xoxco.com/exa ...
- windows安装oracle-odbc驱动错误原因
在windows7上准备使用powerdesigner16连接oracle逆向生成表结构,确发现一直无法连接oracle,其原因是本机没有ODBC驱动. 第一步 安装oracle11g客户端,这里是具 ...
- VScode编辑器使用
快捷键: shift + alt + F 格式化
- ccf-集合竞价-201412-3
这道题数据量很小,所以用前缀和直接暴力解决了 首先将浮点数转换为整数; int_p=(int)(dou_p*100+0.5); 必须加一个eps,否则浮点数运算会有误差 然后从高到低枚举 #inclu ...
- 2018.9.12 B树总结
1. B-Tree B-树是一种平衡的多路查找树,它在文件系统中很有用. 1.1 B-Tree 特性 关键字集合分布在整颗树中: 任何一个关键字出现且只出现在一个结点中: 搜索有可能在非叶子结点结束: ...
- Python练习十
1.生成随机整数,从1-5取出来然后输入一个数字,来猜,如果大于,则打印bigger小了,则打印less如果相等,则打印equal. import random num1 = random.randi ...
- Scala基础
1.seq[String] 用[]表示参数类型,java使用<>表示参数,因为Scala 允许以<命名方法和变量名,java不允许 2.支持range的类型:Char .Int . ...
- 引擎设计跟踪(九.14.3.2) Deferred shading的后续实现和优化
最近完成了deferred shading和spot light的支持, 并作了一部分优化. 之前forward shading也只支持方向光, 现在也支持了点光源和探照光. 对于forward sh ...