I have a main database server that WALs is periodically archived on s3. So s3 has a 'snapshot' of a database with all the corresponding latest WALs.
I have another (local) database server that I want to periodically
update to be actual to the state of the main database server.
So I once copied "main" directory from s3 and applied all the WALs from s3 by using restore.conf
The only thing I've changed in this file is:
restore_command = 'aws s3 cp s3://%bucketName%/database/pg_wal/%f %p'
It was successful.
After some time I want to apply all the latest WALs from s3 to being "more synchronized" with a main database server. Is it possible to do it somehow? I know exactly, that I did not make any updates or writes into my "copied" database server. When I'm trying to do it in the exactly same way as before I am getting the next errors (from stderr):
fatal error: An error occurred (404) when calling the HeadObject
operation: Key "database/pg_wal/00000001000001EF0000001F" does not
exist
fatal error: An error occurred (404) when calling the HeadObject
operation: Key "database/pg_wal/00000002.history" does not exist
fatal error: An error occurred (404) when calling the HeadObject
operation: Key "database/pg_wal/00000001.history" does not exist
fatal error: An error occurred (403) when calling the HeadObject
operation: Forbidden
fatal error: An error occurred (403) when calling the HeadObject
operation: Forbidden
fatal error: An error occurred (403) when calling the HeadObject
operation: Forbidden
fatal error: An error occurred (403) when calling the HeadObject
operation: Forbidden
fatal error: An error occurred (403) when calling the HeadObject
operation: Forbidden
This is a more detailed description of my procedure:
I have a two directories on s3: basebackup and pg_wal. basebackup contains base, global, pg_logical, pg_multixact, pg_xact, PG_VERSION, backup_label files.
When I recover it the first time, I do the following:
Stop postgres
aws s3 sync s3://%bucketname%/basebackup ~/10/main
mkdir empty directories in ~/10/main
copied recovery.conf.sample into ~/10/main/recovery.conf
edit recovery.conf as above
start PostgreSQL
When I'm doing it again after some time I'm doing steps 1, 4, 5, 6 and getting the described result.
Probably, I need to somehow specify the first WAL from s3 bucket to being restored? Because we already restored some of them before. Or it is impossible at all?
There seems to be a lot wrong with your procedures:
A complete backup does not only consist of the files and directories you list above, but of the complete data directory (pg_wal/pg_xlog can be empty).
After the first recovery, PostgreSQL will choose a new time line, rename backup_label and recovery.conf and come up as a regular database.
You cannot resume recovering such a database. I don't know what exactly you did to get into recovery mode again, but you must have broken something.
Once a database has finished recovery, the only way to recover further is to restore the initial backup again and recover from the beginning.
Have you considered using point-in-time recovery with recovery_target_action = 'pause'? Then PostgreSQL will stay in recovery mode, and you can run queries against the database. To continue recovering, define a new recovery target and restart the server.
Related
At the time of backup firebird database (gbak -g -ig) I have the following error:
gbak: writing data for table ORDERS
gbak: ERROR:message length error (encountered 532, expected 528)
gbak: ERROR:gds_$receive failed
gbak:Exiting before completion due to errors
When I'm using gfix with different parameters (-v -full, -mend, -ignore), I have the message:
Summary of validation errors
Number of index page errors : 540
In firebird.log file I see the lines:
PC (Server) Thu Sep 20 08:37:01 2018
Database: E:\...GDB
Index 2 is corrupt on page 134706 level 1. File: ..\..\..\src\jrd\validation.cpp, line: 1699
in table COMPONENTS (197)
However, the database works OK without problems.
Please help me to fix the error and make a backup.
(I need the backup to migrate to on 64bit server).
We are using Azure database for PostgreSQL ( Service ) for creating DB for each user when user register to the application ( less than 25 users databases right now ).
For reporting purpose we need information which each user's DB size.
To retrieve database size we have a Postgres function which fires the following query
SELECT pg_database.datname , pg_database_size(pg_database.datname) FROM
pg_database
We execute this function every hour throw azure function but at random time Postgres throw exceptions
Exception: Npgsql.PostgresException (0x80004005): 58P01: could not read directory "base/16452": No such file or directory at...
Exception remain same at most of the time with different directory or file location
Sometimes it also throws the exception
Exception: Npgsql.NpgsqlException (0x80004005): Exception while reading from stream ---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException
Working on the solution at the MSDN forums here.
Mongo version is 3.0.6, I have a process to apply oplog from another database to destination database by mongodump and mongorestore by using --oplogReplay option.
But I found duplicate key error messages many time, source and target database have the same structure (indies and fields) that is impossible to have duplicated record on target because it should be error on source db first.
And error message looks like this
2017-08-20T00:55:55.900+0000 Failed: restore error: error applying oplog: applyOps: exception: E11000 duplicate key error collection: <collection_name> index: <field> dup key: { : null }
And today I found a mystery message like this
2017-08-25T01:02:14.134+0000 Failed: restore error: error applying oplog: applyOps: not master
What's a mean? And my understanding, mongorestore has "--stopOnError" option that means the default process, if have any errors, the restore process will skip and move on. But I got above error and then the restore process has been terminated anytime. :(
This does not answer directly to your question, sorry for that, but...
If you need to apply oplog changes for database A to database B, it would be better to use mongo-connector program, than mongodump/mongorestore -pair.
Frequently getting this error message in postgres log - "failed to set up event for socket: error code 10038". Because of this connection attempt getting failed.
I have uninstalled and reinstalled postgres 9.6. I have included postgres.exe file in the exclude file list for antivirus scan. Is there any solutions for this.
We deployed some code tonight but had to rollback. The rollback affected the database so we restored our database to one we captured right before the deploy. Now we're getting all types of database errors, such as:
ActiveRecord::UnknownPrimaryKey: Unknown primary key for table billing_accounts in model BillingAccount.
PG::SyntaxError: ERROR: zero-length delimited identifier at or near """" LINE 1: ... "billing_accounts" ORDER BY "billing_accounts"."" ASC LIM.
PG::InternalError: ERROR: cache lookup failed for type 19005
PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block
I have no idea what to do about these errors, we're getting a ton of them. Help!!