I made a Snapshot yesterday of a Django app running on a development server. I made sure to run sudo poweroff
before the Power Cycle.
After the App restarted, I couldn’t access the domain in my browser. I then try to dump my database, but I get the following error:
pg_dump: [archiver (db)] connection to database "db" failed: could not connect to server: Connection refused
Is the server running on host "####" and accepting
TCP/IP connections on port ###?
It actually seems like I can’t get any response from the DB or the app.
Response from nmap ip##
PORT STATE SERVICE
80/tcp closed http````
But the logs from the Django app tell me that it should be running.
How do I retrieve the data from my database and get the app running again?
Thank you!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi!
So it sounds like you are using the Dokku postgres plugin. If that’s the case, then to dump a database, you’ll need to do it with Dokku as it is running inside a container.
dokku postgresql:dump dbname > foo.sql
and to restore one:
dokku postgresql:restore dbname < foo.sql
As to the question of will dokku postgresql:create original_db_name
will destroy the old one, looking at the code:
if [[ -f "$DOKKU_ROOT/.postgresql/volume_$APP" ]]; then
VOLUME="`cat $DOKKU_ROOT/.postgresql/volume_$APP`:/opt/postgresql"
echo
echo "-----> Reusing postgresql/$APP database"
else
VOLUME="/opt/postgresql"
# Generate a random password for DB user
DB_PASSWORD=$(< /dev/urandom tr -dc A-Za-z0-9 | head -c 16)
echo $DB_PASSWORD > "$DOKKU_ROOT/.postgresql/pwd_$APP"
chown dokku: "$DOKKU_ROOT/.postgresql/pwd_$APP"
chmod 700 "$DOKKU_ROOT/.postgresql/pwd_$APP"
fi
it looks like it will attempt to reuse the persistent volume.
Click below to sign up and get $100 of credit to try our products over 60 days!
The problem was that the docker container for the postgresql database was not running, even though postgresql was running.
Trying:
The container seemed to be running as well. But I tried:
And now the app is running with the database port open.
I tried running the script from this forum: https://coderwall.com/p/wtqlca
Which restarted my app properly. However, my database name is different from the app name I’m using, so a new database container was created, which is obviously empty.
I’m not sure if
dokku postgresql:create original_db_name
is going to erase my original database, or just restart the container.Yes it seems to be running. I get the following output.
Is Postgres running? What’s the output of
I get the same error after restarting postgresql
Have you attempted to restart your postgres after you encountered this issue? These messages would appear to indicate that the database is not currently running