Re: Use tar to online backup has an error - Mailing list pgsql-general

From David Steele
Subject Re: Use tar to online backup has an error
Date
Msg-id 560403CA.9020004@pgmasters.net
Whole thread Raw
In response to Re: Use tar to online backup has an error  (Yves Dorfsman <yves@zioup.com>)
Responses Re: Use tar to online backup has an error
List pgsql-general
On 9/24/15 9:29 AM, Yves Dorfsman wrote:
> On 2015-09-24 03:55, maxiangqian wrote:
>> /bin/tar: /data/test/PG_9.0_201008051/20001/24500001: Cannot stat: No such
>> file or directory
>>
>> /bin/tar: Error exit delayed from previous errors
>>
>>
>> and /data/test/PG_9.0_201008051/20001/24500001 file is not exist.
>>
>
> It looks like you are trying to make a filesystem backup while the files are still being updated. In order to make a
filesystembackup you need to either: 
>
>    - shutdown the database
>    - run "pg_start_backup" (make SURE that you run pg_stop_backup" when done)
>
> http://www.postgresql.org/docs/9.3/static/backup-file.html
> http://www.postgresql.org/docs/9.3/static/continuous-archiving.html#BACKUP-TIPS

It's actually perfectly normal for files to disappear during a backup,
even when pg_start_backup() is called first (never perform file-level
backup with calling pg_start_backup()).  The database continues to
operation normally during a backup so any dropped table (or temp table)
will result it files being removed by Postgres, not to mention changes
in clog, pg_xlog, etc.

All of this is reconciled during the replay of WAL after a restore.  You
just need to ignore any missing file errors while taking the backup and
be sure to back up all the WAL segments required to make the database
consistent. pg_basebackup will do all of this for you.

Another option is to use purpose-built backup software such as
pgBackRest or barman, both of which are open source.

--
-David
david@pgmasters.net


pgsql-general by date:

Previous
From: Willy-Bas Loos
Date:
Subject: Re: epoch and timezone changed bevior
Next
From: Stephen Frost
Date:
Subject: Re: Use tar to online backup has an error