How to restore PostgreSQL database? - postgresql

My Windows Server was damaged, I have installed the new OS, PostgreSQL12.
The folder \PostgreSQL\12\data is in good state.
No database dumps.
Is it possible to restore database having the folder?

As long as you're using the same architecture (32-bit vs 64-bit), and it's still on Windows Server, you should be able to use that by copying it to the right location on your new OS's filesystem and start it. Just be prepared for it to take longer to start if the database wasn't shut down cleanly as it will have to replay the transaction logs before coming online.

Related

Need to move postgis database to new linux machine...best method?

We're running out of room on our hard drive, and we're forced to move our postgis database to a new linux redhat machine. When our IT person copies the directories over to the new machine, I assume the entire database structure won't copy over perfectly.
We are running Red Hat 6 on the old and new machine. The postgresql version is 9.4.9 and the postgis version is 2.1.8.
Do you have suggestions for steps to take to successfully move our postgis-enabled PostgreSQL database to the new machine, keeping of course all data, structure, tables, etc.
I have seen some tutorials on this, but nothing really recent online.
Thanks for any help!
If the architecture is the same on both machines (e.g., both are x86_64), the PostgreSQL version is the same (the third digit can be different) and the RedHat version is the same (so that the same version of glibc guarantees that the collations are the same), you can simply copy the data directory (and all tablespaces) to the new machine and you are good.
Otherwise, use pg_dumpall to dump the old cluster and restore to the new machine.

Read-Only program on CD. no installation permitted. Firebird database

I have to develop a software for CD. So, the project must run only in CD, without installing to computer. Installing and copying must be impossible from disc. The program is something like Language Learning program. Can I use .NET (c#) environment for such a program? And which databases can I use? (I heard about Firebird).
You could use firebird. However, you would need a connection to an external firebird server to be able to do physical operations on the data. Another solution would be to save the data on the client computer. For instance you could restore the database in a profile folder. It is unclear to me whether changes and learn progress should be saved.

Can I run LocalDb "in-memory"

I am using LocalDb in an integration testing environment - instantiating and disposing of my instance before and after my tests run.
However, when I create a database within my instance, it still flushes my tables and data to disk. Is it possible to run LocalDb in an "in-memory" mode? And if so how?
You could run your tests against a database in a RAM disk. I have done that a while ago and it seemed to improve integration tests performance by a factor of 2 or 3! This was on a Windows 7 VM hosted in a MacBook Pro with an SSD. Your milage will probably be better if you have a mechanical HDD.
Since SQL Server allows you to specify the mdf file in a connection string via "AttachDbFileName=", you can leverage that by pointing to an mdf in a RAM disk.
The RAM disk device driver I used was ImDisk, which is available for both 64 and 32 bit Windows. Linux counterparts are numerous.
No. LocalDB is still SQL Server, and in SQL Server there is no concept of an in-memory database. All databases are disk-backed, with in-memory cache sitting on top of them.
You could probably write a custom step in your testing harness to drop your databases after your tests are completed and delete database files. Maybe even it's already there if you're using TFS for build and test runs? But there's nothing in LocalDB to make it automatic.

Unable to install PostgreSQL on dev machine

I'm trying to install PGSQL 8.3 (and 8.4 and 9.0) on my work laptop. At the end of the installation, the installer complains it can't init the cluster. Investigating more, I noticed that the service is not even installed. I did use the "OneClick Installer", not the pgAdmin stand alone install. I tried installing as Administrator and as a regular user. In all the cases, the pgsql system account is created and the files copied, but the service is not.
I successfully installed PGSQL many times on my home PC. Both the laptop and desktop use Windows 7 64 bits (former is Professional, later is Ultimate). The only differences I can think of are that the laptop is part of an Active Directory and uses McAfee, while the desktop is only on a workgroup and uses Windows Security Essentials.
Are you sure the postgres user is allowed to create files in the data directory? The installer defaults to putting the data directory where the binaries are installed (e.g. c:\Program Files) which is usually not writeable by a regular user (and I never understood why the installer contains such an idiotic default).
McAffee could be an issue though. I have heard several stories about virus scanners infering with the Postgres (or other DBMS). Can you turn McAffee off - at least for the data directory?
Another problem could be that the installer is not able to create the postgres windows user (that is used to run the service).
If you are a local administrator on that machine, try to create the user before the installer does it. The installer will then not try to create the user account.
As a last ressort, you could install PostgreSQL without the installer (this is what I usually do).
Download the ZIP file from http://www.enterprisedb.com/products-services-training/pgbindownload
Unzip it into a convenient location
Run initdb (make sure you do that using the postgres user account - the one that is used to run the service later!)
run pg_ctlr register to create the Windows service
If any of those steps fails you'll see a proper error message which is not always the case with the installer.
Anti-virus is a well known issue:
http://wiki.postgresql.org/wiki/Running_&_Installing_PostgreSQL_On_Native_Windows#Antivirus_software
PostgreSQL connection problems
(answer is from one the core developers)
Postgresql 8.4 and BitDefender 11
With earlier versions of PostgreSQL, I found I had to delete the user "postgres" before reinstalling would work. Not sure what versions had that problem, though.

Using pg_admin III and PostgreSQL 8.1 (both test and development)

I want to backup Development and restore it in test and vice-versa.
So when I do a backup of the db (in PGAdmin III), it backs it up. But
when I restore it, all primary key information is gone and no data is
in the tables.
Any help would be much appreciated. Thanks.
pgAdmin uses the client programs pg_dump for making backups and pg_restore for restoring (it's only a GUI). Try to dump and to restore with these programs directly and see if you get any errors or warnings.
Offtopic: Support for version 8.1 ends this year, you should upgrade to a newer version.