search
HomeDatabaseMysql TutorialDB2数据库自动备份详解

DB2数据库自动备份详解

Jun 07, 2016 pm 03:08 PM
db2backupdatabaseautomaticDetailed explanation

DB2 数据库自动备份详解 1) 请先保证你的 DB2 数据库已安装,且运行正常 2) 在开始 - 运行,输入命令 db2cmd ,打开一个新的 db2 命令窗口: 在 DB2 的“命令窗口”执行下面语句创建备份运行数据库 db2 create tools catalog cc create new database toolsdb

DB2数据库自动备份详解

 

 

1)请先保证你的DB2数据库已安装,且运行正常

2) 在开始->运行,输入命令db2cmd,打开一个新的db2命令窗口:

 

DB2的“命令窗口”执行下面语句创建备份运行数据库

db2 create tools catalog cc create new database toolsdb

目的是创建一个命名为toolsdb的数据库,用来存放任务信息

 

3)开启“任务中心”窗口,如下图

4)新建任务

DB2数据库自动备份详解DB2数据库自动备份详解DB2数据库自动备份详解

请注意“类型”和“DB2实例和分区”按照上图选择

在“命令脚本”tab页中输入脚本:

BACKUP DATABASE JM_DAJ ONLINE TO "D:\DB2_BAK" WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 COMPRESS INCLUDE LOGS WITHOUT PROMPTING;

意思是把数据库JM_DAJ压缩备份到D:\DB2_BAK目录下(前提是D:\DB2_BAK目录已存在)

 

然后进入到“安排”tab页面

添加一个时间起始点,选择“重复安排”,如图所示,注意“运行时权限”也要填写,一般为administrator,密码为登陆windows系统时的密码

然后就可以点击“确定”按钮

 

到此DB2的自动备份已设置完成,每天备份一次,到“D:\DB2_BAK”目录下找备份文件。

 

       5)数据库删除

       当数据库备份逐日增加时,硬盘的容量就会越来越小,直到硬盘空间容量被占满,此时将不能再自动备份,因此,我们必须在一定时间内删除多余的数据库备份文件。

       C盘根目录下,建立一个bat文件,如db2autodel.bat,内容如下:

C:\WINDOWS\system32\forfiles /p D:\DB2_BAK /m *.* /d -7 /c "cmd /c del @file"

这样D:\DB2_BAK目录下的文件会保留7

      

新建一个任务计划:

浏览并找到建立在C盘根目录下的db2autodel.bat文件

 

选择每天执行这个任务,单击下一步:

 

选择起始时间,单击下一步:

 

单击完成按钮,系统即会根据您设置的信息,每天自动删除多余的历史数据库备份文件。

 

自此,完成了DB2数据库的自动备份及定时清除。

对于oa文件的定时备份,我们也可以建立bat文件来完成:(此命令需要调用WinRAR,请确保系统已经安装了WinRAR软件)

cd C:\Program Files\WinRAR

winrar a -r -ibck -y d:\DB2_BAK\%date:~4,10%.rar e:\DAJ_OA\Tomcat5.0\jmoa\*.*

意思是把oa程序包文件进行压缩并存储到d:\DB2_BAK目录下,注意本例中e:\DAJ_OA\Tomcat5.0\jmoaoa的程序包目录,各个单位的目录或许有差异,请根据实际路径修改,同样把此bat文件加到计划任务里则可以完成oa文件的自动备份。

如果服务器插有移动硬盘等,可以建立一个新的bat文件把自动备份的文件定时拷到移动硬盘里:xcopy d:\db2_bak F:\db2_bak /s/i/y 意思是把d:\db2_bak里的文件拷到F:\db2_bak里,同样把此bat文件加到计划任务里。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL BLOB : are there any limits?MySQL BLOB : are there any limits?May 08, 2025 am 12:22 AM

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

MySQL : What are the best tools to automate users creation?MySQL : What are the best tools to automate users creation?May 08, 2025 am 12:22 AM

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

MySQL: Can I search inside a blob?MySQL: Can I search inside a blob?May 08, 2025 am 12:20 AM

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc

MySQL String Data Types: A Comprehensive GuideMySQL String Data Types: A Comprehensive GuideMay 08, 2025 am 12:14 AM

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,idealforconsistentlengthdatalikecountrycodes;2)VARCHARforvariable-lengthstrings,suitableforfieldslikenames;3)TEXTtypesforlargertext,goodforblogpostsbutcanimpactperformance;4)BINARYandVARB

Mastering MySQL BLOBs: A Step-by-Step TutorialMastering MySQL BLOBs: A Step-by-Step TutorialMay 08, 2025 am 12:01 AM

TomasterMySQLBLOBs,followthesesteps:1)ChoosetheappropriateBLOBtype(TINYBLOB,BLOB,MEDIUMBLOB,LONGBLOB)basedondatasize.2)InsertdatausingLOAD_FILEforefficiency.3)Storefilereferencesinsteadoffilestoimproveperformance.4)UseDUMPFILEtoretrieveandsaveBLOBsco

BLOB Data Type in MySQL: A Detailed Overview for DevelopersBLOB Data Type in MySQL: A Detailed Overview for DevelopersMay 07, 2025 pm 05:41 PM

BlobdatatypesinmysqlareusedforvoringLargebinarydatalikeImagesoraudio.1) Useblobtypes (tinyblobtolongblob) Basedondatasizeneeds. 2) Storeblobsin Perplate Petooptimize Performance.3) ConsidersxterNal Storage Forel Blob Romana DatabasesizerIndimprovebackupupe

How to Add Users to MySQL from the Command LineHow to Add Users to MySQL from the Command LineMay 07, 2025 pm 05:01 PM

ToadduserstoMySQLfromthecommandline,loginasroot,thenuseCREATEUSER'username'@'host'IDENTIFIEDBY'password';tocreateanewuser.GrantpermissionswithGRANTALLPRIVILEGESONdatabase.*TO'username'@'host';anduseFLUSHPRIVILEGES;toapplychanges.Alwaysusestrongpasswo

What Are the Different String Data Types in MySQL? A Detailed OverviewWhat Are the Different String Data Types in MySQL? A Detailed OverviewMay 07, 2025 pm 03:33 PM

MySQLofferseightstringdatatypes:CHAR,VARCHAR,BINARY,VARBINARY,BLOB,TEXT,ENUM,andSET.1)CHARisfixed-length,idealforconsistentdatalikecountrycodes.2)VARCHARisvariable-length,efficientforvaryingdatalikenames.3)BINARYandVARBINARYstorebinarydata,similartoC

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools