标签云
asm恢复 bbed bootstrap$ dul kcbzib_kcrsds_1 kccpb_sanity_check_2 kcratr_nab_less_than_odr kgegpa MySQL恢复 ORA-00312 ORA-00704 ORA-00742 ORA-01110 ORA-01200 ORA-01555 ORA-01578 ORA-01595 ORA-600 2662 ORA-600 3020 ORA-600 4000 ORA-600 4137 ORA-600 4193 ORA-600 4194 ORA-600 16703 ORA-600 kcbzib_kcrsds_1 ORA-600 KCLCHKBLK_4 ORA-600 kdsgrp1 ORA-15042 ORA-15196 ORACLE 12C oracle dul ORACLE PATCH Oracle Recovery Tools oracle加密恢复 oracle勒索 oracle勒索恢复 oracle异常恢复 Oracle 恢复 ORACLE恢复 ORACLE数据库恢复 oracle 比特币 OSD-04016 YOUR FILES ARE ENCRYPTED 勒索恢复 比特币加密文章分类
- Others (2)
- 中间件 (2)
- WebLogic (2)
- 操作系统 (109)
- 数据库 (1,819)
- DB2 (22)
- MySQL (80)
- Oracle (1,650)
- Data Guard (53)
- EXADATA (8)
- GoldenGate (24)
- ORA-xxxxx (168)
- ORACLE 12C (72)
- ORACLE 18C (6)
- ORACLE 19C (15)
- ORACLE 21C (3)
- Oracle 23ai (8)
- Oracle ASM (69)
- Oracle Bug (8)
- Oracle RAC (54)
- Oracle 安全 (6)
- Oracle 开发 (28)
- Oracle 监听 (29)
- Oracle备份恢复 (619)
- Oracle安装升级 (102)
- Oracle性能优化 (62)
- 专题索引 (5)
- 勒索恢复 (86)
- PostgreSQL (35)
- pdu工具 (7)
- PostgreSQL恢复 (12)
- SQL Server (34)
- SQL Server恢复 (14)
- TimesTen (7)
- 达梦数据库 (3)
- 达梦恢复 (1)
- 生活娱乐 (2)
- 至理名言 (11)
- 虚拟化 (2)
- VMware (2)
- 软件开发 (45)
- Asp.Net (9)
- JavaScript (12)
- PHP (2)
- 小工具 (28)
-
最近发表
- 在生产环境错误执行dd命令破坏asm磁盘故障恢复
- obet实现对数据文件坏块检测功能
- oracle linux 8.10注意pmlogger导致空间被大量占用
- obet快速修改scn/resetlogs恢复数据库(缺少归档,ORA-00308)
- 使用DBMS_PDB.RECOVER抢救单个pdb
- aix环境写入大文件设置combehin提高效率
- 数据库启动报 maximum number of processes () exceeded分析
- ORA-600 [ksunfy : too few sessions]
- 由于数据块scn大于数据库scn导致ORA-600 kcbzib_kcrsds_1错误
- ORA-600 ktbair2: illegal inheritance恢复
- 一键恢复ORA-00704 ORA-00702故障—202512
- PostgreSQL查询一个表相关的所有oid
- PostgreSQL oid文件替换实现数据访问
- 模拟sql server故障备份完成恢复实现数据0丢失
- sql server 事务日志备份异常恢复案例
- win平台挂起Oracle数据库启动进程
- linux异常磁盘lvm恢复操作演示
- open数据库报ora-600 kdsgrp1故障处理
- expdp dmp 导出不完整导入ORA-39059 ORA-39246 故障抢救数据
- mysql drop database 恢复思路
标签归档:Postgres truncate恢复
Postgres数据库truncate表无有效备份恢复
创建一个Postgres表,并插入数据
postgres=# CREATE TABLE "PeisInterfaceLog"( postgres(# "PeisInterfaceLogId" text, postgres(# "PeisDepartmentId" text, postgres(# "PeisDepartmentName" text, postgres(# "PeisInterfaceSubjectType" text, postgres(# "PeisInterfaceSubjectId" text, postgres(# "PeisInterfaceNo" text, postgres(# "PeisInterfaceName" text, postgres(# "PeisInterfaceDirection" text, postgres(# "PeisInterfaceCallAddress" text, postgres(# "PeisInterfaceLogStartTime" timestamp, postgres(# "PeisInterfaceInputContent" json, postgres(# "PeisInterfaceInputTranscodeContent" json, postgres(# "PeisInterfaceOutContent" json, postgres(# "PeisInterfaceOutTranscodeContent" json, postgres(# "PeisInterfaceSuccessSign" int4, postgres(# "PeisInterfaceLogStatusCode" text, postgres(# "PeisInterfaceLogNote" text, postgres(# "PeisInterfaceLogTimestamp" timestamp, postgres(# "PeisInterfaceLogInfo" text, postgres(# "PeisPatientRegisterId" text postgres(# ); CREATE TABLE postgres=# \i /postgres/COPY/public_copy.sql SET COPY 722957 postgres=# select count(1) from "PeisInterfaceLog"; count -------- 722957 (1 row)
验证truncate操作,引起Postgres中oid的变化
postgres=# checkpoint;
CHECKPOINT
postgres=# show data_directory;
data_directory
----------------
/pgdata
(1 row)
postgres=# select oid, datname from pg_database ;
oid | datname
-------+-----------
13676 | postgres
1 | template1
13675 | template0
(3 rows)
postgres=# select relname, relowner, relfilenode from pg_class where relowner = 10 and relname like '%PeisInterfaceLog%';
relname | relowner | relfilenode
------------------+----------+-------------
PeisInterfaceLog | 10 | 16384
(1 row)
postgres=# truncate table "PeisInterfaceLog";
TRUNCATE TABLE
postgres=# select count(1) from "PeisInterfaceLog";
count
-------
0
(1 row)
postgres=# select relname, relowner, relfilenode from pg_class where relowner = 10 and relname like '%PeisInterfaceLog%';
relname | relowner | relfilenode
------------------+----------+-------------
PeisInterfaceLog | 10 | 16394
(1 row)
使用工具进行初始化字典信息
PDU.public=# b;
开始初始化...
-pg_database:</pgdata/global/1262>
数据库:postgres
-pg_schema:</pgdata/base/13676/2615>
-pg_class:</pgdata/base/13676/1259> 共88行
-pg_attribute:</pgdata/base/13676/1249> 共2950行
模式:
▌ public 1张表
PDU.public=# use postgres;
┌────────────────────────────────────────┐
│ 模式 │ 表数量 │
├────────────────────────────────────────┤
│ public │ 1 │
└────────────────────────────────────────┘
postgres.public=# set public;
┌──────────────────────────────────────────────────┐
│ 表名 │ 表大小 │
├──────────────────────────────────────────────────┤
│ PeisInterfaceLog │ 0 │
└──────────────────────────────────────────────────┘
仅显示表大小排名前 1 的表名
postgres.public=# \d PeisInterfaceLog;
┌──────────────────────────────────────────────────────────────┐
│ 列类型 │
└──────────────────────────────────────────────────────────────┘
text,text,text,text,text,text,text,text,text,timestamp,json,json,json,json,int4,text,text,timestamp,text,text
配置软件磁盘扫描操作(pdu.ini中配置)
#dropScan需要扫描的磁盘 DISK_PATH=/data/test.dd #dropScan时跳跃的数据块数量,数值越小覆盖磁盘越全面,速度越慢 BLOCK_INTERVAL=5
启用磁盘扫描操作
PDU.public=# p idxmode off;
┌─────────────────────────────────────────────────────────────────┐
│ 参数 │ 当前值 │
├─────────────────────────────────────────────────────────────────┤
│ startwal │ │
│ endwal │ │
│ startlsnt │ │
│ endlsnt │ │
│ starttime │ │
│ endtime │ │
│ resmode(Data Restore Mode) │ TIME │
│ exmode(Data Export Mode) │ CSV │
│ encoding │ UTF8 │
│ restype(Data Restore Type) │ DELETE │
----------------------DropScan----------------------
│ dsoff(DropScan startOffset) │ 0 │
│ blkiter(Block Intervals) │ 5 │
│ itmpcsv(Items Per Csv) │ 100 │
│ idxmode │ off │
└─────────────────────────────────────────────────────────────────┘
PDU.public=# ds;
▌全量扫描恢复模式
▌数据文件扫描
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
表名 │ 结果
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
PeisInterfaceLog 99.976 %(21469593600) 数据页: 71158 成功: 722947 (疑似乱码: 2809 ) 失败: 0
耗时 15.28 秒
└────────────────────────────────────────────────────────────────────────────────────────────────────┘
扫描完毕,文件目录如下:
restore/dropscan/PeisInterfaceLog
PDU.public=# ds copy;
已导出:
/restore/dropscan/PeisInterfaceLog/COPY.sql
PDU.public=#
[root@xifenfei PeisInterfaceLog]# more COPY.sql
[root@xifenfei PeisInterfaceLog]# cat /restore/dropscan/PeisInterfaceLog/COPY.sql
COPY PeisInterfaceLog FROM '/restore/dropscan/PeisInterfaceLog/09-28-21:29:55_226738176_32760blks_336787items.csv';
COPY PeisInterfaceLog FROM '/restore/dropscan/PeisInterfaceLog/09-28-21:30:01_595968000_32767blks_330416items.csv';
COPY PeisInterfaceLog FROM '/restore/dropscan/PeisInterfaceLog/09-28-21:30:04_1116061696_5631blks_55744items.csv';
把恢复数据导入到Postgres数据中
[root@xifenfei ~]# su - postgres [postgres@xifenfei ~]$ psql psql (12.8) Type "help" for help. postgres=# \i /restore/dropscan/PeisInterfaceLog/COPY.sql COPY 336787 COPY 330416 COPY 55744 postgres=# select count(1) from "PeisInterfaceLog"; count -------- 722947 (1 row)
经过上述扫描测试证明该工具实现了在Postgres中truncate数据的绝大部分数据恢复(这里的乱码不是由于没有扫描到数据,主要是由于个别字符串由于类型判断关系识别不对导致乱码抛弃).
如果你遇到Postgres 数据库由于drop/truncate等误操作,而且无有效备份进行恢复,面临数据丢失风险,请第一时间保护现场(数据文件所在分区尽可能不要有写入操作),联系我们提供专业恢复技术支持:
电话/微信:17813235971 Q Q:107644445
E-Mail:dba@xifenfei.com

加我微信(17813235971)
加我QQ(107644445)

