I have a postgresql database called tables
with 2 tables which looks like this
readingtable
date reading1 reading2 reading3 source
2021-01-01 xx xx xx x1
2021-01-01 xx xx xx x2
2021-01-01 xx xx xx x3
...
2021-01-01 xx xx xx x150
2021-01-02 xx xx xx x1
2021-01-02 xx xx xx x2
....
2021-06-29 xx xx xx x150
booltable
date bool1 bool2 bool3 source
2021-01-01 xx xx xx x1
2021-01-01 xx xx xx x2
2021-01-01 xx xx xx x3
...
2021-01-01 xx xx xx x150
2021-01-02 xx xx xx x1
2021-01-02 xx xx xx x2
....
2021-06-29 xx xx xx x150
I have 150 sources which save reading to my postgresql server which are saved to 2 tables.
So example, today I would get the following data appended to the readingtable
table
date reading1 reading2 reading3 source
2021-06-30 xx xx xx x1
2021-06-30 xx xx xx x2
2021-06-30 xx xx xx x3
...
2021-06-30 xx xx xx x150
I have another backup postgresql server in mylaptop where I save the readings everyday.
But to do that, what I do is first delete from booltable;
and delete from readingtable;
.
Then I do pg_dump -h $remoteip -p $remoteport -U $remoteuser -C tables | psql -h localhost -d tables -U $localuser
This copies every entry in the database.
Is there a way for my local database to just compare with the remote database and only update the entries which are missing (the latest date's 150 entries).