Postgres data directories from previous upgrades

We’re preparing for upgrading to Gitlab 14.x and we’re on postgres 11 at the moment.
Our current postgress directory is 27 GB but a lot of data is stored in what seems like left overs from previous upgrades of postgres:

[root@chow ~]# du -h --max-depth=1 /var/opt/gitlab/postgresql/
2.4G    /var/opt/gitlab/postgresql/data.9.2.18
7.9G    /var/opt/gitlab/postgresql/data.12
7.7G    /var/opt/gitlab/postgresql/data.10
8.6G    /var/opt/gitlab/postgresql/data
27G     /var/opt/gitlab/postgresql/
[root@chow ~]#

The data.12 is from our latest attempt at upgrading which wasn’t that successful.
Could you please advise if it’s safe to simply delete all data.* directory leaving just the current “data”? Timestamps on the directories and files inside suggest that no change has been made for quite a long time hence looks good but I want to be sure.
Please advise.


Yes its safe. The data.{pgver} are leftover after upgrading postgres. Maybe just leave the data.12 with it being the last one before current data directory. You have backups anyway under /var/opt/gitlab/backups so you could remove data.12 as well if you wanted.

I thought so but needed to confirm.

1 Like