Step-by-step instructions for restoring an exported .sql file to a local PostgreSQL database, using PyCharm or pgAdmin.
.sql file downloaded from the Instance Controller.Open PyCharm and go to View → Tool Windows → Database. Click the + button and select Data Source → PostgreSQL.
In the connection settings, fill in:
localhost5432djangolundadminlocalClick Test Connection to verify, then click OK.
The database username you need is shown on the instance page next to the Export Database button, labelled DB user for restore. Copy it before continuing.
If you no longer have access to the instance page, open the .sql file in a text editor and search for OWNER TO — the name that follows it is the username.
Create the users
In the Database panel, right-click your PostgreSQL server and select New → User. Fill in the username and password, then repeat for the second user.
Grant privileges via query console
Right-click the server and select New → Query Console, then run the GRANT statements below.
Run the following in the query console, replacing the placeholders:
GRANT ALL PRIVILEGES ON DATABASE <database_name> TO initdeploy;
GRANT ALL PRIVILEGES ON DATABASE <database_name> TO <instance_user>;
GRANT statements.
In the Database panel, right-click your target database and select Restore. In the restore dialog:
psql binary:C:\Program Files\PostgreSQL\[Version]\bin\psql.exe.sql file as the input.The restore may take a minute depending on the size of the dump. Once complete, all tables and data will be available in your local database.
google_vacuum_mgmt extension not being available locally. These are harmless and do not affect the restored data.
Your local database now contains a copy of the exported instance data. You can connect to it from your local LEX setup by pointing it at the restored database. Remember that this is a point-in-time snapshot — any changes made in the instance after the export are not included.