在Azure上更新本地Dockerized Postgress DB

发布于 2025-01-27 02:34:53 字数 274 浏览 3 评论 0原文

我有一台未更新的本地Postgres服务器,在Docker容器上运行,现在我想更新Production DB中的所有新记录, 在Azure Postgres DB上运行。

我知道pg_dump 但是,我不清楚我应该在哪里赞扬 - Azure DB不知道本地的DB,反之亦然?

I have an un-updated local Postgres server, running on a docker container, now I want to update all new records from Production DB,
which runs on Azure Postgres DB.

I'm aware of the pg_dump as in this Answer
but, I'm not clear where should I commend it - the Azure DB doesn't know the Local one and vice versa?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花桑 2025-02-03 02:34:53

您可以尝试多种方法。

最常见,最简单的方法是使用pg_dumppg_restore命令bash以升级数据库。

在上述方法中,您首先使用pg_dump从源服务器创建一个转储。然后,您使用pg_restore将转储文件还原到目标服务器。

要备份现有的PostgreSQL数据库,请运行以下命令:

pg_dump -fc -v -v -host =< host> - username =< name> -dbname =<数据库名称> -f< database> .dump

创建文件后,将其下载在本地环境中。

创建目标数据库后,可以使用PG_Restore命令和-DBNAME参数将数据从转储文件还原到目标数据库。

pg_restore -v -no所有者 - honst =<服务器名称> -port =< port> - username =<用户名> -dbname =< target数据库名称>.dump

To find more upgrade methods, you can refer

要获取有关pg_dumppg_restore methood的更多详细信息,请参阅Microsoft官方文档使用转储和还原迁移您的PostgreSQL数据库。

There are multiple methods which you can try.

The most common and simple approach is to use pg_dump and pg_restore commands in bash to upgrade the database.

In above mentioned method, you first create a dump from the source server using pg_dump. Then you restore that dump file to the target server using pg_restore.

To back up an existing PostgreSQL database, run the following command:

pg_dump -Fc -v --host=<host> --username=<name> --dbname=<database name> -f <database>.dump

Once the file has been created, download it in local environment.

After you've created the target database, you can use the pg_restore command and the --dbname parameter to restore the data into the target database from the dump file.

pg_restore -v --no-owner --host=<server name> --port=<port> --username=<user-name> --dbname=<target database name> <database>.dump

To find more upgrade methods, you can refer https://learn.microsoft.com/en-us/azure/postgresql/how-to-upgrade-using-dump-and-restore#method-1-using-pg_dump-and-psql.

To get more details on pg_dump and pg_restore methood, please refer Microsoft Official document Migrate your PostgreSQL database by using dump and restore.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文