Reputation: 1091
I have Ubuntu 16.04 LTS installed in my machine with postgresql-9.3. (It looks I Keep this instance since 16.04 installs postgresql9.5).
Well, I installed 9.5 and remove 9.3 using...
sudo apt-get remove postgresql-9.3
Unfortunately I didn't know all databases and roles were in that instance (9.3) and are not shared with 9.5. when trying to log in with my users it doesn't work because they don't exist in that instance / cluster (am I right?)
I tried to install 9.3 using Ubuntu repository but it installs me just the 9.5. How can I move the all my roles and databases to 9.5 ??
Upvotes: 4
Views: 3675
Reputation: 798
To see if your database is still on your server check this folder :
ls /var/lib/postgresql/9.3/main/base/
If you have files there, this mean your database is still here !! If nothing in this folder, this mean your life data have been deleted.
Did you made a regular backup of your database ?
If so, you need to install back your previous version of PostgreSQL and make a restore of it.
apt-get install postgresql-9.3
psql -h localhost
create database dbname;
psql -h localhost dbname < backup_file
After the normal process to upgrade on Debian or Ubuntu is this one : service postgresql stop
On vire le cluster de la nouvelle version (normalement vide si on vient juste de l’installer : faire gaffe à ne pas laisser passer de temps entre l’installation de la nouvelle version et la migration des données, pour que personne n’utilise le nouveau cluster)
Stop the new updated version of PostreSQL :
service postgresql stop
Drop the new updated version cluster to be sure nothing is inside :
pg_dropcluster --stop 9.5 main
Then data migration :
pg_upgradecluster -m upgrade 9.3 main
Then stop previous version of PotsgreSQL :
pg_dropcluster 9.3 main --stop
Remove the old version :
apt-get autoremove --purge postgresql-9.3
Then just restart PostgreSQL, the new version with database migrated :
service postgresql start
Hope this help.
But if you didn't do any backup, unfortunatly you should have loose everything.
Upvotes: 5