sipcapture / homer

HOMER - 100% Open-Source SIP, VoIP, RTC Packet Capture & Monitoring
https://sipcapture.org
GNU Affero General Public License v3.0
1.58k stars 239 forks source link

Follow up Question - dumping/importing homer_config mapping_schema #636

Closed jagnetta closed 2 months ago

jagnetta commented 2 months ago

Good day,

I'm following up on a question about trying to make the field mappings portable across installations. It's imperative that an automated process be created, so I'm focusing on this type of operation:

Server 1: sudo -u postgres pg_dump homer_config > homer_config scp homer_config Server2:

Server 2: sudo -u postgres psql -c "drop database homer_config;" sudo -u postgres psql -c "create database homer_config;" sudo -u postgres psql < /tmp/homer_config

Even after the drop, I get errors such as this: ERROR: duplicate key value violates unique constraint "mapping_schema_pkey"

NB: I do see references to my custom mappings in the dump file.

I'm not sure why there are still relations or tables after the DB drops that the import should complain about duplication. But that's because I'm no psql expert at all.

If you happen to have a 1/2 way decent procedure on how to do something like this I'd appreciate it. In the meantime I'm googling as hard as I can!! :)

Thanks, Jim Agnetta

github-actions[bot] commented 2 months ago

Your report is appreciated. Please star this repository to motivate its developers! :star:

jagnetta commented 2 months ago

This seems to work better:

Server 1: sudo -u postgres pg_dump homer_config > homer_config scp homer_config Server2:/tmp/homer_config

Server 2: sudo -u postgres psql -c "DROP TABLE mapping_schema;" sudo -u postgres psql < /tmp/homer_config

Any tables that already exist are protected, and mapping_schema gets imported.

jagnetta commented 2 months ago

I'm pretty sure this can be closed. If you have something more elegant, please advise. Thanks!