先在 dsa 中创建一个表,并插入一些数据以做为后面恢复的验证:
[tt1@west-mountain ~]$ ttisql dsa
Copyright (c) 1996-2007, Oracle. All rights reserved.
Type ? or “help” for help, type “exit” to quit ttIsql.
All commands must end with a semicolon character.
connect “DSN=dsa”;
Connection successful: DSN=dsa;UID=tt1;……TimesTen/tt70/lib/libtten.so;PermSize=50;TempSize=10;TypeMode=0;
(Default setting AutoCommit=1)
Command> create table ftable(id int not null primary key, name char(10));
Command> insert into ftable values(1,’hello’);
1 row inserted.
Command> insert into ftable values(2,’world’);
1 row inserted.
Command> commit;
Command> select * from ftable;
< 1, hello >
< 2, world >
2 rows found.
Command>
然后另开一个控制台,通过ttstatus可以家查dsa的状态:
[tt1@west-mountain ~]$ ttstatus
TimesTen status report as of Sun Jul 1 21:58:29 2007
Daemon pid 4411 port 17000 instance tt70
TimesTen server pid 4424 started on port 17002
TimesTen webserver pid 4422 started on port 17004
————————————————————
Data store /home/tt1/TimesTen/tt70/info/dsa
There are no connections to the data store
Replication policy : Manual
Cache agent policy : Manual
————————————————————
Access control enabled.
End of report
[tt1@west-mountain ~]$ pwd
/home/tt1
[tt1@west-mountain ~]$ ls
Desktop install TimesTen
[tt1@west-mountain ~]$ mkdir backup
[tt1@west-mountain ~]$ cd backup
通过命令ttbackup 命令备份数据库, dir指向放置备份文件的路进,fname指定所要生成的备份文件的命名,dsn指向要备份的datastore:
[tt1@west-mountain backup]$ ttbackup -dir /home/tt1/backup -fname dsa-0701 dsn=dsa
Backup started …
Backup complete
[tt1@west-mountain backup]$ ls -al
total 11916
drwxr-xr-x 2 tt1 tta 4096 Jul 1 21:54 .
drwx—— 17 tt1 users 4096 Jul 1 21:54 ..
-rw——- 1 tt1 tta 11542528 Jul 1 21:54 dsa-0701.0.bac
-rw——- 1 tt1 tta 606208 Jul 1 21:54 dsa-0701.0.bac0
-rw——- 1 tt1 tta 676 Jul 1 21:54 dsa-0701.sta
[tt1@west-mountain backup]$
现在我们通过ttdestroy 命令 删除掉现在的dsa datastore, 首先退出已有的 ttisql 连接:
Command> exit
Disconnecting…
Done.
现在删除它:
[tt1@west-mountain ~]$ ttdestroy dsa
通过ttstatus验证确实该datastore已经不存在了,可对比前面的ttstatus的输出结果进行对比:
[tt1@west-mountain ~]$ ttstatus
TimesTen status report as of Sun Jul 1 21:58:16 2007
Daemon pid 4411 port 17000 instance tt70
TimesTen server pid 4424 started on port 17002
TimesTen webserver pid 4422 started on port 17004
————————————————————————
Access control enabled.
End of report
现在恢复它,dir指向备份文件放置的目录,noconn为恢复好后,不要自动登录该datastore:
[tt1@west-mountain ~]$ ttrestore -dir /home/tt1/backup -noconn -fname dsa-0701 dsn=dsa
Restore started …
Restore complete
现在登录上去,验证原有的数据是否存在:
[tt1@west-mountain ~]$ ttisql dsa
Copyright (c) 1996-2007, Oracle. All rights reserved.
Type ? or “help” for help, type “exit” to quit ttIsql.
All commands must end with a semicolon character.
connect “DSN=dsa”;
Connection successful: DSN=dsa;UID=tt1;……PermSize=50;TempSize=10;TypeMode=0;
(Default setting AutoCommit=1)
Command> desc ftable;
Table TT1.FTABLE:
Columns:
*ID NUMBER (38) NOT NULL
NAME CHAR (10)
1 table found.
(primary key columns are indicated with *)
Command> select * from ftable;
< 1, hello >
< 2, world >
2 rows found.
Command>
所有的数据确实已经恢复过来。