Re: Recommended way to copy database files on Windows OS (to perform file system level backup)

From: Christoph Moench-Tegeder <cmt(at)burggraben(dot)net>
To: Yashwanth Govinda Setty <ygovindasetty(at)commvault(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, Girish Rao <grao(at)commvault(dot)com>
Subject: Re: Recommended way to copy database files on Windows OS (to perform file system level backup)
Date: 2018-05-14 14:14:27
Message-ID: 20180514141427.xikwj3npoucy5a76@squirrel.exwg.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

## Yashwanth Govinda Setty (ygovindasetty(at)commvault(dot)com):

> We are facing this problem while performing file system level backup of database files:
> As each database will form a directory inside Base directory which consists of files representing the tables, when some tables are dropped during backup, We get error while copying since the files do not exist anymore.

This looks like you read only the first sentence of the relevant
documentation:
https://www.postgresql.org/docs/current/static/backup-file.html

The "recommended way" is not "use tar", but to heed both restrictions
mentioned there. Especially, if you want to do a naive copy of the files,
the database has to be shut down.
If shutting down the database is not an option (most cases), your
option is a "base backup" - there's pg_basebackup to help you with
that, and you can do that "the hard way" with the low level API.
Both approaches are described here:
https://www.postgresql.org/docs/current/static/continuous-archiving.html#BACKUP-BASE-BACKUP

This is mostly independent from the OS - but you have to make sure to
follow the process (shutting down the database beforehand, or do the
full base backup) - else the database will be corrupted after restore
and may even fail to start.

Regards,
Christoph

--
Spare Space.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jonathan Marks 2018-05-14 16:28:05 Rapid disk usage spikes when updating large tables with GIN indexes
Previous Message Allan Kamau 2018-05-14 13:48:45 Re: Recommended way to copy database files on Windows OS (to perform file system level backup)