如何解决PostgreSQL 数据库恢复使用 pg_restore 作为增量数据,无需覆盖或删除现有表
我有两个主机服务器 s1 和 s2。在两台服务器中,我都有一个名为 // Code from Real World App (RWA)
// cypress/support/index.ts
import { isMobile } from './utils'
import './commands'
// Throttle API responses for mobile testing to simulate real world conditions
if (isMobile()) {
cy.intercept({ url: 'http://localhost:3001/**',middleware: true },(req) => {
req.on('response',(res) => {
// Throttle the response to 1 Mbps to simulate a mobile 3G connection
res.setThrottle(1000)
})
})
}
的架构。现在我对 s1 的模式 {
/**
* Serve a fixture as the response body.
*/
fixture?: string
/**
* Serve a static string/JSON object as the response body.
*/
body?: string | object | object[]
/**
* HTTP headers to accompany the response.
* @default {}
*/
headers?: { [key: string]: string }
/**
* The HTTP status code to send.
* @default 200
*/
statusCode?: number
/**
* If 'forceNetworkError' is truthy,Cypress will destroy the browser connection
* and send no response. Useful for simulating a server that is not reachable.
* Must not be set in combination with other options.
*/
forceNetworkError?: boolean
/**
* Milliseconds to delay before the response is sent.
*/
delay?: number
/**
* Kilobits per second to send 'body'.
*/
throttleKbps?: number
}
中存在的一些表进行了一些更改。我希望对服务器 s2 的架构 n1
进行相同的更改。我打算做的是使用 n1
备份服务器 s1 的架构 n1,并使用 n1
在服务器 s2 中恢复。
对于备份和恢复使用这些命令:
pg_dump
但是当我使用 pg_restore
恢复时,出现此错误:
pg_dump -Fc -h XXXXX -U user -d dbname > test.dump
pg_restore -h XXXXX -U user -d dbname < test.dump
解决方法
你可以这样转储:
pg_dump -Fc -h XXXXX -U user --inserts --on-conflict-do-nothing --data-only -n n1 dbname > test.dump
恢复这样的转储将跳过与现有行有主键或唯一约束冲突的行。选项 --on-conflict-do-nothing
从 v12 开始可用。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。