![](/img/trans.png)
[英]How to recover deleted data from AWS PostgreSQL database for Django project?
[英]How to restore postgreSQL from dump file to AWS?
我的本地環境中有 PostgreSQL 轉儲文件,我想在部署了 Django 應用程序的 AWS 服務器上恢復它。
我想我應該將轉儲文件上傳到 AWS 服務器,但我不知道它應該上傳到哪里以及如何恢復它。
使用 pgrestore 來恢復你的數據庫。
鏈接: https://www.postgresql.org/docs/9.2/app-pgrestore.html
為了獲得數據庫的轉儲,請使用 pgdump。
首先,使用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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.