I'm in a bit of a pickle here. I managed to copy the whole postgresql installation directory to a backup drive but how would I retrieve it from Linux with the same architecture and version. Is this possible? I wasn't able to do a backup.
1 Answer
There's no way to dump your Windows PostgreSQL database directory using Linux directly1.
You need to start up a virtual machine running Windows, then copy the database directory to that virtual machine. You can then pg_dump -Fc
it, and pg_restore
the dump to your new blank PostgreSQL install on the Linux machine.
You must make sure that if your PostgreSQL data directory was from 64-bit PostgreSQL you install a 64-bit Windows version and install 64-bit PostgreSQL on it.
If your PostgreSQL data dir is 32-bit it doesn't matter whether you install 32-bit or 64-bit Windows, but you must install 32-bit PostgreSQL.
Licensing restrictions mean that you can't just download a virtual machine image for Vagrant or whatever to run Windows. You will need a Windows install DVD or ISO image. It's possible to download these legally from Microsoft's digital distribution system if you don't already have a DVD or ISO. You can install them without a license key, but it'll disable its self after a few days, and it's not legal to use it without possessing a license.
For that reason, unless the database is really huge one of the best options is to sign up to Amazon EC2 (if you haven't already) and launch a Windows Server virtual machine on EC2. You can install PostgreSQL then copy your database to that virtual machine, run pg_dump
, and copy the dump back to your computer. Then just shut down the VM. You can use EC2 for free if you use a micro instance.
1 It's possible you might be able to run PostgreSQL using WINE, but I suspect that'd be even more complicated, if it works at all, and probably not particularly trustworthy. So just use Windows.
-
I was considering the same thing. And it looks like the most probable way of retrieving my data. Much appreciated. I'll do that. The database contains records for the system we made for a client for a school project. It took us hours to encode all of them. So I really need this. Just wait till I solve this. I'll give you the rep you deserve, sir Commented Oct 29, 2015 at 9:30
-
pg_dump
andpg_restore
pg_dump
wherever your current Postgres installation is running andpg_restore
wherever your new Postgres installation is running. Both are client programs, so you can actually run them on any computer that can connect to the the running Postgres instancespg_dump
andpg_restore
do work across different operating systems. This is all explained in the manual.