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