MS SQL2000数据库自动备份的几种方法.txt
一、简单实用的备份方法
企业管理器中的Tools Database Maintenance Planner可以设置数据库的定期自动备份计划。并通过启动Sql server Agent来自动运行备份计划。具体步骤如下:
1、打开企业管理器在控制台根目录中依次点开Microsoft SQL Server-->SQLServer组-->双击打开你的服务器
2、然后点上面菜单中的工具-->选择数据库维护计划器
3、下一步选择要进行自动备份的数据-->下一步更新数据优化信息这里一般不用做选择-->下一步检查数据完整性也一般不选择
4、下一步指定数据库维护计划默认的是1周备份一次 点击更改选择每天备份后点确定
5、下一步指定备份的磁盘目录选择指定目录如您可以在D盘新建一个目录如 d:\da tab ak然后在这里选择使用此目录如果您的数据库比较多最好选择为每个数据库建立子目录然后选择删除早于多少天前的备份一般设定47天这看您的具体备份要求备份文件扩展名默认的是BAK
6、下一步指定事务日志备份计划看您的需要做选择-->下一步要生成的报表一般不做选择-->下一步维护计划历史记录最好用默认的选项-->下一步完成
7、完成后系统很可能会提示Sql Server Agent服务未启动先点确定完成计划设定然后找到桌面最右边状态栏中的SQL绿色图标双击点开在服务中选择SqlServer Agent然后点击运行箭头选上下方的当启动OS时自动启动服务
8、可以设置启动启动sql server Agent:运行Services.msc设置sqlserverAgent为自动启动。
修改备份计划
打开企业管理器在控制台根目录中依次点开Microsoft SQL Server-->SQL Server组-->双击打开你的服务器-->管理-->数据库维护计划
二、异地备份
运行环境分析
现有两台机器具体配置如下
操作系统两台都是Windows 2000 Advanced Server
数据库 Sql Server 2000
IP:一台是192.168.0.1另一台是192.168.0.100
要求定期自动实现将192.168.0.1中数据库中bbsbak数据库备份到192.168.0.100的机器上并删除15天以前对192.168.0.100中自动备份的bbsbak数据库。
注本操作涉及到Ms Sql Server2000数据库数据转换服务中包的高级设置、数据库存储过程、作业的添加及简单Transact_SQL语句的操作等内容在此不再详述请参考相关资料及微软官方网站。
操作步骤
1.在本机win2000中打开SQL数据库――数据转换服务――本地包如图screen.width*0.7) {this.re s ized=true; this.width=screen.width*0.7; this.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';} "border=0 onmousewheel="returnimgzoo m(this);"onmouse over="if(this.resize d)this.style.cursor='hand';"onclick="if(!this.re sized) {return false;} else
{window.open('attachments/month_0606/00001_Y7 l2 vTPXYJIN.jpg');}">
2.右键――新建包 出现如图画面screen.width*0.7) {this.re s ized=true; this.width=screen.width*0.7; this.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';} "border=0 onmousewheel="returnimgzoo m(this);"onmouse over="if(this.resize d)this.style.cursor='hand';"onclick="if(!this.re sized) {return false;} else
{window.open('attachments/month_0606/00002_CLxGkSexp hxp.j pg');}"res ized="true">
A首先建立Microsoft OLE DB Provider for SQL Server 如图screen.width*0.7) {this.res ized=true; this.width=scre en.width*0.7; this.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';}"border=0onmous ewhe e l="return imgzo om(this);"onmouseover="if(this.res ized)this.style.cursor='hand' ;"onc lick="if(!this.resized) {return false;} else
{win dow.open('attachments/month_0606/00003_pKIEkQ GWar4 l.jp g');}"res ized="true">
在此注意两点
第一指定的服务器应是192.168.0.100
第二192.168.0.100数据库的选择(在此我用master数据库)。
B下面建立执行SQL任务:未定义如图scre en.width*0.7) {this.res ized=true; this.width=screen.width*0.7; this.alt='点击在新窗口查看全图\nCTRL+鼠标滚轮放大或缩小';}"b order=0 onmousewheel="returnimgzoom(thi s);"onmouseover="if(this.res ized) this.style.curs or='hand' ;"
onc lick="if(!this.res ized) {returnfal se;} e lse {window.op en('attachments/month_0606/00004_ohD3JHl S 8hWw.jpg');}"resized="true">a.命令超时项设置为 300b.SQL语句为s e le c t'bb sb ak'+c onvert(varcha r(4),datep art(yyyy,getd ate()))
+c onve rt(va rc har(4),datep art(mm,ge tdate()))+c onvert(varc har(4),dat ep art(dd,getd a te()))
注释红色标记是实现备份后的数据库在bb sb ak后加上年月日
如bb sb ak20031023.c.点击参数A对参数进行相关设置 出现如上图界面screen.width*0.7) {this.res ize d=true; this.width=s creen.width*0.7; thi s.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';}"bo rder=0 onmousewhee l="returnimgzoom(this);"onmous eover="if(this.res iz ed) this.style.curso r='hand' ;"onclick="if(!this.resized) {return false;} else
{windo w.open('attac hments/mo nth_0606/00005_XmKg6kcX991 t.jpg');}"res ize d="true">
选输出参数如上图
输出参数类型为行值 点击创建全局变量 出现如图界面screen.width*0.7) {this.re s ized=true; this.width=screen.width*0.7; this.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';} "border=0 onmousewheel="returnimgzoo m(this);"onmouse over="if(this.resize d)this.style.cursor='hand';"onclick="if(!this.re sized) {return false;} else
{window.open('attachments/month_0606/00006_xTCkaC lz5 F5o.jpg');}"re s ized="true">全局变量的名称为 bbsbak_crt确定后返回参数映射界面
选择输出全局变量为:b b sb ak_crt
OK,第一个SQL任务建立成功
C下面建立另外一个执行SQL任务:未定义如图screen.width*0.7) {this.res ized=true; this.width=screen.width*0.7; this.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';}"border=0 onmousewheel="return
imgzoom(this);"onmouseo ver="if(this.re sized) thi s.style.cursor='hand';"onc lick="if(!this.res ized) {return false;} els e
{window.open('atta chme nts/mo nth_0606/00007_OUOn5 MK 1 f0 My.jp g');} "res ized="true">
其中SQL语句为 exec crtdatabase_bbsbak.
OK,继续
D建立复制SQL Server对象任务:未定义如图screen.width*0.7) {this.re s ized=true; this.width=screen.width*0.7; this.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';} "border=0 onmousewheel="returnimgzoo m(this);"onmouse over="if(this.resize d)this.style.cursor='hand';"onclick="if(!this.re sized) {return false;} else
{window.open('attachments/month_0606/00008_fUuVEKyMg7cD.j pg');}"res ized="true">
注意此时源服务器为 192.168.0.1,选择要备份的数据库bbsbak
下面转到目的服务中参数如图设置screen.width*0.7) {this.res ize d=true; this.width=s creen.width*0.7; thi s.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';}"bo rder=0 onmousewhee l="returnimgzoom(this);"onmous eover="if(this.res iz ed) this.style.curso r='hand' ;"onclick="if(!this.resized) {return false;} else
{windo w.open('attac hments/mo nth_0606/00009_xQ KiP GIxhnH i.jp g');}"r es ize d="true">OK继续
E建立动态属性任务:未定义如图screen.width*0.7) {this.res ized=true; this.width=screen.width*0.7; this.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';}"border=0 onmousewheel="returnimgz oom(this);"onmouseo ver="if(this.re sized) thi s.style.cursor='hand';"onc lick="if(!this.res ized) {return false;} els e
{window.open('atta chme nts/mo nth_0606/000010_X5yM 8Vr9TM zi.j pg');}"res ized="true">
OK!
F:下面设置工作流状态如图
screen.width*0.7) {this.res ize d=true; this.width=s creen.width*0.7; thi s.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';}"bo rder=0 onmousewhee l="returnimgzoo m(this);"o nmous eover="if(this.res iz ed) this.style.curso r='hand' ;"onclick="if(!this.resized) {return false;} else
{w indo w.op en('attac hments/mo nth_0606/000011_RuUCj 5 uHVHK g.jpg');}"re s ized="true">
保存为bbsbak_D TS,如图screen.width*0.7) {this.res ize d=true; this.width=s creen.width*0.7; thi s.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';}"bo rder=0 onmousewhee l="returnimgzoo m(this);"o nmous eover="if(this.res iz ed) this.style.curso r='hand' ;"onclick="if(!this.resized) {return false;} else
{windo w.op en('attac hments/mo nth_0606/000012_liyvn4GnJwH z.jpg');}"re s ized="true">
下面调度包
调度前保证SQL agent server启动screen.width*0.7) {this.re s ized=true; this.width=screen.width*0.7; this.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';} "border=0 onmousewheel="returnimgzoo m(this);"onmouse over="if(this.resize d)this.style.cursor='hand';"onclick="if(!this.re sized) {return false;} else
{window.open('attachments/month_0606/000013_Jzyc mRVC bgEO.jp g');}"res ize d="true">
到此本机中192.168.0.1上的操作完成。
3.打开192.168.0.100机器中的sql数据库――Master数据库――存储过程,如图screen.width*0.7) {this.re s ized=true; this.width=screen.width*0.7; this.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';} "border=0 onmousewheel="returnimgzoo m(this);"onmouse over="if(this.resize d)this.style.cursor='hand';"onclick="if(!this.re sized) {return false;} else
{window.open('attachments/month_0606/000014_saj kx9 uu8GO 1.jpg');}"res ize d="true">
存储过程如下screen.width*0.7) {this.res ize d=true; this.width=s creen.width*0.7; thi s.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';}"bo rder=0 onmousewhee l="returnimgzoo m(this);"o nmous eover="if(this.res iz ed) this.style.curso r='hand' ;"onclick="if(!this.resized) {return false;} else
{windo w.open('attac hments/mo nth_0606/000015_3 QFuNc lMZMQ l.jpg');}"res ized="true">
文本语法为
CREATE pro c crtdatabase_bbsbakasdeclare@sq l varc har(120)declare@sql2 varchar(120)declare@sql3 varchar(260)dec lare@na lj a va rc har(12)s et@na lj a=c o nvert(var c har(4),da tep art(yyyy,ge tdate()))+c onve rt(varc har(4),dat ep art(mm,getda te()))+convert(var char(4),datep a rt(dd,ge t date()))set@sql='create datab ase bbsbak'+@nalj a+'on(name='+'''backup_md f'+@nalja+''',filename=''E:\bb sbak\ba ckup_md f\b b sbak'+@nalj a+' .md f' ')'set@sql2='Lo g on(name='+'backup_ldf'+@nalj a+' ,filename=''E:\bb sbak\backup_ldf\bb sb ak'+@na lj a+' .ld f' ')'set@sql3=@sq l+@sql2
--select@sql3exec (@sql3)
GO
注意 E:\DB_backup\F ull_b ackup\此路径中的DB_b ackup和Full_backup文件夹应当事先在本机E盘上建立好
同样再建立一个存储过程语法为
CREATE proc deldatabase_bbsbakasdec lare@na lj a va rc har(12)
dec lare@sql varchar(120)set@na lj a=c onvert(var c har(4),d atep art(yyyy,getdat e()-15))+c onvert(var cha r(4),datep a rt(mm,getd ate()-15))
+c onve rt(va rc har(4),datep ar t(dd,getd ate()-15))set@sql='drop database nage'+@naljaexec (@sql)
GO
最后再agent server中建立一个作业调度存储过程其中作业中的步骤命令为 execde ldatabase_bbsbak
注意调度时的日期应当推迟15天
OK了
三、本地备份
若是在本机192.168.0.1中实现自动备份
操作如下 sql agent中直接添加作业bbsbak_full_ba ckup
如图screen.width*0.7) {this.res ize d=true; this.width=s creen.width*0.7; thi s.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';}"bo rder=0 onmousewhee l="returnimgzoo m(this);"o nmous eover="if(this.res iz ed) this.style.curso r='hand' ;"onclick="if(!this.resized) {return false;} else
{windo w.open('attac hments/mo nth_0606/000016_WfVh20VMAb m3.jpg');}"res ized="true">
其中作业中的步骤命令为
BAC KUP DATABASE bbsbak TO DI SK='F:\DB_backup\Full_b ackup\bbsb ak.bak'WITH IN IT,NOUNLOAD,NAME=N'bbsbak Full backup' ,SKIP,STATS=
10,NOFORMAT
注意 F:\DB_b ackup\F ull_backup\此路径中的DB_backup和F ull_backup文件夹应当事先在本机上建立好
日志文件的步骤同样添加作业 bb sb ak_lo g_b ackup
screen.width*0.7) {this.res ized=true; this.width=screen.width*0.7; this.alt='点击在新窗口查看全图\nC TRL+鼠标滚轮放大或缩小';}"border=0 onmousewheel="returnimgz oom(this);"onmouseo ver="if(this.re sized) thi s.style.cursor='hand';"onc lick="if(!this.res ized) {return false;} els e
{window.open('atta chme nts/mo nth_0606/000017_52WAGCH f5 FUb.j pg');}"res ized="true">
其中作业中的步骤命令为
BACKUP LO G[bb sbak]TO DI SK=N'F:\DB_ba ckup\Lo g_b ackup\bb sbak_lo g.bak'WITH INIT,NOUNLOAD,NAME=N'bbsbak log backup',NOSKIP,STATS=10,NOFORMAT
注意 F:\DB_b ackup\Lo g_backup\此路径中的DB_backup和Lo g_bac kup文件夹应当事先在本机上建立好
好到此所有的操作已完成望各位继续讨论。
数据库自动备份简易贴方法二
一配置发布服务器
在发布服务器上执行以下步骤:
(1)从[工具]下拉菜单的[复制]子菜单中选择[配置发布、订阅服务器和分发]出现配置发布和分发向导
(2) [下一步]选择分发服务器可以选择把发布服务器自己作为分发服务器或者其他sql的服务器
(3) [下一步]设置快照文件夹
一般采用默认\\servername\d$\Pro gram F iles\Micro so ft SQL S erver\MSSQ L\Rep lData
**(4) [下一步]自定义配置
可以选择:
是,让我设置分发数据库属性启用发布服务器或设置发布设置
否,使用下列默认设置
建议采用自定义设置
(5) [下一步]设置分发数据库名称和位置采用默认值
(6) [下一步]启用发布服务器选择作为发布的服务器
(7) [下一步]选择需要发布的数据库和发布类型
(8) [下一步]选择注册订阅服务器
(9) [下一步]完成配置
二创建出版物
发布服务器上
(1)从[工具]菜单的[复制]子菜单中选择[创建和管理发布]命令
(2)选择要创建出版物的数据库然后单击[创建发布]
(3)在[创建发布向导]的提示对话框中单击[下一步]系统就会弹出一个对话框。对话框上的内容是复制的三个类型。我们现在选第一个也就是默认的快照发布(其他两个大家可以去看看帮助)
(4)单击[下一步]系统要求指定可以订阅该发布的数据库服务器类型,
SQLSERVER允许在不同的数据库如ORACLE或ACCESS之间进行数据复制。但是在这里我们选择运行"SQL SERVER 2000"的数据库服务器
(5)单击[下一步]系统就弹出一个定义文章的对话框也就是选择要出版的表注意:如果前面选择了事务发布则再这一步中只能选择带有主键的表
(6)选择发布名称和描述
**(7)自定义发布属性
向导提供的选择:
是我将自定义数据筛选,启用匿名订阅和或其他自定义属性
hosteons当前对美国洛杉矶、达拉斯、纽约数据中心的VPS进行特别的促销活动:(1)免费从1Gbps升级到10Gbps带宽,(2)Free Blesta License授权,(3)Windows server 2019授权,要求从2G内存起,而且是年付。 官方网站:https://www.hosteons.com 使用优惠码:zhujicepingEDDB10G,可以获得: 免费升级10...
greencloudvps怎么样?greencloudvps是一家国外主机商,VPS数据中心多,之前已经介绍过多次了。现在有几款10Gbps带宽的特价KVM VPS,Ryzen 3950x处理器,NVMe硬盘,性价比高。支持Paypal、支付宝、微信付款。GreenCloudVPS:新加坡/美国/荷兰vps,1核@Ryzen 3950x/1GB内存/30GB NVMe空间/1TB流量/10Gbps...
RAKsmart怎么样?RAKsmart机房即日起开始针对洛杉矶机房的独立服务器进行特别促销活动:低至$76.77/月,最低100Mbps带宽,最高10Gbps带宽,优化线路,不限制流量,具体包括有:常规服务器、站群服务器、10G大带宽服务器、整机机柜托管。活动截止6月30日结束。RAKsmart,美国华人老牌机房,专注于圣何塞服务器,有VPS、独立服务器等。支持PayPal、支付宝付款。点击直达...