簡體   English   中英

PostgreSQL生成一個空的20字節gzip壓縮備份文件

[英]PostgreSQL generates an empty 20-byte gzipped backup file

我們在Jelastic中管理多個Java + PostgreSQL環境。 我們的PaaS提供商使用Jelastic平台5.4版。

在每種環境中,我們都有一個cron任務,該任務調用一個shell腳本,以通過pg_dump為PostgreSQL 9.4生成每日gzip壓縮的數據庫備份。 從字面上看,該腳本已經運行了多年,但是最近它停止工作了。 該腳本如下所示:

#!/bin/bash
DATE=`date +"%Y-%m-%d_%H-%M-%S"`
DB_NAME="my-backup"
FILE="$DB_NAME-$DATE.backup.gz"
BASE_DIR="/var/lib/jelastic/backup"
BACKUP_FILE_PATH=$BASE_DIR/$FILE
pg_dump --verbose --format=custom $DB_NAME | gzip > $BACKUP_FILE_PATH

最近發生的唯一變化是與postgresql.conf shared_buffers值增加有關,這是我們根據Jelastic提供的指令執行的更改。 我們確實嘗試將shared_buffers上的更改撤消,以將其恢復為Jelastic環境的默認值,而對備份沒有積極影響。

現在,生成的備份文件(壓縮)只有20個字節長,整個備份過程比我們期望的要少得多的時間,因為我們的數據庫很大(超過1.5GB)並且包含BLOB。 從GZIP提取的文件為空。

pg_dump詳細輸出中,沒有什么異常:

pg_dump: reading schemas
pg_dump: reading user-defined tables
pg_dump: reading extensions
pg_dump: reading user-defined functions
pg_dump: reading user-defined types
pg_dump: reading procedural languages
pg_dump: reading user-defined aggregate functions
pg_dump: reading user-defined operators
pg_dump: reading user-defined operator classes
pg_dump: reading user-defined operator families
pg_dump: reading user-defined text search parsers
pg_dump: reading user-defined text search templates
pg_dump: reading user-defined text search dictionaries
pg_dump: reading user-defined text search configurations
pg_dump: reading user-defined foreign-data wrappers
pg_dump: reading user-defined foreign servers
pg_dump: reading default privileges
pg_dump: reading user-defined collations
pg_dump: reading user-defined conversions
pg_dump: reading type casts
pg_dump: reading table inheritance information
pg_dump: reading event triggers
pg_dump: finding extension members
pg_dump: finding inheritance relationships
pg_dump: reading column info for interesting tables
pg_dump: finding the columns and types of table "databasechangeloglock"
pg_dump: finding the columns and types of table "databasechangelog"
pg_dump: finding the columns and types of table "compania"
pg_dump: finding default expressions of table "compania"
pg_dump: finding the columns and types of table "comprobante"
pg_dump: finding default expressions of table "comprobante"
pg_dump: finding the columns and types of table "estado_comprobante"
pg_dump: finding default expressions of table "estado_comprobante"
pg_dump: finding the columns and types of table "usuario"
pg_dump: finding default expressions of table "usuario"
pg_dump: finding the columns and types of table "clave_contingencia"
pg_dump: finding default expressions of table "clave_contingencia"
pg_dump: finding the columns and types of table "latido_integrador"
pg_dump: finding default expressions of table "latido_integrador"
pg_dump: finding the columns and types of table "comprobante_importado"
pg_dump: finding default expressions of table "comprobante_importado"
pg_dump: finding the columns and types of table "estado_comprobante_importado"
pg_dump: finding default expressions of table "estado_comprobante_importado"
pg_dump: finding the columns and types of table "tarea_comprobante_importado"
pg_dump: finding default expressions of table "tarea_comprobante_importado"
pg_dump: finding the columns and types of table "usuario_compania"
pg_dump: finding default expressions of table "usuario_compania"
pg_dump: flagging inherited columns in subtables
pg_dump: reading indexes
pg_dump: reading indexes for table "databasechangeloglock"
pg_dump: reading indexes for table "compania"
pg_dump: reading indexes for table "comprobante"
pg_dump: reading indexes for table "estado_comprobante"
pg_dump: reading indexes for table "usuario"
pg_dump: reading indexes for table "clave_contingencia"
pg_dump: reading indexes for table "latido_integrador"
pg_dump: reading indexes for table "comprobante_importado"
pg_dump: reading indexes for table "estado_comprobante_importado"
pg_dump: reading indexes for table "tarea_comprobante_importado"
pg_dump: reading indexes for table "usuario_compania"
pg_dump: reading constraints
pg_dump: reading foreign key constraints for table "compania"
pg_dump: reading foreign key constraints for table "comprobante"
pg_dump: reading foreign key constraints for table "estado_comprobante"
pg_dump: reading foreign key constraints for table "usuario"
pg_dump: reading foreign key constraints for table "clave_contingencia"
pg_dump: reading foreign key constraints for table "latido_integrador"
pg_dump: reading foreign key constraints for table "comprobante_importado"
pg_dump: reading foreign key constraints for table "estado_comprobante_importado"
pg_dump: reading foreign key constraints for table "tarea_comprobante_importado"
pg_dump: reading foreign key constraints for table "usuario_compania"
pg_dump: reading triggers
pg_dump: reading triggers for table "compania"
pg_dump: reading triggers for table "comprobante"
pg_dump: reading triggers for table "estado_comprobante"
pg_dump: reading triggers for table "usuario"
pg_dump: reading triggers for table "clave_contingencia"
pg_dump: reading triggers for table "latido_integrador"
pg_dump: reading triggers for table "comprobante_importado"
pg_dump: reading triggers for table "estado_comprobante_importado"
pg_dump: reading triggers for table "tarea_comprobante_importado"
pg_dump: reading triggers for table "usuario_compania"
pg_dump: reading rewrite rules
pg_dump: reading large objects
pg_dump: reading dependency data
pg_dump: saving encoding = UTF8
pg_dump: saving standard_conforming_strings = on
pg_dump: saving database definition

另外,無法在Jelastic上訪問的PostgreSQL 9.4日志也沒有顯示任何相關消息,這些消息可能無法為我們提供線索。

為了“修復”此問題,我們執行了PostgreSQL維護程序,包括vacuumlovacuumdb --full ,無濟於事。 備份文件有足夠的可用存儲空間,因此這不應成為問題的原因。

關於為什么會發生這種情況的任何想法? 我們應該尋找什么,在哪里? 由於這是一個關鍵問題,因此我們希望您能提出一些建議。

您需要做的第一件事是更改文件pg_hba.conf(允許通過套接字進行無密碼連接):

CT-42366 ~# cat ./backup.sh 
local    all all                  trust
host     all all     127.0.0.1/32 ident
host     all all     ::1/128      ident
host     all all     0.0.0.0/0    md5

之后,重新啟動“ postgresql”服務:

service postgresql restart

然后,如果您對數據庫的登錄名不同於“ root”,請使用以下修改的腳本:

CT-42366 ~# cat ./backup.sh 
#!/bin/bash
DATE=date +"%Y-%m-%d_%H-%M-%S"
DB_NAME="db_name"
LOGIN="db_login"
FILE="$DB_NAME-$DATE.backup.gz"
BASE_DIR="/var/lib/jelastic/backup"
BACKUP_FILE_PATH=$BASE_DIR/$FILE
pg_dump --user=$LOGIN --format=custom --dbname=$DB_NAME | gzip > 
$BACKUP_FILE_PATH

我們希望這可以幫助您解決問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM