我有两个数据库服务器和一个由 pg_basebackup 配置的备份。您可以在下面看到整个命令。
pg_basebackup -h $PGHOST -p $PGPORT -U $PGUSER -w -D $backup_dir/psql_base_backup_$(date +"%d-%m-%y") -l "$(date)" -F tar -z -R -P &>> $backup_dir/status.log
下面您可以看到我想要备份的产品数据库:
postgres=# \c sks-api
You are now connected to database "sks-api" as user "postgres".
sks-api=# \dt
List of relations
Schema | Name | Type | Owner
--------+------------------+-------+-------
public | clusters | table | api
public | migrations | table | api
public | nodepools | table | api
public | service_instance | table | api
public | tasks | table | api
public | update_schedule | table | api
public | version_registry | table | api
(7 rows)
sks-api=# SHOW data_directory;
data_directory
--------------------------------
/var/lib/postgresql/13/cluster
(1 row)
现在,我正尝试恢复此数据库以进行测试。我创建了相同的两个服务器并执行以下操作:
systemctl stop postgresql
cd /home/user
tar -xzf base.tar.gz -C /var/lib/postgresql/13/cluster
tar -xzf pg_wal.tar.gz -C /var/lib/postgresql/13/cluster
systemctl start postgresql
但之后我在 sks-api db 中只看到两个表。我做错了什么?
sks-api=# \dt
List of relations
Schema | Name | Type | Owner
--------+------------+-------+---------------------
public | migrations | table | unknown (OID=16386)
public | nodepools | table | unknown (OID=16386)
(2 rows)