D
D
Dauren Bablan2021-10-13 23:23:14
PostgreSQL
Dauren Bablan, 2021-10-13 23:23:14

How to restore postgres data?

  1. The problem is I don't have a database backup (I don't know well).
  2. The system is raised on docker, more precisely docker-compose, there is an old volumes (copied to another place /var/lib/docker/old/ ), and so everything connected with docker is fixed.
  3. Inside the old volumes there are folders (like 95390d0fa0cb02a9baf131967acc27a65a23b073ab0201c4935de53d6f87ae2e ), which contain files like in the image below.
  4. In docker-compose.yml I wrote:
    volumes:
          - /var/lib/docker/old/95390d0fa0cb02a9baf131967acc27a65a23b073ab0201c4935de53d6f87ae2e/_data/:/var/lib/postgresql/data/

    it doesn't help db is empty

How can I restore the data, what are the ways? Please help

Thanks in advance!

61674016d6e03024383667.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2021-10-13
@karabanov

Move the files somewhere where it will be convenient to store them.
Make a bind-mount of the directory where you moved the files.
Let's say the files are placed in a directory called data and it is placed in the same place as the docker-compoe.yml file , then:

version: '3.1'

services:

  db:
    image: postgres:13.4
    container_name: postgres13
    restart: always
    environment:
      POSTGRES_PASSWORD: strong_password
    volumes:
      - ./data:/var/lib/postgresql/data
    ports:
      - '5432:5432'

Specify your Postgresql version.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question