“在不同机器间同步 PostgreSQL 数据库的替代解决方案”

huangapple go评论69阅读模式
英文:

Alternative Solutions for Syncing PostgreSQL Databases Across Machines

问题

我拥有两台机器:

  1. 我的笔记本电脑,运行Ubuntu 22.04。
  2. OKD(Openshift容器)运行在CentOS 7上。

我的目标是在这两台机器之间同步一个PostgreSQL数据库。

最初,我计划使用Rsync来确保PostgreSQL数据目录在两台机器上保持一致。然而,由于两个系统之间配置文件的差异,这种方法可能会失败。

另一种替代方法涉及使用psql_dump命令从一台机器导出数据库,然后在另一台机器上导入它。

是否有其他解决方案适用于这种情况(请注意,此数据库用于Django项目)?

英文:

I possess two machines:

  1. My laptop, which operates on Ubuntu 22.04.
  2. OKD (Openshift container) that runs on CentOS 7.

My objective is to synchronize a PostgreSQL database between these two machines.

Initially, I planned to utilize Rsync to ensure that the PostgreSQL data directory remains consistent on both machines. However, this method is likely to fail due to the differences in configuration files between the two systems.

An alternative approach involves using the psql_dump command to export the database from one machine and then importing it on the other.

Are there any other solutions available for scenarios like this (Note that this database is used for a Django project)?

答案1

得分: 3

django-pg-copy 是为此目的编写的。它使用您 DATABASES 设置中的凭据来备份和恢复 Postgres 数据库跨不同环境,例如从生产环境备份以恢复到开发环境。

https://pypi.org/project/django-pg-copy/

完全透明披露:我维护这个包。

英文:

django-pg-copy was written for this purpose. It uses the credentials in your DATABASES settings to backup and restore Postgres databases across environments, such as backing up production to restore to dev.

https://pypi.org/project/django-pg-copy/

Full disclosure: I maintain this package.

huangapple
  • 本文由 发表于 2023年6月6日 15:42:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76412416.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定