Postgresql – archive command is not working

archivepostgresql

One of our ancient PostgreSQL server's used disk space has increased to 90%. First I've checked the archive command:

archive_command = 'rsync -aq %p /data/wal-archive/%f'

The problem with that command is rsync is not installed. So I've replaced it with:

archive_command = 'test ! -f /data/pgsql/data/mnt/server/archivedir/%f && 
    cp %p /data/pgsql/data/mnt/server/archivedir/%f'

After the replacement here is the output of postgresql.log:

cp: cannot stat `pg_xlog/000000010000000000000001': No such file or directory

I presume beginning of the pg_xlog files removed by hand. Do you have any idea how to make this archive process work?

Best Answer

First, take a pg_basebackup, just in case. Then set your archive command to /bin/true. That will allow Postgres to delete everything to its own satisfaction that has already been deleted. To restore from backup you need the WAL since your last basebackup. Restoring to a point in time before is now impossible I’m afraid. When this is finished, set the archive command correctly. And get some monitoring for this!