Unix系统Informix数据备份技巧
笔者在单位使用Unix Openserver 5.05 操作系统和Informix 7.3 数据库管理系统。对如何做好Unix 系统Informix数据的备份,笔者在日常工作中积累了一些技巧,现介绍给大家。 一、Informix数据备份命令 1.Ontape命令:该命令可以在线进行数据备份,提供0、1、2
笔者在单位使用Unix Openserver 5.05 操作系统和Informix 7.3 管理系统。对如何做好Unix 系统Informix数据的备份,笔者在日常工作中积累了一些技巧,现介绍给大家。
一、Informix数据备份命令
1.Ontape命令:该命令可以在线进行数据备份,提供0、1、2级三种不同级别的备份方式,其0级备份是对数据空间的完整备份(包括数据库逻辑日志),其备份量较大,在此基础上的1、2级备份,是增量备份,备份量较小。但在数据恢复时,如果0级备份出了问题,则不能进行数据恢复。备份的数据以专用的格式存贮,对用户“不可见”,给用户一种不踏实的感觉。
2.Dbexport命令:该命令是对数据库的完整备份(包括数据结构)。备份的数据格式是文本文件,用户可以用VI进行编辑,进行部份数据恢复。但不能进行在线备份,需要使数据库离线。同时要对多个数据库进行备份时,要用shell程序实现。
3.Unload命令:该命令对数据库中的一张表进行备份。其优点是方便灵活,备份的数据格式是文本文件,用户可以用VI进行编辑,进行部分数据恢复。能实现在线数据备份。其缺点是如要对数据库进行完整备份,要进行编程。
通过以上介绍可知,Ontape命令面向数据空间、dbexport命令面向数据库、unload命令面向数据表,三种命令各有其长处,也有其不足。综合考虑,笔者认为采用ontape命令进行周备份(0级备份),用unload命令进行日备份比较合理,方便灵活。
二、用unload命令备份Informix-4gl
用unload命令备份Informix-4gl 的源程序如下:
Define database_name Char(20)
Main
Define tabname Char(18)
Define tmpstr Char(100)
Database database_name
Let database_name = Arg_Val(1)
Declare cur_unload0 Cursor For
Select @tabname From systables
Where @tabid 〉=100 And @tabtype = ="T"
ForEach cur_unload0 Into tabname
Display "Unloading ", tabname Clipped, "..."
Let tmpstr = "echo 'Unload To ", database_name Clipped, "/", tabname Clipped, ".unl Select From ", tabname Clipped,"' | isql ", database_name Clipped, " -"
Run tmpstr
End ForEach
Close Database
End Main
程序中数据库名从命令行中获得,对数据库中的每一张表进行循环,转存成相应表名的文本文件。
三、对多个数据库操作的Shell程序
以上程序操作的对象为单个数据库,如要对 Informix - 4gl 中的每一个数据库进行备份,则可以用一Shell程序执行。以下是相应的Shell程序,名为 auto_backup。
YYMMDD=`date '+%y%m%d'`
FILENAME=b$YYMMDD\.tar
unload0 motor
unload0 idc
……
tar -fcv $FILENAME
compress $FILENAME
省略号处可加上若干数据库。为了节省空间,对备份好的数据打包、压缩,生成一个文件。
四、将备份好的数据传送到数据备份机
对上述备份好的数据,需要将它异机备份或用磁带进行备份。笔者认为,设置一台专用数据备份机,并在该机上配有一光盘刻录机,可即时地将数据备份到可读写光盘上。
为了将数据从Unix 系统中传送到Windows 95或Windows 98中去,可使用FTP程序。为了使程序能自动执行,应在Unix用户中建立.netrc文件,并定义用户的FTP写目录为刻录光盘。以下是.netrc文件实例:
machine sjbf
login fq
passwd qqqqqq
该文件定义了FTP到一远程机器为sjbf,用户为fq,口令为 qqqqqq。
同时建立一文件 auto_ftp,其清单如下:
prompt off
put Z
文件auto_backup的最后加入命令:
ftp sjbf 〈 auto_ftp
五、自动定时执行备份
为了使计算机自动执行备份程序,可使用Unix系统中的cron定时执行机制,建议让Unix系统中的Informix用户去执行。在Unix系统中,用Informix用户登录,执行crontab -e,其内容为:
30 12 /prog/auto_backup
经过以上几步,我们就做好了自动备份程序,机器每天12:30会自动执行数据备份,并将数据送到可读写光盘中去,系统管理员要做的事,就是当光盘中的数据满时,换一张可读写光盘而已。这样数据备份,相对来讲比较安全可靠。如果有一远程机器可以FTP,则可以非常方便地进行远程异机备份,极大提高数据备份的可靠性。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values and pointers to data rows, and is suitable for non-primary key column queries.

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.
