pg_restore工作正常,但有一些错误

时间:2017-03-31 13:56:08

标签: postgresql

我正在测试我的备份/恢复过程,当我恢复数据库时,所有表都是正确的以及数据和表所有权。但是我担心会有一些警告/错误。

我的备份使用postgres crontab在cronjob中运行。然而,postgres cronjob中的pg_dump命令是使用' myuser'用户:

00 01 * * * pg_dump -U myuser -Fc --exclude-table-data=example_table example_db > ~/backups/example_db_backup.gz

如您所见,我在备份期间从其中一个表中排除数据。所有其他表等都会正常备份。

然后我使用postgres用户创建一个新的测试数据库,因为我不想将其恢复到实时数据库。我授予' myuser'的新数据库完全访问权限。用户然后恢复db:

su postgres
psql -U postgres
create database test;
GRANT ALL PRIVILEGES ON DATABASE test TO myuser;
\q

然后我按如下方式恢复数据库:

pg_restore -d test -U myuser ~/backups/example_db_backup.gz

如上所述,恢复正常,数据库中的所有内容都显示正确,但在恢复期间,我收到以下消息:

pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 2655; 0 0 COMMENT EXTENSION plpgsql 
pg_restore: [archiver (db)] could not execute query: ERROR:  must be owner of extension plpgsql
Command was: COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';

pg_restore: WARNING:  no privileges could be revoked for "public"
pg_restore: WARNING:  no privileges could be revoked for "public"
pg_restore: WARNING:  no privileges were granted for "public"
pg_restore: WARNING:  no privileges were granted for "public"
WARNING: errors ignored on restore: 1

这些错误是否值得关注?即使恢复似乎工作正常,我也不喜欢忽略我不理解的潜在问题。

1 个答案:

答案 0 :(得分:0)

加载sql dump文件时出现相同的错误,

 int val;
 int val2;
 Int32.TryParse(category.SelectedValue.ToString(), out val);
 Int32.TryParse(type.SelectedValue.ToString(), out val2);

 SqlConnection conn = new SqlConnection();
 conn.ConnectionString = "Data Source=ANTHONY-LAP\\SQLEXPRESS;Initial Catalog=Tenant Management;Integrated Security=True";
 conn.Open();
 string search_channel = @"select c.[Name],cate.[Channel Category],tp.type,st.Status,c.Surface,
                         g.GOVERNATOR + ' ' + d.District + ' ' + cit.City + ' ' as [Address],
                         c.[Short term Price per night] as [Short term monthly amount],
                         c.[Long term price per month] as [Long term monthly amount],c.[Selling Price]
                         from[dbo].[Channel] c
                         inner join[dbo].[Governator] g on c.[Governator ID] = g.ID
                         inner join[dbo].[District] d on c.[District ID] = d.ID
                         inner join[dbo].[City] cit on c.[City ID] = cit.id
                         inner join[dbo].[Channel_Category] cate on c.[Channel Category ID] = cate.ID
                         inner join[dbo].[Channel_Type] tp on c.[Channel Type] = tp.id
                         inner join[dbo].[Channel_Status] st on c.[Channel Status] = st.ID
                         inner join[dbo].[Reservations] r on c.[ID] = r.[Channel ID]
                         where r.[Actual Date in] < " + res_from.Value.ToString("yyyy/MM/dd") + " and r.[Actual Date out] > " + res_to.Value.ToString("yyyy/MM/dd") +
                         "and c.[Channel Status]!= '2' and c.[Channel Category ID] =" + val + "and c.[Channel Type] ="
                          + val2 + " and c.Surface =" + Convert.ToInt32(surf.Text) +
                          " and c.[Short term Price per night]= " + Decimal.Parse(shrtrntprice.Text) +
                          "and c.[Long term price per month]=" + Decimal.Parse(lngrent.Text) + "and c.[Selling Price] =" + Decimal.Parse(sellprc.Text);

为您的postgres=# alter role <user-name> superuser; 用户提供superuser角色,