directory "*" exists but is not empty

在使用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 must exactly match the path specification of the tablespace as it is currently defined. (But it is not an error if there is no tablespace in olddir contained in the backup.) Both olddir and newdir must be absolute paths. If a path happens to contain a = sign, escape it with a backslash. This option can be specified multiple times for multiple tablespaces. See examples below.

If a tablespace is relocated in this way, the symbolic links inside the main data directory are updated to point to the new location. So the new data directory is ready to be used for a new server instance with all tablespaces in the updated locations.

所以:參數中指定

 -T /home/Thornger=/home/Thornger/data2/

問題解決

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章