the first way
pg_dumpall -p 5432 | psql -d postgres -p 5433
the second way
First install two versions of the database 9.5 and 9.5
sudo service postgresql stop
sudo pg_dropcluster 9.5 main ; do not perform this step wrong, delete the old database
sudo pg_upgradecluster -v 9.5 9.3 main
After the new database is normal, delete the old database