如何利用pg_dumpall备份的文件,恢复数据库

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何利用pg_dumpall备份的文件,恢复数据库相关的知识,希望对你有一定的参考价值。

如题。
如何利用pg_dumpall备份的文件,恢复数据库。
用pg_dumpall备份了数据库,但是恢复的时候没成功

一、把SQL2005数据库备份恢复到SQL2005数据库中二、在SQL2005数据库中生成脚本 1、选定数据库-->右键-->任务-->生成脚本 2、下一步-->选择数据库 3、下一步-->找到“为服务器版本编写脚本”-->选择“SQL Server 2000数据库” 4、选择“表”,逐步执行下一步三、执行脚本,在SQL2000数据库中生成数据库结构 1、将脚本文件传输到SQL2000数据库电脑 2、运行SQL 2000的查询分析器 3、将脚本内容复制到查询分析器中,执行脚本内容,生成数据库结构 四、导入数据 1、在SQL 2000数据库中,创建数据库 2、选定数据库-->右键-->所有任务-->导入数据 3、选择数据源-->选择服务器-->选择数据库 4、选择目的 5、逐步执行下一步 参考技术A

我安装的是pg 10,自带pgAdmin4:

这是备份文件:

恢复步骤:

第一步:在pgAdmin4中手动新建名字与备份文件名字一致的数据库

第二步:右键刚刚建的数据库,点击恢复(Restore)

第三步:选择备份文件

第四步:选择Role name,点击恢复即可

楼主可以试试,有什么问题再问我,若觉得有帮助的话,望采纳,谢谢!

ORACLE 11G 利用泠备份恢复standby库

利用泠备份恢复standby数据库

 

1 開始在备库上进行泠备份

先查好控制文件、redo、undo文件、数据文件的路径

 

1.1 先关闭主库的归档日志传输

SQL> ALTER system SETlog_archive_dest_state_2 =‘DEFER‘;                                                                                                                                     

                                                                                                                                                                                              

System altered.

 

SQL> 

 

 

1.2 先关闭standby

SQL> shutdown immediate;                                                                                                                                                                      

Database closed.                                                                                                                                                                              

Database dismounted.                                                                                                                                                                          

ORACLE instance shut down.                                                                                                                                                                    

SQL>                                                                                                                                                                                          

SQL>    

 


<版权全部,文章同意转载,但必须以链接方式注明源地址,否则追究法律责任!> 
原博客地址:   http://blog.csdn.net/mchdba/article/details/46622839
原作者:黄杉 (mchdba)



1.3 開始进行泠备份

#建立一个泠备份文件夹

mkdir /data/oracle_cold/

開始泠备份控制文件

cp /data/oracle_cold/

cp /home/oradata/orcl/control01.ctlcontrol01.ctl

cp /oracle/app/oracle/flash_recovery_area/orcl/control02.ctlcontrol02.ctl

開始泠备份redo、undo文件

mkdir orcl_2

cp -r /home/oradata/orcl/*.log orcl_2

開始泠备份数据文件

cp -r /home/oradata/orcl/*.dbf orcl_2

 

 

 

2開始使用泠备份进行db恢复

2.1,停止掉standby

SQL> shutdown immediate;                                                                                                                                                                      

Database closed.                                                                                                                                                                              

Database dismounted.                                                                                                                                                                          

ORACLE instance shut down.                                                                                                                                                                    

SQL>                                                                                                                                                                                          

SQL>    

 

 

2.2。将泠备中的控制文件覆盖当前的控制文件

查看原来的控制文件文件夹

[[email protected] oracle_cold]$ morecontrolfile.log

SQL> SELECT name FROMv$controlfile;                                                                                                                                                          

 

NAME

--------------------------------------------------------------------------------

/home/oradata/orcl/control01.ctl

/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl

 

SQL> 

開始复制覆盖

[[email protected] oracle_cold]$ cpcontrol02.ctl /oracle/app/oracle/flash_recovery_area/orcl/control02.ctl

[[email protected] oracle_cold]$ cpcontrol01.ctl /home/oradata/orcl/control01.ctl

[[email protected] oracle_cold]$

 

2.3,将泠备中的redoundo文件覆盖到曾经的文件夹中

查看曾经的redo、undo文件路径

[[email protected] oracle_cold]$ morelogfile.log

SQL> select member from v$logfile;                                                                                                                                                            

 

MEMBER

--------------------------------------------------------------------------------

/home/oradata/orcl/redo03.log

/home/oradata/orcl/redo02.log

/home/oradata/orcl/redo01.log

/home/oradata/orcl/redo_dg_01.log

/home/oradata/orcl/redo_dg_02.log

/home/oradata/orcl/redo_dg_03.log

 

6 rows selected.

 

SQL> 

 

開始覆盖redo、undo文件

[[email protected] oracle_cold]$ cp orcl_2/*.log/home/oradata/orcl/

[[email protected] oracle_cold]$

 

2.4,将泠备中的数据文件覆盖到曾经的文件夹中

查看曾经的数据文件文件夹

[[email protected] oracle_cold]$ moredatafile.log

SELECT name FROM v$datafile;

1       /home/oradata/orcl/system01.dbf

2       /home/oradata/orcl/sysaux01.dbf

3       /home/oradata/orcl/undotbs01.dbf

4       /home/oradata/orcl/users01.dbf

5       /home/oradata/orcl/orclk01.dbf

6       /home/oradata/orcl/plas01.dbf

7       /home/oradata/orcl/pl01.dbf

8       /home/oradata/orcl/help01.dbf

9       /home/oradata/orcl/adobelc01.dbf

10     /home/oradata/orcl/sms01.dbf

11     /home/oradata/orcl/plcrm01.dbf

 

[[email protected] oracle_cold]$

 

開始覆盖曾经的数据文件文件夹

[[email protected] oracle_cold]$ cp orcl_2/*.dbf/home/oradata/orcl/

[[email protected] oracle_cold]$

 

2.5 启动数据库

SQL> startup                                                                                                                                                                                  

ORACLE instance started.                                                                                                                                                                      

 

Total System Global Area 5344731136 bytes

Fixed Size              2213136 bytes

Variable Size              3355446000 bytes

Database Buffers    1946157056 bytes

Redo Buffers                40914944 bytes

Database mounted.                                                                                                                                                                              

Database opened.                                                                                                                                                                              

SQL>

 

 

2.6 去主库上开启归档日志传输

SQL> ALTER system SET log_archive_dest_state_2=‘enable‘;                                                                                                                                     

                                                                                                                                                                                              

System altered.

 

SQL> 

 

2.7 然后备库启动应用

select sequence#,applied fromv$archived_log order by sequence# asc;

 

SQL> alter database recovermanagedstandby database disconnect from session;                                                                                                                

                                                                                                                                                                                             

Database altered.

 

SQL>

SQL> select open_modefromv$database;                                                                                                                                                       

OPEN_MODE

--------------------

READ ONLY WITH APPLY

 

SQL>

 








以上是关于如何利用pg_dumpall备份的文件,恢复数据库的主要内容,如果未能解决你的问题,请参考以下文章

利用备份恢复数据库,但是没有控制文件文件如何解决

如何进行数据库备份和恢复 mysql

MSSQL · 最佳实践 · 利用文件组实现冷热数据隔离备份方案

pg_dumpall - 抽出一个 PostgreSQL 数据库集群到脚本文件中

PG运维篇--逻辑备份和物理备份实战

PostgreSQL逻辑备份恢复--pg_dump导出及psql导入案例