Send netdisco-users mailing list submissions to
        netdisco-users@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/netdisco-users
or, via email, send a message with subject or body 'help' to
        netdisco-users-requ...@lists.sourceforge.net

You can reach the person managing the list at
        netdisco-users-ow...@lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than "Re: Contents of netdisco-users digest..."
Today's Topics:

   1. How to copy postgresql when Docker'izing (Eric Bates)
   2. Re: How to copy postgresql when Docker'izing (Christian Ramseyer)
--- Begin Message ---
Thanks for this amazing program.


We're trying to migrate our Netdisco from a "standard" Ubuntu install to 
a Docker container and I'm stuck trying to copy the postgres data.

Ubuntu currently installs postgres 16 and the netdisco-postgresql image 
is postgres 13; so, unfortunately, I can't simply rsync the postgresql 
data directory. Doing so results in the following postgres error:

netdisco-postgresql  | 2025-04-10 12:52:43.716 UTC [1] FATAL:  database 
files are incompatible with server
netdisco-postgresql  | 2025-04-10 12:52:43.716 UTC [1] DETAIL: The data 
directory was initialized by PostgreSQL version 16, which is not 
compatible with this version 13.4.

So I dumped the data from the existing netdisco:

pg_dump -Unetdisco -W netdisco > netdisco.sql

copied the file into the container's pgdata folder. Fired up just the 
postgres image and shelled in:

$ docker compose -f compose-netdisco.yaml up netdisco-postgresql -d
[+] Running 1/1
  ✔ Container netdisco-postgresql 
Started                                               0.2s

$ docker exec -it netdisco-postgresql bash
bash-5.1#

Finally I attempted to restore the copied data within the container:

bash-5.1# psql -Unetdisco netdisco < /var/lib/postgresql/data/netdisco.sql

The difficulty at this stage is that the restore attempt generates 
dozens of errors. Many of them are of the "already exists" variety; so I 
don't think I need to worry about them:

ERROR:  relation "user_log" already exists

However, there are other errors which look more serious (a small sample):

ERROR:  column "leaf" of relation "device_browser" does not exist
invalid command \.

ERROR:  multiple primary keys for table "admin" are not allowed
ERROR:  multiple primary keys for table "community" are not allowed

etc.

Is there a recommended way to copy the postgres?

Thanks for your time.

-- 
Clark 159a
508/289-3112

Attachment: smime.p7m
Description: smime.p7m


--- End Message ---
--- Begin Message --- If you just run pg_dump with -c, it will include drops for all the objects first and your restore should work a lot better.

Cheers
Christian

On 10.04.2025 15:11, Eric Bates wrote:
Thanks for this amazing program.


We're trying to migrate our Netdisco from a "standard" Ubuntu install to
a Docker container and I'm stuck trying to copy the postgres data.

Ubuntu currently installs postgres 16 and the netdisco-postgresql image
is postgres 13; so, unfortunately, I can't simply rsync the postgresql
data directory. Doing so results in the following postgres error:

netdisco-postgresql  | 2025-04-10 12:52:43.716 UTC [1] FATAL:  database
files are incompatible with server
netdisco-postgresql  | 2025-04-10 12:52:43.716 UTC [1] DETAIL: The data
directory was initialized by PostgreSQL version 16, which is not
compatible with this version 13.4.

So I dumped the data from the existing netdisco:

pg_dump -Unetdisco -W netdisco > netdisco.sql

copied the file into the container's pgdata folder. Fired up just the
postgres image and shelled in:

$ docker compose -f compose-netdisco.yaml up netdisco-postgresql -d
[+] Running 1/1
   ✔ Container netdisco-postgresql
Started                                               0.2s

$ docker exec -it netdisco-postgresql bash
bash-5.1#

Finally I attempted to restore the copied data within the container:

bash-5.1# psql -Unetdisco netdisco < /var/lib/postgresql/data/netdisco.sql

The difficulty at this stage is that the restore attempt generates
dozens of errors. Many of them are of the "already exists" variety; so I
don't think I need to worry about them:

ERROR:  relation "user_log" already exists

However, there are other errors which look more serious (a small sample):

ERROR:  column "leaf" of relation "device_browser" does not exist
invalid command \.

ERROR:  multiple primary keys for table "admin" are not allowed
ERROR:  multiple primary keys for table "community" are not allowed

etc.

Is there a recommended way to copy the postgres?

Thanks for your time.



_______________________________________________
Netdisco mailing list
netdisco-users@lists.sourceforge.net
https://sourceforge.net/p/netdisco/mailman/netdisco-users/

--
Christian Ramseyer, netnea ag
Network Management. Security. OpenSource.
https://www.netnea.com
Phone: +41 79 644 77 64




--- End Message ---
_______________________________________________
Netdisco mailing list - Digest Mode
netdisco-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/netdisco-users

Reply via email to