Postgres从WAL文件恢复,没有使用pg_basebackup的basebackup

时间:2016-01-07 17:51:11

标签: postgresql postgresql-9.3 database-replication wal

我有以下情况。

  • 拥有主/副本设置。
  • 不知何故,数据库被删除,django创建了一个同名的新数据库。在这种情况下,以前数据库的WAL文件是否仍然存在?
  • 我没有使用像pg_basebackup这样的工具使用以前的数据库创建备份,但是在pg_xlog中确实有一些WAL文件。

现在,我正在尝试执行以下操作:   - 关闭postgres服务器。   - 使用PGDATA(/var/lib/postgresql/9.3/main)目录中的recovery.conf文件并在其中输入以下内容:

    restore_command = 'cp /var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/%f %p'
    recovery_target_time = '2016-01-07 03:00:00'

- 再次启动postgres服务器。

我在日志文件中看到的是:

postgres:~/9.3/main/pg_log$ tail -100f postgresql-2016-01-07_170256.log
2016-01-07 17:02:56 UTC LOG:  database system was shut down at 2016-01-07 17:02:55 UTC
2016-01-07 17:02:56 UTC LOG:  starting point-in-time recovery to 2016-01-06 00:00:00+00
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A.history’: No such file or directory
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A00000000000000CC’: No such file or directory
2016-01-07 17:02:56 UTC LOG:  consistent recovery state reached at 0/CC000090
2016-01-07 17:02:56 UTC LOG:  record with zero length at 0/CC000090
2016-01-07 17:02:56 UTC LOG:  redo is not required
2016-01-07 17:02:56 UTC LOG:  database system is ready to accept read only connections
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A00000000000000CC’: No such file or directory
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000B.history’: No such file or directory
2016-01-07 17:02:56 UTC LOG:  selected new timeline ID: 11
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A.history’: No such file or directory
2016-01-07 17:02:57 UTC LOG:  archive recovery complete
2016-01-07 17:02:57 UTC LOG:  autovacuum launcher started
2016-01-07 17:02:57 UTC LOG:  database system is ready to accept connections
2016-01-07 17:02:57 UTC LOG:  incomplete startup packet

我的pg_xlog_backup_jan072016文件夹包含foll内容。:

:~/9.3/main/pg_xlog_backup_jan072016$ ls -larth 
total 161M
-rw-------  1 postgres postgres  257 Jan  7 15:57 00000007.history
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000CA
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C9
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C8
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C7
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C6
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C5
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C4
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C3
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C2
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C1
-rw-------  1 postgres postgres  298 Jan  7 15:57 00000007000000000000005D.00000028.backup
-rw-------  1 postgres postgres  214 Jan  7 15:57 00000006.history
-rw-------  1 postgres postgres  171 Jan  7 15:57 00000005.history
drwx------  3 postgres postgres 4.0K Jan  7 16:54 .
drwx------ 18 postgres postgres 4.0K Jan  7 17:02 ..
drwx------  2 postgres postgres 4.0K Jan  7 17:08 archive_status

我想弄清楚的是:

  • 是否可以从没有pg_basebackup命令备份的WAL恢复?我只是想在现有的postgres安装中从WAL恢复。
  • 为什么日志说它找不到0000000A.history和0000000A00000000000000CC文件?该文件夹不包含任何此类文件。

任何人都可以帮助我们吗? 谢谢。 Sarthak

0 个答案:

没有答案