B
B
bmalets2015-06-29 18:04:53
PostgreSQL
bmalets, 2015-06-29 18:04:53

How to get postgres database from Ubuntu FS backup?

Hello! There was an ubuntu 14.04
VPS running postgres 9.3 . Database is my_database , user is postgres , password is my_password . Due to a weak SSH password, the VPS was hacked. The hosting provided a VPS backup and mounted it as /opt/backup (the entire file system of the previous ubuntu with all data is available along this path) The new VPS is also ubuntu 14.04, postgres is installed the same - 9.3. path to old postgre - /opt/backup/etc/postgresql/9.3/main path to new postgre - /etc/postgresql/9.3/main Judging by the file




/opt/backup/etc/postgresql/9.3/main/postgresql.conf :

# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.
data_directory = '/var/lib/postgresql/9.3/main'
hba_file = '/etc/postgresql/9.3/main/pg_hba.conf'
ident_file = '/etc/postgresql/9.3/main/pg_ident.conf'

The databases must be physically located in /var/lib/postgresql/9.3/main (data_directory).
But they are not there:
/opt/backup/var/lib/postgresql/9.3/main$ ls -al
total 56
drwxr-xr-x 2 postgres postgres  4096 May 15 06:06 .
drwxr-xr-x 3 postgres postgres  4096 May 15 06:06 ..
-rw-r--r-- 1 postgres postgres   315 May 15 06:06 environment
-rw-r--r-- 1 postgres postgres   143 May 15 06:06 pg_ctl.conf
-rw-r----- 1 postgres postgres  4719 Jun 17 09:47 pg_hba.conf
-rw-r----- 1 postgres postgres  1636 May 15 06:06 pg_ident.conf
-rw-r--r-- 1 postgres postgres 20669 Jun 17 09:29 postgresql.conf
-rw-r--r-- 1 postgres postgres   378 May 15 06:06 start.conf

Question: how to get the my_database database from the backup of the old VPS and attach it to the postgres of the new VPS?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2015-06-29
@bmalets

Databases should be physically located in data_directory = '/var/lib/postgresql/9.3/main'..
But they are not there:
/opt/backup/etc/postgresql/9.3/main$ ls -al

The thought is logical, but why look in etc, but not in var?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question