I have a broken server, and backups of /etc/postgresql
and /var/lib/postgresql
.
The database I am looking for was used by a 2009 release of Redmine, if that makes any difference. https://www.redmine.org/
The backup of /etc/postgresql/postgresql.conf
says:
data_directory = '/var/lib/postgresql/8.3/main' # use data in another directory
Listing the backup of /var/lib/postgresql/8.3/main
I see:
drwx------ 6 mysql scanner 4096 Nov 24 2009 base
drwx------ 2 mysql scanner 4096 Aug 15 07:40 global
drwx------ 2 mysql scanner 4096 Nov 23 2009 pg_clog
drwx------ 4 mysql scanner 4096 Nov 23 2009 pg_multixact
drwx------ 2 mysql scanner 4096 Nov 23 2009 pg_subtrans
drwx------ 2 mysql scanner 4096 Nov 23 2009 pg_tblspc
drwx------ 2 mysql scanner 4096 Nov 23 2009 pg_twophase
-rw------- 1 mysql scanner 4 Nov 23 2009 PG_VERSION
drwx------ 3 mysql scanner 4096 May 24 10:46 pg_xlog
-rw------- 1 mysql scanner 133 Jun 25 2014 postmaster.opts
-rw------- 1 mysql scanner 54 Jun 25 2014 postmaster.pid
(Ignore the ownership/group, they were messed up by the backup procedure.)
My concern is that only one file has an up-to-date modification time:
$ find . -mtime -10
./global
./global/pgstat.stat
Does this mean that the database data was written somewhere else, rather than into /var/lib/postgresql
?
There does seem to be some significant disk usage:
$ du .
12 ./pg_clog
4 ./pg_twophase
12 ./pg_multixact/members
12 ./pg_multixact/offsets
28 ./pg_multixact
4 ./pg_tblspc
76 ./pg_subtrans
4 ./pg_xlog/archive_status
98312 ./pg_xlog
300 ./global
25428 ./base/16427
4280 ./base/11510
4500 ./base/11511
4280 ./base/1
38492 ./base
137244 .
Does this imply a non-empty database?
If there have been no changes to the contents of the directories (no files created/deleted etc) then the directory timestamps won't change. This could account for many of the old timestamps - the DB was initialised in 2009 and had basically just worked since.
The two files from 2014 ... my guess is that someone made changes to the options in the postmaster.opts file and restarted the server. It then ran until it stopped some time after May 24th 2016.
In the location identified by data_directory.
No
Yes
My confusion was caused by the fact that no users had entered any new data in the last 10 days. When I looked to for modified files in the last 20 days, there were many.