在使用pg_basebackup备份基础数据的时候,遇到了错误
directory "/home/Thornger" exists but is not empty
经过检查-D ‘/home/Thornger/data2’,指定的文件夹里面确实是空的。
[Thornger@localhost postgres-9.6]$ ll data2/
total 0
data2 下没有数据,这时候你就应该检查你的主库,也就是说你指定创建基础备份的库。检查一下有没有特殊地方的tablespace
psql
postgres=# \db
List of tablespaces
Name | Owner | Location
------------+----------+----------------
pg_default | Thornger |
pg_global | Thornger |
test | Thornger | /home/Thornger
问题找到了,有一个自建的tablespace 在/home/Thornger下。
pg_basebackup 中有一个参数:大概意思就是将你以前创建的tablespace目录对应到现在指定的tablespace 目录。
-T olddir=newdir
--tablespace-mapping=olddir=newdir
Relocate the tablespace in directory olddir to newdir during the backup. To be effective, olddir