R
R
rPman2017-09-24 15:23:27
PostgreSQL
rPman, 2017-09-24 15:23:27

How to transfer the postgresql database from a non-working system if the service does not start in the chroot?

The ubuntu server 16.04 lts stopped starting, at startup it stupidly does not see the device any sata and ide disks (through the controller), it is very difficult to track what exactly and why this happened, the machine reboots every half a year, there was no time to solve the problem the previous time, but it was fixed bluntly copying the kernel and image to the boot directory from a clean install. Unfortunately, after a few months, when a reboot (power outage) was required, the situation repeated itself, and copying a newer version of the kernel and the starting imagefs did not help.
Of course, update-grub did, went through different launch options and kernel versions. The problem is clearly not in the hardware, but in the combination of installed software, imagefs regeneration settings, etc., it was not possible to solve the problem right away, and therefore a decision was made to reinstall the system. Unfortunately, there is no backup in the form of a dump of the postgresql database, but there is a full copy of the system.
I would be happy to run the system in chroot, but unfortunately when I try to do this, the postgresql service writes that 'I can't run in chroot', Google even gave out links to the archlinux bug tracker where this problem was even solved, but I have ubuntu and this is clearly a distribution problem .
Tell me how I can transfer the database to a new installation with the least bloodshed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2017-09-24
@melkij

Find where the datadir of the base is. Most likely /var/lib/postgresql/(base version)/main, but could have been moved, there may also be several base clusters and different base versions - this is easy to do in debians and ubunts.
Next, install on the new system postgresql identical to the major version and not lower than the minor version that was there. What was the major version - see the PG_VERSION file in datadir. minor version, install the latest current one.
So I understand that the old system basically does not work? Those. the old base is turned off? Turn off the new (so far empty) base. Check, if not sure, both bases must be turned off.
Rename datadir on the new server (in general, you can delete it, but you can also make a mistake with the console and drop it wrong =) )
Copy the base directory: rsync -a /olddatadir /newdatadir
Copy and edit, if necessary, configs from /etc/postgresql/base_version
If the pg_tblspc/ directory in datadir is not empty, copy the symlinks from it and all the data for these symlinks to similar places on the new machine.
If pg_xlog/ is a symlink, it must be copied. You can leave a symlink, you can copy the content.
Trying to start the database in a new location. Look at the logs. If the database was not damaged in the old place (and nothing was forgotten to be copied), then it will start.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question