0

I would like to make backups of my whole / directory with borgbackup.
However, since PostgreSQL has its own way to backup databases, I would use in this case the SQL dump method to create a snapshot of the database.
Thus, when I perform my system backups, which directory am I expected to exclude from /?

1

Canonical PostgreSQL installation put all DB related content into /var/lib/postgresql. This is also the case in Ubutu, see this other question for example: default location of postgresql when installing through apt-get

You can also see it if your database is running, in ps output the postgres process should have a -D flag followed by the path of the "data" directory.

If you start the psql client you can also use command show data_directory; to see it (if you are on the same host).

See https://stackoverflow.com/questions/1137060/where-does-postgresql-store-the-database for even more ways to get this information.

2
  • Do you think I have to exclude from my system backup the whole var/lib/postgresql data directory or just the databases? I do not know if pg_dumpall performs on this directory or on single files. – Asarluhi Dec 27 '17 at 16:21
  • 1
    You can exclude the whole directory if you do backup it another way (or just keep it in your backups, not a. trouble either even if restoring from it might not be possible). pg_dumpand pg_dumpall do SQL level dumps, irrelevant to how the files are handled and spread out. – Patrick Mevzek Dec 27 '17 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.