基于ontape的备份与恢复实验

说明:
可以使用ontape命令,进行SinoDB数据库的备份和恢复。
在使用ontape命令进行数据的备份和恢复时,可以选择只进行物理恢复和完全恢复(物理恢复+逻辑日志恢复)。
基于ontape的备份,无法直接使用ontape命令进行基于时间点的恢复。如果需要基于时间点的恢复功能,请使用onbar命令进行数据备份。
ontape与onbar两个命令的数据备份不兼容,我们无法使用ontape命令来恢复由onbar命令生成的备份文件,也无法使用onbar命令来恢复由ontape命令生成的备份文件。

环境参数设置

使用ontape进行数据库的备份与恢复时,需要设置ontape默认使用的存储设备。
可通过修改参数文件,或使用onmode -wf命令,设置SinoDB的参数。可通过onstat -c命令,查看SinoDB的参数设置。
检查onconfig文件中备份的存储设备参数,发现未指定。

[informix@vm84145 ~]$ onstat -g cfg |grep TAPEDEV |grep -v '#'
TAPEDEV                   /dev/null
LTAPEDEV                  /dev/null

创建一个目录,并设置物理备份和逻辑备份的存储设备为新创建的目录。

mkdir backup
onmode -wf "LTAPEDEV=/home/informix/backup"
onmode -wf "TAPEDEV=/home/informix/backup"


[informix@vm84145 ~]$ mkdir backup
[informix@vm84145 ~]$ onmode -wf "LTAPEDEV=/home/informix/backup"
Value of LTAPEDEV has been changed to /home/informix/backup.
[informix@vm84145 ~]$ onmode -wf "TAPEDEV=/home/informix/backup"
Value of TAPEDEV has been changed to /home/informix/backup.

查看备份设备参数,已经指向新创建的目录。

onstat -g cfg |grep TAPEDEV |grep -v '#'
[informix@vm84145 ~]$ onstat -g cfg |grep TAPEDEV |grep -v '#'
TAPEDEV                   /home/informix/backup
LTAPEDEV                  /home/informix/backup
[informix@vm84145 ~]$ 

备份与恢复实验

业务场景:数据库空间文件被删除时的数据恢复

步骤1:创建数据库与表

语法

create database tapedb in datadbs1 with log;
create table t_dept(f_deptid int, f_deptname varchar(20));
create table t_employee(f_employeeid int, f_deptid int, f_employeename varchar(20));

操作演示

[informix@vm84145 ~]$ dbaccess - -
> create database tapedb in datadbs1 with log;

Database created.

> 
> create table t_dept(f_deptid int, f_deptname varchar(20));     

Table created.

> create table t_employee(f_employeeid int, f_deptid int, f_employeename varchar(20));

Table created.

> info tables;


Table name

t_dept             t_employee         

> 

实验的数据库和表创建完成。

步骤2:L0备份前的数据准备

语法

insert into t_dept values(1, 'dept_1');
insert into t_dept values(2, 'dept_2');
insert into t_dept values(3, 'dept_3');

insert into t_employee values(1, 1, 'employee_01');
insert into t_employee values(2, 1, 'employee_02');
insert into t_employee values(3, 2, 'employee_03');
insert into t_employee values(4, 2, 'employee_04');
insert into t_employee values(5, 3, 'employee_05');

操作演示

> select * from t_dept;


   f_deptid f_deptname           

          1 dept_1              
          2 dept_2              
          3 dept_3              

3 row(s) retrieved.

> select * from t_employee;


f_employeeid    f_deptid f_employeename       

           1           1 employee_01         
           2           1 employee_02         
           3           2 employee_03         
           4           2 employee_04         
           5           3 employee_05         

5 row(s) retrieved.

>

两个表生成L0备份需要的测试数据。
在L0备份前,t_dept表有3条记录,t_employee表有5条记录。在将数据库物理恢复到L0时,可恢复t_dept中的3条记录和t_employee中的5条记
录。

步骤3:执行L0备份

语法

ontape -s -L 0

其中
-s:表示备份整个系统
-L:表示备份级别
操作演示

[informix@vm84145 ~]$ ontape -s -L 0
100 percent done.
File created: /home/informix/backup/vm84145_0_L0

Please label this tape as number 1 in the arc tape sequence. 
This tape contains the following logical logs:

 7

Program over.
[informix@vm84145 ~]$ cd backup/
[informix@vm84145 backup]$ ll
total 204320
-rw-rw---- 1 informix informix 209223680 Feb 23 23:14 vm84145_0_L0
[informix@vm84145 backup]$ 

执行L0备份后,目录中生成一个名称为vm84145_0_L0的备份文件。vm84145是服务器名,0是数据库实例ID,L0表示一个0级备份。

步骤4:L1备份前的数据准备

语法

insert into t_employee values(11, 1, 'employee_11');
insert into t_employee values(12, 1, 'employee_12');
insert into t_employee values(13, 2, 'employee_13');
insert into t_employee values(14, 2, 'employee_14');
insert into t_employee values(15, 3, 'employee_15');

操作演示

> select * from t_employee;


f_employeeid    f_deptid f_employeename       

           1           1 employee_01         
           2           1 employee_02         
           3           2 employee_03         
           4           2 employee_04         
           5           3 employee_05         
          11           1 employee_11         
          12           1 employee_12         
          13           2 employee_13         
          14           2 employee_14         
          15           3 employee_15         

10 row(s) retrieved.

> 

t_employee中数据添加5条记录,用于L1的备份测试。

步骤5:执行L1备份

ontape -s -L 1

操作演示

[informix@vm84145 backup]$ ontape -s -L 1
100 percent done.
File created: /home/informix/backup/vm84145_0_L1

Please label this tape as number 1 in the arc tape sequence. 
This tape contains the following logical logs:

 7

Program over.
[informix@vm84145 backup]$ ll
total 381152
-rw-rw---- 1 informix informix 209223680 Feb 23 23:14 vm84145_0_L0
-rw-rw---- 1 informix informix 181075968 Feb 23 23:20 vm84145_0_L1
[informix@vm84145 backup]$ 

执行L1备份后,目录中生成一个名称为vm84145_0_L1的备份文件。vm84145是服务器名,0是数据库实例ID,L1表示一个1级备份。

步骤6:L1备份前的数据准备(第二次)

语法

insert into t_employee values(16, 3, 'employee_16');

操作演示

[informix@vm84145 backup]$ dbaccess tapedb -

Database selected.

> insert into t_employee values(16, 3, 'employee_16');

1 row(s) inserted.

> select * from t_employee;


f_employeeid    f_deptid f_employeename       

           1           1 employee_01         
           2           1 employee_02         
           3           2 employee_03         
           4           2 employee_04         
           5           3 employee_05         
          11           1 employee_11         
          12           1 employee_12         
          13           2 employee_13         
          14           2 employee_14         
          15           3 employee_15         
          16           3 employee_16         

11 row(s) retrieved.

> 

在第二次L1备份前,t_employee表有11条记录。
可通过L1的物理恢复,得到t_employee表的11条记录。

步骤7:执行L1备份(第二次)

ontape -s -L 1

操作演示

[informix@vm84145 backup]$ ontape -s -L 1
100 percent done.
File created: /home/informix/backup/vm84145_0_L1

Please label this tape as number 1 in the arc tape sequence. 
This tape contains the following logical logs:

 7

Program over.
[informix@vm84145 backup]$ ll
total 557984
-rw-rw---- 1 informix informix 181075968 Feb 23 23:20 vm84145_0_20220223_232007_L1
-rw-rw---- 1 informix informix 209223680 Feb 23 23:14 vm84145_0_L0
-rw-rw---- 1 informix informix 181075968 Feb 23 23:25 vm84145_0_L1
[informix@vm84145 backup]$ 

当连续执行L 1备份时,原来的L1备份会被重命名为
图片4
新备份的文件仍为
图片5

步骤8:L2备份前的数据准备

语法

insert into t_employee values(21, 1, 'employee_21');
insert into t_employee values(22, 1, 'employee_22');
insert into t_employee values(23, 2, 'employee_23');
insert into t_employee values(24, 2, 'employee_24');
insert into t_employee values(25, 3, 'employee_25');

演示

> select * from t_employee;


f_employeeid    f_deptid f_employeename       

           1           1 employee_01         
           2           1 employee_02         
           3           2 employee_03         
           4           2 employee_04         
           5           3 employee_05         
          11           1 employee_11         
          12           1 employee_12         
          13           2 employee_13         
          14           2 employee_14         
          15           3 employee_15         
          16           3 employee_16         
          21           1 employee_21         
          22           1 employee_22         
          23           2 employee_23         
          24           2 employee_24         
          25           3 employee_25         

16 row(s) retrieved.

> 

在L2备份前,t_employee表有16条记录。
可通过L2的物理恢复,得到t_employee表的16条记录。

步骤9:执行L2备份

ontape -s -L 2

演示

[informix@vm84145 backup]$ ontape -s -L 2
100 percent done.
File created: /home/informix/backup/vm84145_0_L2

Please label this tape as number 1 in the arc tape sequence. 
This tape contains the following logical logs:

 7

Program over.
[informix@vm84145 backup]$ ll
total 734848
-rw-rw---- 1 informix informix 181075968 Feb 23 23:20 vm84145_0_20220223_232007_L1
-rw-rw---- 1 informix informix 209223680 Feb 23 23:14 vm84145_0_L0
-rw-rw---- 1 informix informix 181075968 Feb 23 23:25 vm84145_0_L1
-rw-rw---- 1 informix informix 181108736 Feb 23 23:43 vm84145_0_L2
[informix@vm84145 backup]$ 

至此,三级备份已经完成。

步骤10:切换逻辑日志前的数据准备

语法

insert into t_dept values(4, 'dept_4');
update t_employee set f_employeename = 'employee_updated' where f_employeeid = 11;

演示

[informix@vm84145 backup]$ dbaccess tapedb -

Database selected.

> insert into t_dept values(4, 'dept_4');

1 row(s) inserted.

> update t_employee set f_employeename = 'employee_updated' where f_employeeid = 11;

1 row(s) updated.

> 

数据查看

> select * from t_dept;


   f_deptid f_deptname           

          1 dept_1              
          2 dept_2              
          3 dept_3              
          4 dept_4              

4 row(s) retrieved.

> select * from t_employee;


f_employeeid    f_deptid f_employeename       

           1           1 employee_01         
           2           1 employee_02         
           3           2 employee_03         
           4           2 employee_04         
           5           3 employee_05         
          11           1 employee_updated    
          12           1 employee_12         
          13           2 employee_13         
          14           2 employee_14         
          15           3 employee_15         
          16           3 employee_16         
          21           1 employee_21         
          22           1 employee_22         
          23           2 employee_23         
          24           2 employee_24         
          25           3 employee_25         

16 row(s) retrieved.

> 

上面的数据更新和数据插入,用于模拟在备份后的新业务发生。

步骤11:切换逻辑日志

切换前,当前的逻辑日志文件(number)是7,唯一编号(uniqid)为7。

[informix@vm84145 backup]$ onstat -l

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- On-Line -- Up 5 days 03:53:53 -- 2374324 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-2  24       1024     34255      924        37.07
      phybegin         physize    phypos     phyused    %used   
      3:53             1023945    46558      24         0.00    

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-2  0        512      448373     62687      49756      7.2        1.3     
        Subsystem    numrecs    Log Space used
        OLDRSAM      447573     48095856      
        HA           667        29348         
        DDL          133        46284         

address          number   flags    uniqid   begin                size     used    %used
475dffa8         7        U---C-L  7        2:53               102390    88177    86.12
475fbf88         8        A------  0        2:102443           102390        0     0.00
48882d90         9        A------  0        2:204833           102390        0     0.00
48882df8         10       A------  0        2:307223           102390        0     0.00
48882e60         11       A------  0        2:409613           102390        0     0.00
48882ec8         12       A------  0        2:512003           102390        0     0.00
48882f30         13       A------  0        2:614393           102390        0     0.00
48882f98         14       A------  0        2:716783           102390        0     0.00
473abf68         15       A------  0        2:819173           102390        0     0.00
47481f40         16       A------  0        2:921563           102390        0     0.00
 10 active, 10 total

[informix@vm84145 backup]$ 

执行逻辑日志切换命令

[informix@vm84145 backup]$ onmode -l

切换后,当前的逻辑日志文件(number)是8,唯一编号(uniqid)为8。

[informix@vm84145 backup]$ onstat -l

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- On-Line -- Up 5 days 03:55:14 -- 2374324 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-2  16       1024     34294      926        37.03
      phybegin         physize    phypos     phyused    %used   
      3:53             1023945    46597      31         0.00    

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-3  0        512      448398     62694      49763      7.2        1.3     
        Subsystem    numrecs    Log Space used
        OLDRSAM      447597     48098256      
        HA           668        29392         
        DDL          133        46284         

address          number   flags    uniqid   begin                size     used    %used
475dffa8         7        U-----L  7        2:53               102390    88180    86.12
475fbf88         8        U---C--  8        2:102443           102390        4     0.00
48882d90         9        A------  0        2:204833           102390        0     0.00
48882df8         10       A------  0        2:307223           102390        0     0.00
48882e60         11       A------  0        2:409613           102390        0     0.00
48882ec8         12       A------  0        2:512003           102390        0     0.00
48882f30         13       A------  0        2:614393           102390        0     0.00
48882f98         14       A------  0        2:716783           102390        0     0.00
473abf68         15       A------  0        2:819173           102390        0     0.00
47481f40         16       A------  0        2:921563           102390        0     0.00
 10 active, 10 total

[informix@vm84145 backup]$ 

步骤12:灾难前的最后一次数据变更

语法

delete from t_employee where f_employeeid = 14;

在灾难发生前,删除一个记录,用于后续恢复时的验证用例。

[informix@vm84145 backup]$ dbaccess tapedb -

Database selected.

> delete from t_employee where f_employeeid = 14;

1 row(s) deleted.

> select * from t_employee;


f_employeeid    f_deptid f_employeename       

           1           1 employee_01         
           2           1 employee_02         
           3           2 employee_03         
           4           2 employee_04         
           5           3 employee_05         
          11           1 employee_updated    
          12           1 employee_12         
          13           2 employee_13         
          15           3 employee_15         
          16           3 employee_16         
          21           1 employee_21         
          22           1 employee_22         
          23           2 employee_23         
          24           2 employee_24         
          25           3 employee_25         

15 row(s) retrieved.

> select * from t_dept;


   f_deptid f_deptname           

          1 dept_1              
          2 dept_2              
          3 dept_3              
          4 dept_4              

4 row(s) retrieved.

>  

步骤13:模拟灾难发生

我们在步骤1中执行create database tapedb in datadbs1 with log;,指定演示数据库创建在datadbs1中,我们可以删除该数据库空间对应的文件,破坏数据。
使用onstat -d列出数据库中的表空间。

[informix@vm84145 ~]$ onstat -d

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- On-Line -- Up 5 days 21:29:58 -- 2374324 Kbytes

Dbspaces
address          number   flags      fchunk   nchunks  pgsize   flags    owner    name
47481028         1        0x1        1        1        2048     N  BA    informix rootdbs
48ab60d8         2        0x1        2        1        2048     N  BA    informix llogdbs
48ab6318         3        0x1        3        1        2048     N  BA    informix plogdbs
48ab6558         4        0x2001     4        1        8192     N TBA    informix tempdbs1
48ab6798         5        0x2001     5        1        8192     N TBA    informix tempdbs2
48ab69d8         6        0x2001     6        1        8192     N TBA    informix tempdbs3
48ab6c18         7        0x11       7        1        8192     N BBA    informix bindbs1
48ab7028         8        0x8001     8        1        2048     N SBA    informix sbdbs1
48ab7268         9        0x1        9        1        2048     N  BA    informix datadbs1
48ab74a8         10       0x1        10       1        2048     N  BA    informix datadbs2
48ab76e8         11       0x1        11       1        2048     N  BA    informix datadbs3
48ab7928         12       0x1        12       1        2048     N  BA    informix datadbs4
48ab7b68         13       0x1        13       1        2048     N  BA    informix datadbs5
 13 active, 2047 maximum

Note: For BLOB chunks, the number of free pages shown is out of date.
      Run 'onstat -d update' for current stats.

Chunks
address          chunk/dbs     offset     size       free       bpages     flags pathname
47481268         1      1      0          1024000    1010153               PO-B-D /home/informix/dbs/rootdbs
48ab9028         2      2      0          1024000    47                    PO-B-D /home/informix/dbs/llogdbs
48aba028         3      3      0          1024000    2                     PO-B-D /home/informix/dbs/plogdbs
48abb028         4      4      0          64000      63947                 PO-B-- /home/informix/dbs/tempdbs1
48abc028         5      5      0          64000      63947                 PO-B-- /home/informix/dbs/tempdbs2
48abd028         6      6      0          64000      63947                 PO-B-- /home/informix/dbs/tempdbs3
48abe028         7      7      0          512000    ~127872     128000     POBB-D /home/informix/dbs/bindbs1
48abf028         8      8      0          512000     477454     477465     POSB-D /home/informix/dbs/sbdbs1
                                 Metadata 34482      25659      34482   
48ac0028         9      9      0          1024000    1019161               PO-B-D /home/informix/dbs/datadbs1-1
48ac1028         10     10     0          1024000    1023947               PO-B-D /home/informix/dbs/datadbs2-1
48ac2028         11     11     0          1024000    1023947               PO-B-D /home/informix/dbs/datadbs3-1
48ac3028         12     12     0          1024000    1023947               PO-B-D /home/informix/dbs/datadbs4-1
48ac4028         13     13     0          1024000    1023947               PO-B-D /home/informix/dbs/datadbs5-1
 13 active, 32766 maximum

NOTE: The values in the "size" and "free" columns for DBspace chunks are
      displayed in terms of "pgsize" of the DBspace to which they belong.


Expanded chunk capacity mode: always

[informix@vm84145 ~]$ 

根据Dbspaces部分的name列中的datadbs1,得到datadbs1的编号(number)为9。
Dbspaces

address          number   flags      fchunk   nchunks  pgsize   flags    owner    name
......
48ab7268         9        0x1        9        1        2048     N  BA    informix datadbs1

进入目录,删除文件。

[informix@vm84145 dbs]$ cd /home/informix/dbs/
[informix@vm84145 dbs]$ ll
total 19968000
-rw-rw---- 1 informix informix 1048576000 Feb 14 23:49 bindbs1
-rw-rw---- 1 informix informix 2097152000 Feb 24 19:28 datadbs1-1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs2-1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs3-1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs4-1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs5-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:03 llogdbs
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:03 plogdbs
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:03 rootdbs
-rw-rw---- 1 informix informix 1048576000 Feb 18 19:53 sbdbs1
-rw-rw---- 1 informix informix  524288000 Feb 24 21:13 tempdbs1
-rw-rw---- 1 informix informix  524288000 Feb 24 21:13 tempdbs2
-rw-rw---- 1 informix informix  524288000 Feb 24 20:13 tempdbs3
[informix@vm84145 dbs]$ rm -rf datadbs1-1
[informix@vm84145 dbs]$ ll
total 17920000
-rw-rw---- 1 informix informix 1048576000 Feb 14 23:49 bindbs1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs2-1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs3-1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs4-1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs5-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:08 llogdbs
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:08 plogdbs
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:08 rootdbs
-rw-rw---- 1 informix informix 1048576000 Feb 18 19:53 sbdbs1
-rw-rw---- 1 informix informix  524288000 Feb 24 21:13 tempdbs1
-rw-rw---- 1 informix informix  524288000 Feb 24 21:13 tempdbs2
-rw-rw---- 1 informix informix  524288000 Feb 24 20:13 tempdbs3
[informix@vm84145 dbs]$ 

删除数据空间文件成功。

步骤14:灾难后的第一次数据变更

在数据库空间文件被删除后,对t_dept表的INSERT操作可以成功。

[informix@vm84145 ~]$ dbaccess tapedb -

Database selected.

> insert into t_dept values(5, 'dept_5');

1 row(s) inserted.

> select * from t_dept;


   f_deptid f_deptname           

          1 dept_1              
          2 dept_2              
          3 dept_3              
          4 dept_4              
          5 dept_5              

5 row(s) retrieved.

> 

虽然删除了文件,但数据库在短时间内还可以工作。

步骤15:重启数据库,出现错误信息。

为了演示效果,我们重启一下数据库。

[informix@vm84145 ~]$ onmode -ky
[informix@vm84145 ~]$ oninit -vy
Reading configuration file '/home/informix/sinodb/etc/onconfig.sinodb'...succeeded
Creating /INFORMIXTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 22166 kbytes...succeeded
Creating infos file "/home/informix/sinodb/etc/.infos.sinodb"...succeeded
Linking conf file "/home/informix/sinodb/etc/.conf.sinodb"...succeeded
Initializing rhead structure...rhlock_t 32768 (1024K)... rlock_t (13281K)... Writing to infos file...succeeded
Initialization of Encryption...succeeded
Initializing ASF...succeeded
Initializing Dictionary Cache and SPL Routine Cache...succeeded
Initializing encryption-at-rest if necessary...succeeded
Bringing up ADM VP...succeeded
Creating VP classes...succeeded
Forking main_loop thread...succeeded
Initializing DR structures...succeeded
Forking 1 'soctcp' listener threads...succeeded
Starting tracing...succeeded
Initializing 32 flushers...succeeded
Initializing SDS Server network connections...succeeded
Initializing log/checkpoint information...succeeded
Initializing dbspaces...succeeded
Opening primary chunks...oninit: Cannot open chunk '/home/informix/dbs/datadbs1-1'. errno = 2
succeeded
Validating chunks...succeeded
Initialize Async Log Flusher...succeeded
Starting B-tree Scanner...succeeded
Init ReadAhead Daemon...succeeded
Init DB Util Daemon...succeeded
Initializing DBSPACETEMP list...succeeded
Init Auto Tuning Daemon...succeeded
Checking database partition index...succeeded
Initializing dataskip structure...succeeded
Checking for temporary tables to drop...succeeded
Updating Global Row Counter...succeeded
Forking onmode_mon thread...succeeded
Creating periodic thread...succeeded
Creating VP cache drain thread...succeeded
Creating limits manager thread...succeeded
Starting scheduling system...succeeded
Verbose output complete: mode = 5
[informix@vm84145 ~]$ 

在数据库启动时报错,信息:Cannot open chunk '/home/informix/dbs/datadbs1-1'. errno = 2。
因为这个文件被删除,所以SinoDB找不到这个文件了。

步骤16:备份逻辑日志。

当出现灾难时,我们需要保护好数据库的逻辑日志。
我们先尝试进行一次逻辑日志的备份。

ontape -a

执行逻辑日志备份时,发现数据库处于Blocked状态,无法备份逻辑日志

[informix@vm84145 data]$ onstat -

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- Fast Recovery (CKPT REQ) -- Up 00:05:34 -- 2374324 Kbytes
Blocked:CKPT

步骤17:恢复数据库到L0

当数据库空间的文件丢失或损坏时,在进行恢复前,需要手工创建一个空文件,并设置相应权限(660)。
为丢失的数据库空间文件,创建一个同名的空文件,并设置好相应的权限。
语法

touch /home/informix/dbs/datadbs1-1
chmod 660 /home/informix/dbs/datadbs1-1

操作演示
文件准备

[informix@vm84145 dbs]$ touch /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ chmod 660 /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ ll
total 17920000
-rw-rw---- 1 informix informix 1048576000 Feb 14 23:49 bindbs1
-rw-rw---- 1 informix informix          0 Feb 24 22:24 datadbs1-1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs2-1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs3-1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs4-1
-rw-rw---- 1 informix informix 2097152000 Feb 18 19:53 datadbs5-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:12 llogdbs
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:12 plogdbs
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:12 rootdbs
-rw-rw---- 1 informix informix 1048576000 Feb 18 19:53 sbdbs1
-rw-rw---- 1 informix informix  524288000 Feb 24 22:11 tempdbs1
-rw-rw---- 1 informix informix  524288000 Feb 24 21:13 tempdbs2
-rw-rw---- 1 informix informix  524288000 Feb 24 22:11 tempdbs3
[informix@vm84145 dbs]$ 

恢复数据到L0备份。

[informix@vm84145 dbs]$ onmode -ky
[informix@vm84145 backup]$ ontape -r
Restore will use level 0 archive file /home/informix/backup/vm84145_0_L0. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: Sinoregal SinoDB Dynamic Server Version 12.10.FC8 
Archive date:   Wed Feb 23 23:14:22 2022 
User id:        informix 
Terminal id:    /dev/pts/2 
Archive level:  0 
Tape device:    /home/informix/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 

Spaces to restore:1 [rootdbs                                                                                                                         ] 
2 [bindbs1                                                                                                                         ] 
3 [llogdbs                                                                                                                         ] 
4 [plogdbs                                                                                                                         ] 
5 [datadbs1                                                                                                                        ] 
6 [datadbs2                                                                                                                        ] 
7 [datadbs3                                                                                                                        ] 
8 [datadbs4                                                                                                                        ] 
9 [datadbs5                                                                                                                        ] 
10 [sbdbs1                                                                                                                          ] 

Archive Information

Sinoregal SinoDB Dynamic Server Copyright 2001, 2017  Sinoregal Corporation
Initialization Time       02/14/2022 23:09:43
System Page Size          2048
Version                   29
Index Page Logging        OFF
Archive CheckPoint Time   02/23/2022 23:14:22


Dbspaces

number   flags    fchunk   nchunks  flags    owner                            name
1        30001    1        1        N   A    informix                         rootdbs                                                                                                                         
2        20001    2        1        N   A    informix                         llogdbs                                                                                                                         
3        30001    3        1        N   A    informix                         plogdbs                                                                                                                         
4        2001     4        1        N T A    informix                         tempdbs1                                                                                                                        
5        2001     5        1        N T A    informix                         tempdbs2                                                                                                                        
6        2001     6        1        N T A    informix                         tempdbs3                                                                                                                        
7        20011    7        1        N B A    informix                         bindbs1                                                                                                                         
8        28001    8        1        N S A    informix                         sbdbs1                                                                                                                          
9        20001    9        1        N   A    informix                         datadbs1                                                                                                                        
10       20001    10       1        N   A    informix                         datadbs2                                                                                                                        
11       20001    11       1        N   A    informix                         datadbs3                                                                                                                        
12       20001    12       1        N   A    informix                         datadbs4                                                                                                                        
13       20001    13       1        N   A    informix                         datadbs5                                                                                                                        

Chunks

chk/dbs offset   size     free     bpages   flags pathname
1   1   0        1024000  1010409           PO--- /home/informix/dbs/rootdbs
2   2   0        1024000  47                PO--- /home/informix/dbs/llogdbs
3   3   0        1024000  2                 PO--- /home/informix/dbs/plogdbs
4   4   0        256000   255564            PO--- /home/informix/dbs/tempdbs1
5   5   0        256000   255788            PO--- /home/informix/dbs/tempdbs2
6   6   0        256000   255788            PO--- /home/informix/dbs/tempdbs3
7   7   0        512000            128000   POB-- /home/informix/dbs/bindbs1
8   8   0        512000   25659             POS-- /home/informix/dbs/sbdbs1
9   9   0        1024000  1019161           PO--- /home/informix/dbs/datadbs1-1
10  10  0        1024000  1023947           PO--- /home/informix/dbs/datadbs2-1
11  11  0        1024000  1023947           PO--- /home/informix/dbs/datadbs3-1
12  12  0        1024000  1023947           PO--- /home/informix/dbs/datadbs4-1
13  13  0        1024000  1023947           PO--- /home/informix/dbs/datadbs5-1

Continue restore? (y/n)y
Do you want to back up the logs? (y/n)y
File created: /home/informix/backup/vm84145_0_Log0000000007
File created: /home/informix/backup/vm84145_0_Log0000000008
Log salvage is complete, continuing restore of archive.

Restore a level 1 archive (y/n) Restore a level 1 archive (y/n) n
Do you want to restore log tapes? (y/n)n
/home/informix/sinodb/bin/onmode -sy

Program over.
[informix@vm84145 backup]$ onstat -

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- Quiescent -- Up 00:01:53 -- 2374324 Kbytes

[informix@vm84145 backup]$ 

检查恢复结果

[informix@vm84145 backup]$ onmode -m
[informix@vm84145 backup]$ onstat -

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- On-Line -- Up 00:02:32 -- 2374324 Kbytes

[informix@vm84145 backup]$ dbaccess - -
> database tapedb;

Database selected.

> select * from t_dept;     


   f_deptid f_deptname           

          1 dept_1              
          2 dept_2              
          3 dept_3              

3 row(s) retrieved.

>select * from t_employee;


f_employeeid    f_deptid f_employeename       

           1           1 employee_01         
           2           1 employee_02         
           3           2 employee_03         
           4           2 employee_04         
           5           3 employee_05         

5 row(s) retrieved.

> 

至此,数据已经恢复到L0备份时的状态。

步骤18:恢复数据库到L1

文件准备

[informix@vm84145 dbs]$ rm -rf /home/informix/dbs/datadbs1-1 
[informix@vm84145 dbs]$ ll
total 17920000
-rw-rw---- 1 informix informix 1048576000 Feb 24 22:31 bindbs1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:31 datadbs2-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:31 datadbs3-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:31 datadbs4-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:31 datadbs5-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:41 llogdbs
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:36 plogdbs
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:41 rootdbs
-rw-rw---- 1 informix informix 1048576000 Feb 24 22:31 sbdbs1
-rw-rw---- 1 informix informix  524288000 Feb 24 22:36 tempdbs1
-rw-rw---- 1 informix informix  524288000 Feb 24 22:36 tempdbs2
-rw-rw---- 1 informix informix  524288000 Feb 24 22:36 tempdbs3
[informix@vm84145 dbs]$ touch /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ chmod 660 /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ ll
total 17920000
-rw-rw---- 1 informix informix 1048576000 Feb 24 22:31 bindbs1
-rw-rw---- 1 informix informix          0 Feb 24 22:43 datadbs1-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:31 datadbs2-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:31 datadbs3-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:31 datadbs4-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:31 datadbs5-1
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:41 llogdbs
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:36 plogdbs
-rw-rw---- 1 informix informix 2097152000 Feb 24 22:41 rootdbs
-rw-rw---- 1 informix informix 1048576000 Feb 24 22:31 sbdbs1
-rw-rw---- 1 informix informix  524288000 Feb 24 22:36 tempdbs1
-rw-rw---- 1 informix informix  524288000 Feb 24 22:36 tempdbs2
-rw-rw---- 1 informix informix  524288000 Feb 24 22:36 tempdbs3
[informix@vm84145 dbs]$ 

恢复数据到L1备份

[informix@vm84145 dbs]$ onmode -ky
[informix@vm84145 dbs]$ ontape -r
Restore will use level 0 archive file /home/informix/backup/vm84145_0_L0. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: Sinoregal SinoDB Dynamic Server Version 12.10.FC8 
Archive date:   Wed Feb 23 23:14:22 2022 
User id:        informix 
Terminal id:    /dev/pts/2 
Archive level:  0 
Tape device:    /home/informix/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 

Spaces to restore:1 [rootdbs                                                                                                                         ] 
2 [bindbs1                                                                                                                         ] 
3 [llogdbs                                                                                                                         ] 
4 [plogdbs                                                                                                                         ] 
5 [datadbs1                                                                                                                        ] 
6 [datadbs2                                                                                                                        ] 
7 [datadbs3                                                                                                                        ] 
8 [datadbs4                                                                                                                        ] 
9 [datadbs5                                                                                                                        ] 
10 [sbdbs1                                                                                                                          ] 

Archive Information

Sinoregal SinoDB Dynamic Server Copyright 2001, 2017  Sinoregal Corporation
Initialization Time       02/14/2022 23:09:43
System Page Size          2048
Version                   29
Index Page Logging        OFF
Archive CheckPoint Time   02/23/2022 23:14:22


Dbspaces

number   flags    fchunk   nchunks  flags    owner                            name
1        30001    1        1        N   A    informix                         rootdbs                                                                                                                         
2        20001    2        1        N   A    informix                         llogdbs                                                                                                                         
3        30001    3        1        N   A    informix                         plogdbs                                                                                                                         
4        2001     4        1        N T A    informix                         tempdbs1                                                                                                                        
5        2001     5        1        N T A    informix                         tempdbs2                                                                                                                        
6        2001     6        1        N T A    informix                         tempdbs3                                                                                                                        
7        20011    7        1        N B A    informix                         bindbs1                                                                                                                         
8        28001    8        1        N S A    informix                         sbdbs1                                                                                                                          
9        20001    9        1        N   A    informix                         datadbs1                                                                                                                        
10       20001    10       1        N   A    informix                         datadbs2                                                                                                                        
11       20001    11       1        N   A    informix                         datadbs3                                                                                                                        
12       20001    12       1        N   A    informix                         datadbs4                                                                                                                        
13       20001    13       1        N   A    informix                         datadbs5                                                                                                                        


Chunks  

chk/dbs offset   size     free     bpages   flags pathname
1   1   0        1024000  1010409           PO--- /home/informix/dbs/rootdbs
2   2   0        1024000  47                PO--- /home/informix/dbs/llogdbs
3   3   0        1024000  2                 PO--- /home/informix/dbs/plogdbs
4   4   0        256000   255564            PO--- /home/informix/dbs/tempdbs1
5   5   0        256000   255788            PO--- /home/informix/dbs/tempdbs2
6   6   0        256000   255788            PO--- /home/informix/dbs/tempdbs3
7   7   0        512000            128000   POB-- /home/informix/dbs/bindbs1
8   8   0        512000   25659             POS-- /home/informix/dbs/sbdbs1
9   9   0        1024000  1019161           PO--- /home/informix/dbs/datadbs1-1
10  10  0        1024000  1023947           PO--- /home/informix/dbs/datadbs2-1
11  11  0        1024000  1023947           PO--- /home/informix/dbs/datadbs3-1
12  12  0        1024000  1023947           PO--- /home/informix/dbs/datadbs4-1
13  13  0        1024000  1023947           PO--- /home/informix/dbs/datadbs5-1

Continue restore? (y/n)y
Do you want to back up the logs? (y/n)y
No log files to salvage. Logs 7 - 8 already exists in directory /home/informix/backup/
Log salvage is complete, continuing restore of archive.
Restore a level 1 archive (y/n) y
Ready for level 1 tape 
Restore will use level 1 archive file /home/informix/backup/vm84145_0_L1. Press Return to continue ...
Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: Sinoregal SinoDB Dynamic Server Version 12.10.FC8 
Archive date:   Wed Feb 23 23:25:03 2022 
User id:        informix 
Terminal id:    /dev/pts/2 
Archive level:  1 
Tape device:    /home/informix/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Restore a level 2 archive (y/n) n
Do you want to restore log tapes? (y/n)n
/home/informix/sinodb/bin/onmode -sy

Program over.
[informix@vm84145 dbs]$ 

检查恢复结果

[informix@vm84145 dbs]$ onstat -

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- Quiescent -- Up 00:03:03 -- 2374324 Kbytes

[informix@vm84145 dbs]$ onmode -m
[informix@vm84145 dbs]$ onstat -

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- On-Line -- Up 00:03:21 -- 2374324 Kbytes

[informix@vm84145 dbs]$ dbaccess tapedb -

Database selected.

> select * from t_dept;  


   f_deptid f_deptname           

          1 dept_1              
          2 dept_2              
          3 dept_3              

3 row(s) retrieved.

> select * from t_employee;


f_employeeid    f_deptid f_employeename       

           1           1 employee_01         
           2           1 employee_02         
           3           2 employee_03         
           4           2 employee_04         
           5           3 employee_05         
          11           1 employee_11         
          12           1 employee_12         
          13           2 employee_13         
          14           2 employee_14         
          15           3 employee_15         
          16           3 employee_16         

11 row(s) retrieved.

> 

至此,L1备份前的数据已经恢复完成。

步骤19:恢复数据库到L2

文件准备

[informix@vm84145 dbs]$ rm -rf /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ touch /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ chmod 660 /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ ll /home/informix/dbs/datadbs1-1
-rw-rw---- 1 informix informix 0 Feb 24 22:50 /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ 

恢复数据到L2备份

[informix@vm84145 dbs]$ onmode -ky
[informix@vm84145 dbs]$ ontape -r
Restore will use level 0 archive file /home/informix/backup/vm84145_0_L0. Press Return to continue ...

Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: Sinoregal SinoDB Dynamic Server Version 12.10.FC8 
Archive date:   Wed Feb 23 23:14:22 2022 
User id:        informix 
Terminal id:    /dev/pts/2 
Archive level:  0 
Tape device:    /home/informix/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 

Spaces to restore:1 [rootdbs                                                                                                                         ] 
2 [bindbs1                                                                                                                         ] 
3 [llogdbs                                                                                                                         ] 
4 [plogdbs                                                                                                                         ] 
5 [datadbs1                                                                                                                        ] 
6 [datadbs2                                                                                                                        ] 
7 [datadbs3                                                                                                                        ] 
8 [datadbs4                                                                                                                        ] 
9 [datadbs5                                                                                                                        ] 
10 [sbdbs1                                                                                                                          ] 


Archive Information

Sinoregal SinoDB Dynamic Server Copyright 2001, 2017  Sinoregal Corporation
Initialization Time       02/14/2022 23:09:43
System Page Size          2048
Version                   29
Index Page Logging        OFF
Archive CheckPoint Time   02/23/2022 23:14:22

Dbspaces

number   flags    fchunk   nchunks  flags    owner                            name
1        30001    1        1        N   A    informix                         rootdbs                                                                                                                         
2        20001    2        1        N   A    informix                         llogdbs                                                                                                                         
3        30001    3        1        N   A    informix                         plogdbs                                                                                                                         
4        2001     4        1        N T A    informix                         tempdbs1                                                                                                                        
5        2001     5        1        N T A    informix                         tempdbs2                                                                                                                        
6        2001     6        1        N T A    informix                         tempdbs3                                                                                                                        
7        20011    7        1        N B A    informix                         bindbs1                                                                                                                         
8        28001    8        1        N S A    informix                         sbdbs1                                                                                                                          
9        20001    9        1        N   A    informix                         datadbs1                                                                                                                        
10       20001    10       1        N   A    informix                         datadbs2                                                                                                                        
11       20001    11       1        N   A    informix                         datadbs3                                                                                                                        
12       20001    12       1        N   A    informix                         datadbs4                                                                                                                        
13       20001    13       1        N   A    informix                         datadbs5                                                                                                                        


Chunks

chk/dbs offset   size     free     bpages   flags pathname
1   1   0        1024000  1010409           PO--- /home/informix/dbs/rootdbs
2   2   0        1024000  47                PO--- /home/informix/dbs/llogdbs
3   3   0        1024000  2                 PO--- /home/informix/dbs/plogdbs
4   4   0        256000   255564            PO--- /home/informix/dbs/tempdbs1
5   5   0        256000   255788            PO--- /home/informix/dbs/tempdbs2
6   6   0        256000   255788            PO--- /home/informix/dbs/tempdbs3
7   7   0        512000            128000   POB-- /home/informix/dbs/bindbs1
8   8   0        512000   25659             POS-- /home/informix/dbs/sbdbs1
9   9   0        1024000  1019161           PO--- /home/informix/dbs/datadbs1-1
10  10  0        1024000  1023947           PO--- /home/informix/dbs/datadbs2-1
11  11  0        1024000  1023947           PO--- /home/informix/dbs/datadbs3-1
12  12  0        1024000  1023947           PO--- /home/informix/dbs/datadbs4-1
13  13  0        1024000  1023947           PO--- /home/informix/dbs/datadbs5-1

Continue restore? (y/n)y
Do you want to back up the logs? (y/n)y
No log files to salvage. Logs 7 - 7 already exists in directory /home/informix/backup/
Log salvage is complete, continuing restore of archive.
y

Restore a level 1 archive (y/n) Ready for level 1 tape 
Restore will use level 1 archive file /home/informix/backup/vm84145_0_L1. Press Return to continue ...

Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: Sinoregal SinoDB Dynamic Server Version 12.10.FC8 
Archive date:   Wed Feb 23 23:25:03 2022 
User id:        informix 
Terminal id:    /dev/pts/2 
Archive level:  1 
Tape device:    /home/informix/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Restore a level 2 archive (y/n) y
Ready for level 2 tape 
Restore will use level 2 archive file /home/informix/backup/vm84145_0_L2. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: Sinoregal SinoDB Dynamic Server Version 12.10.FC8 
Archive date:   Wed Feb 23 23:43:13 2022 
User id:        informix 
Terminal id:    /dev/pts/2 
Archive level:  2 
Tape device:    /home/informix/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Do you want to restore log tapes? (y/n)n
/home/informix/sinodb/bin/onmode -sy

Program over.
[informix@vm84145 dbs]$ 

检查恢复结果

[informix@vm84145 dbs]$ onmode -m
[informix@vm84145 dbs]$ dbaccess tapedb -

Database selected.

> select * from t_dept;


   f_deptid f_deptname           

          1 dept_1              
          2 dept_2              
          3 dept_3              

3 row(s) retrieved.

> select * from t_employee;


f_employeeid    f_deptid f_employeename       

           1           1 employee_01         
           2           1 employee_02         
           3           2 employee_03         
           4           2 employee_04         
           5           3 employee_05         
          11           1 employee_11         
          12           1 employee_12         
          13           2 employee_13         
          14           2 employee_14         
          15           3 employee_15         
          16           3 employee_16         
          21           1 employee_21         
          22           1 employee_22         
          23           2 employee_23         
          24           2 employee_24         
          25           3 employee_25         

16 row(s) retrieved.
> 

步骤20:完全恢复数据库

文件准备

[informix@vm84145 dbs]$ rm -rf /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ touch /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ chmod 660 /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ ll /home/informix/dbs/datadbs1-1
-rw-rw---- 1 informix informix 0 Feb 24 22:55 /home/informix/dbs/datadbs1-1
[informix@vm84145 dbs]$ 

完全恢复数据库

[informix@vm84145 dbs]$ onmode -ky
[informix@vm84145 dbs]$ ontape -r
Restore will use level 0 archive file /home/informix/backup/vm84145_0_L0. Press Return to continue ...

Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: Sinoregal SinoDB Dynamic Server Version 12.10.FC8 
Archive date:   Wed Feb 23 23:14:22 2022 
User id:        informix 
Terminal id:    /dev/pts/2 
Archive level:  0 
Tape device:    /home/informix/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 

Spaces to restore:1 [rootdbs                                                                                                                         ] 
2 [bindbs1                                                                                                                         ] 
3 [llogdbs                                                                                                                         ] 
4 [plogdbs                                                                                                                         ] 
5 [datadbs1                                                                                                                        ] 
6 [datadbs2                                                                                                                        ] 
7 [datadbs3                                                                                                                        ] 
8 [datadbs4                                                                                                                        ] 
9 [datadbs5                                                                                                                        ] 
10 [sbdbs1                                                                                                                          ] 

Archive Information

Sinoregal SinoDB Dynamic Server Copyright 2001, 2017  Sinoregal Corporation
Initialization Time       02/14/2022 23:09:43
System Page Size          2048
Version                   29
Index Page Logging        OFF
Archive CheckPoint Time   02/23/2022 23:14:22


Dbspaces

number   flags    fchunk   nchunks  flags    owner                            name
1        30001    1        1        N   A    informix                         rootdbs                                                                                                                         
2        20001    2        1        N   A    informix                         llogdbs                                                                                                                         
3        30001    3        1        N   A    informix                         plogdbs                                                                                                                         
4        2001     4        1        N T A    informix                         tempdbs1                                                                                                                        
5        2001     5        1        N T A    informix                         tempdbs2                                                                                                                        
6        2001     6        1        N T A    informix                         tempdbs3                                                                                                                        
7        20011    7        1        N B A    informix                         bindbs1                                                                                                                         
8        28001    8        1        N S A    informix                         sbdbs1                                                                                                                          
9        20001    9        1        N   A    informix                         datadbs1                                                                                                                        
10       20001    10       1        N   A    informix                         datadbs2                                                                                                                        
11       20001    11       1        N   A    informix                         datadbs3                                                                                                                        
12       20001    12       1        N   A    informix                         datadbs4                                                                                                                        
13       20001    13       1        N   A    informix                         datadbs5                                                                                                                        

Chunks

chk/dbs offset   size     free     bpages   flags pathname
1   1   0        1024000  1010409           PO--- /home/informix/dbs/rootdbs
2   2   0        1024000  47                PO--- /home/informix/dbs/llogdbs
3   3   0        1024000  2                 PO--- /home/informix/dbs/plogdbs
4   4   0        256000   255564            PO--- /home/informix/dbs/tempdbs1
5   5   0        256000   255788            PO--- /home/informix/dbs/tempdbs2
6   6   0        256000   255788            PO--- /home/informix/dbs/tempdbs3
7   7   0        512000            128000   POB-- /home/informix/dbs/bindbs1
8   8   0        512000   25659             POS-- /home/informix/dbs/sbdbs1
9   9   0        1024000  1019161           PO--- /home/informix/dbs/datadbs1-1
10  10  0        1024000  1023947           PO--- /home/informix/dbs/datadbs2-1
11  11  0        1024000  1023947           PO--- /home/informix/dbs/datadbs3-1
12  12  0        1024000  1023947           PO--- /home/informix/dbs/datadbs4-1
13  13  0        1024000  1023947           PO--- /home/informix/dbs/datadbs5-1

Continue restore? (y/n)y
Do you want to back up the logs? (y/n)y
No log files to salvage. Logs 7 - 7 already exists in directory /home/informix/backup/
Log salvage is complete, continuing restore of archive.

Restore a level 1 archive (y/n) Restore a level 1 archive (y/n) y
Ready for level 1 tape 
Restore will use level 1 archive file /home/informix/backup/vm84145_0_L1. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: Sinoregal SinoDB Dynamic Server Version 12.10.FC8 
Archive date:   Wed Feb 23 23:25:03 2022 
User id:        informix 
Terminal id:    /dev/pts/2 
Archive level:  1 
Tape device:    /home/informix/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Restore a level 2 archive (y/n) y
Ready for level 2 tape 
Restore will use level 2 archive file /home/informix/backup/vm84145_0_L2. Press Return to continue ...


Archive Tape Information

Tape type:      Archive Backup Tape 
Online version: Sinoregal SinoDB Dynamic Server Version 12.10.FC8 
Archive date:   Wed Feb 23 23:43:13 2022 
User id:        informix 
Terminal id:    /dev/pts/2 
Archive level:  2 
Tape device:    /home/informix/backup/ 
Tape blocksize (in k): 32 
Tape size (in k): system defined for directory 
Tape number in series: 1 
Do you want to restore log tapes? (y/n)y

Roll forward should start with log number 7
Restore will use log backup file /home/informix/backup/vm84145_0_Log0000000007. Press Return to continue ...

Rollforward log file /home/informix/backup/vm84145_0_Log0000000007 ...
Rollforward log file /home/informix/backup/vm84145_0_Log0000000008 ...

Program over.
[informix@vm84145 dbs]$ 

检查恢复结果

[informix@vm84145 dbs]$ onstat -

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- Quiescent -- Up 00:01:26 -- 2374324 Kbytes

[informix@vm84145 dbs]$ onmode -m
[informix@vm84145 dbs]$ onstat -

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- On-Line -- Up 00:01:35 -- 2374324 Kbytes

[informix@vm84145 dbs]$ dbaccess tapedb -

Database selected.

> select * from t_dept;


   f_deptid f_deptname           

          1 dept_1              
          2 dept_2              
          3 dept_3              
          4 dept_4              
          5 dept_5              

5 row(s) retrieved.

> select * from t_employee;


f_employeeid    f_deptid f_employeename       

           1           1 employee_01         
           2           1 employee_02         
           3           2 employee_03         
           4           2 employee_04         
           5           3 employee_05         
          11           1 employee_updated    
          12           1 employee_12         
          13           2 employee_13         
          15           3 employee_15         
          16           3 employee_16         
          21           1 employee_21         
          22           1 employee_22         
          23           2 employee_23         
          24           2 employee_24         
          25           3 employee_25         

15 row(s) retrieved.

> 

这次的恢复结果是正确的,在L2备份后INSERT、UPDATE和DELETE的数据都生效了。

附录

数据库与表

create database tapedb in datadbs1 with log;
create table t_dept(f_deptid int, f_deptname varchar(20));
create table t_employee(f_employeeid int, f_deptid int, f_employeename varchar(20));

数据(t2)

insert into t_dept values(1, 'dept_1');
insert into t_dept values(2, 'dept_2');
insert into t_dept values(3, 'dept_3');

数据(t3)

insert into t_employee values(1, 1, 'employee_01');
insert into t_employee values(2, 1, 'employee_02');
insert into t_employee values(3, 2, 'employee_03');
insert into t_employee values(4, 2, 'employee_04');
insert into t_employee values(5, 3, 'employee_05');

数据(t5)

insert into t_employee values(11, 1, 'employee_11');
insert into t_employee values(12, 1, 'employee_12');
insert into t_employee values(13, 2, 'employee_13');
insert into t_employee values(14, 2, 'employee_14');
insert into t_employee values(15, 3, 'employee_15');

数据(t7)

insert into t_employee values(16, 3, 'employee_16');

数据(t9)

insert into t_employee values(21, 1, 'employee_21');
insert into t_employee values(22, 1, 'employee_22');
insert into t_employee values(23, 2, 'employee_23');
insert into t_employee values(24, 2, 'employee_24');
insert into t_employee values(25, 3, 'employee_25');

数据(t11)

insert into t_dept values(4, 'dept_4');

数据(t12)

update t_employee set f_employeename = 'employee_updated' where f_employeeid = 11;

数据(t14)

delete from t_employee where f_employeeid = 14;

数据(t15)

drop table t_employee;

数据(t16)

insert into t_dept values(5, 'dept_5');