Re: Use tar to online backup has an error

From: David Steele <david(at)pgmasters(dot)net>
To: Yves Dorfsman <yves(at)zioup(dot)com>, pgsql-general(at)postgresql(dot)org, maxiangqian(at)gmail(dot)com
Subject: Re: Use tar to online backup has an error
Date: 2015-09-24 14:08:10
Message-ID: 560403CA.9020004@pgmasters.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 filesystem backup 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(at)pgmasters(dot)net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Frost 2015-09-24 14:15:17 Re: Use tar to online backup has an error
Previous Message Willy-Bas Loos 2015-09-24 14:02:02 Re: epoch and timezone changed bevior