I'm looking to backup a postgres database to a plaintext file, and then restore that backup. Here is what I tried.
sudo -u postgres pg_dump --create mydatabase > backup.sql sudo -u postgres psql < backup.sql
I want the database to be completely restored to the state it was in when I backed it up. I'm expecting it to issue a DROP DATABASE in backup.sql, but this is not happening.
Currently, my work-around is to edit backup.sql and insert a DROP DATABASE. Is that really necessary?