【问题标题】:How to restore postgreSQL from dump file to AWS?如何将 postgreSQL 从转储文件恢复到 AWS?
【发布时间】:2020-12-07 17:37:53
【问题描述】:

我的本​​地环境中有 PostgreSQL 转储文件,我想要 在部署 Django 应用程序的 AWS 服务器上恢复它。

我想我应该将转储文件上传到 AWS 服务器,但我不知道 应该上传到哪里以及如何恢复它。

【问题讨论】:

    标签: python django postgresql amazon-web-services


    【解决方案1】:

    首先,使用scp 命令将文件从本地环境复制到 AWS

    例如

    scp -i /directory/to/abc.pem mydump.sql user@ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com:/tmp/
    

    abc.pem 是您的 aws 私钥。 mydump.sql 是您的转储文件,/tmp/ 是复制转储文件的路径

    一旦文件被复制到您的 AWS /tmp 文件夹或您使用的任何位置,接下来您需要将其恢复到您的数据库,例如使用

    ./pg_restore -U postgres -p 5432 -d yourdatabase < mydump.sql
    

    披露:我为EnterpriseDB (EDB)工作

    【讨论】:

      【解决方案2】:

      使用 pgrestore 恢复您的数据库。

      链接:https://www.postgresql.org/docs/9.2/app-pgrestore.html

      为了获得数据库的转储,请使用 pgdump。

      链接:https://www.postgresql.org/docs/9.6/app-pgdump.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-04-07
        • 2011-07-24
        • 2012-01-19
        • 2010-09-11
        • 2022-11-03
        • 1970-01-01
        相关资源
        最近更新 更多