Goodmorning, just wanted to make sure im understanding this right, we should make a new file and a new folder and name it universe.sql and then enter pg_dump -cC --inserts -U freecodecamp universe > universe.sql in the terminal before starting the project to make sure it all gets saved and can be accessed later? /// If you leave your virtual machine, your database may not be saved. You can make a dump of it by entering pg_dump -cC --inserts -U freecodecamp universe > universe.sql in a bash terminal (not the psql one). It will save the commands to rebuild your database in universe.sql. The file will be located where the command was entered. If it’s anything inside the project folder, the file will be saved in the VM. You can rebuild the database by entering psql -U postgres < universe.sql in a terminal where the .sql file is.
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.54
Challenge: Celestial Bodies Database - Build a Celestial Bodies Database
Link to the challenge:
After re reading it, it sounds more like the given command creates a new file named universe.sql to save all the entered commands in. Is that right?
codeally@b9c16d1001ba:~/project$ pg_dump -cC --inserts -U freecodecamp universe > universe.sql
pg_dump: error: connection to database “universe” failed: connection to server on socket “/var/run/postgresql/.s.PGSQL.5432” failed: FATAL: database “universe” does not exist
codeally@b9c16d1001ba:~/project$
///////// ok so should i sign into psql first create a database named universe and then enter the command im confused?
This method is to save your work (after you have done some work).
Ps. You need to copy the contents of the file out to a local copy as well (not sure if the steps mention this). Otherwise the actual file may also get lost.
Alright cool so once i get a bit more done i can hit the \q to exit psql and then i hit the command in the reg bash terminal?
I actually went to look up some stuff on another page and the virtual machine closed trying to refresh but my data was still saved
Yes that makes sense. After that you can check the file to see the contents make sense. Also copy the contents of the file out to a local copy (this has to be done manually. You select the contents and right click and choose copy then go somewhere on your local machine to paste it)
1 Like
It definitely isn’t saying that it will always forget your work. Only that it -may-.
Ok will do, thank you for confirming hbar1st
1 Like