restore PosgreSQL

ubitec2 years ago

good morning, I have a series of errors when trying to restore a database in postgresSQL, (I know that it is not inherent to traccar, but as it is known here I ask from the experience of some) I have tried various ways and options and it always fails due to various errors , (here are most of them), the idea is to restore a traccar 5.4 base and update to 5.5, I am doing the backups and restores by pgadmin (I am recieving in a new vps the same for tests so the original database is intact until learn to carry out the process) thank you very much for your attention and help

ubitec2 years ago
pg_restore: connecting to database for restore
pg_restore: dropping FK CONSTRAINT tc_user_user fk_user_user_userid
pg_restore: dropping FK CONSTRAINT tc_user_user fk_user_user_manageduserid
pg_restore: dropping FK CONSTRAINT tc_user_order fk_user_order_userid
pg_restore: dropping FK CONSTRAINT tc_user_order fk_user_order_orderid
pg_restore: dropping FK CONSTRAINT tc_user_notification fk_user_notification_userid
pg_restore: dropping FK CONSTRAINT tc_user_notification fk_user_notification_notificationid
pg_restore: dropping FK CONSTRAINT tc_user_maintenance fk_user_maintenance_userid
pg_restore: dropping FK CONSTRAINT tc_user_maintenance fk_user_maintenance_maintenanceid
pg_restore: dropping FK CONSTRAINT tc_user_group fk_user_group_userid
pg_restore: dropping FK CONSTRAINT tc_user_group fk_user_group_groupid
pg_restore: dropping FK CONSTRAINT tc_user_geofence fk_user_geofence_userid
pg_restore: dropping FK CONSTRAINT tc_user_geofence fk_user_geofence_geofenceid
pg_restore: dropping FK CONSTRAINT tc_user_driver fk_user_driver_userid
pg_restore: dropping FK CONSTRAINT tc_user_driver fk_user_driver_driverid
pg_restore: dropping FK CONSTRAINT tc_user_device fk_user_device_userid
pg_restore: dropping FK CONSTRAINT tc_user_device fk_user_device_deviceid
pg_restore: dropping FK CONSTRAINT tc_device_attribute fk_user_device_attribute_deviceid
pg_restore: dropping FK CONSTRAINT tc_device_attribute fk_user_device_attribute_attributeid
pg_restore: dropping FK CONSTRAINT tc_user_command fk_user_command_userid
pg_restore: dropping FK CONSTRAINT tc_user_command fk_user_command_commandid
pg_restore: dropping FK CONSTRAINT tc_user_calendar fk_user_calendar_userid
pg_restore: dropping FK CONSTRAINT tc_user_calendar fk_user_calendar_calendarid
pg_restore: dropping FK CONSTRAINT tc_user_attribute fk_user_attribute_userid
pg_restore: dropping FK CONSTRAINT tc_user_attribute fk_user_attribute_attributeid
pg_restore: dropping FK CONSTRAINT tc_positions fk_positions_deviceid
pg_restore: dropping FK CONSTRAINT tc_notifications fk_notification_calendar_calendarid
pg_restore: dropping FK CONSTRAINT tc_groups fk_groups_groupid
pg_restore: dropping FK CONSTRAINT tc_group_order fk_group_order_orderid
pg_restore: dropping FK CONSTRAINT tc_group_order fk_group_order_groupid
pg_restore: dropping FK CONSTRAINT tc_group_notification fk_group_notification_notificationid
pg_restore: dropping FK CONSTRAINT tc_group_notification fk_group_notification_groupid
pg_restore: dropping FK CONSTRAINT tc_group_maintenance fk_group_maintenance_maintenanceid
pg_restore: dropping FK CONSTRAINT tc_group_maintenance fk_group_maintenance_groupid
pg_restore: dropping FK CONSTRAINT tc_group_geofence fk_group_geofence_groupid
pg_restore: dropping FK CONSTRAINT tc_group_geofence fk_group_geofence_geofenceid
pg_restore: dropping FK CONSTRAINT tc_group_driver fk_group_driver_groupid
pg_restore: dropping FK CONSTRAINT tc_group_driver fk_group_driver_driverid
pg_restore: dropping FK CONSTRAINT tc_group_command fk_group_command_groupid
pg_restore: dropping FK CONSTRAINT tc_group_command fk_group_command_commandid
pg_restore: dropping FK CONSTRAINT tc_group_attribute fk_group_attribute_groupid
pg_restore: dropping FK CONSTRAINT tc_group_attribute fk_group_attribute_attributeid
pg_restore: dropping FK CONSTRAINT tc_geofences fk_geofence_calendar_calendarid
pg_restore: dropping FK CONSTRAINT tc_events fk_events_deviceid
pg_restore: dropping FK CONSTRAINT tc_devices fk_devices_groupid
pg_restore: dropping FK CONSTRAINT tc_device_order fk_device_order_orderid
pg_restore: dropping FK CONSTRAINT tc_device_order fk_device_order_deviceid
pg_restore: dropping FK CONSTRAINT tc_device_notification fk_device_notification_notificationid
pg_restore: dropping FK CONSTRAINT tc_device_notification fk_device_notification_deviceid
pg_restore: dropping FK CONSTRAINT tc_device_maintenance fk_device_maintenance_maintenanceid
pg_restore: dropping FK CONSTRAINT tc_device_maintenance fk_device_maintenance_deviceid
pg_restore: dropping FK CONSTRAINT tc_device_geofence fk_device_geofence_geofenceid
pg_restore: dropping FK CONSTRAINT tc_device_geofence fk_device_geofence_deviceid
pg_restore: dropping FK CONSTRAINT tc_device_driver fk_device_driver_driverid
pg_restore: dropping FK CONSTRAINT tc_device_driver fk_device_driver_deviceid
pg_restore: dropping FK CONSTRAINT tc_device_command fk_device_command_deviceid
pg_restore: dropping FK CONSTRAINT tc_device_command fk_device_command_commandid
pg_restore: dropping INDEX user_device_user_id
pg_restore: dropping INDEX position_deviceid_fixtime
pg_restore: dropping INDEX idx_users_login
pg_restore: dropping INDEX idx_users_email
pg_restore: dropping INDEX idx_drivers_uniqueid
pg_restore: dropping INDEX idx_devices_uniqueid
pg_restore: dropping INDEX event_deviceid_servertime
pg_restore: dropping CONSTRAINT tc_users tc_users_pkey
pg_restore: dropping CONSTRAINT tc_users tc_users_email_key
pg_restore: dropping CONSTRAINT tc_statistics tc_statistics_pkey
pg_restore: dropping CONSTRAINT tc_servers tc_servers_pkey
pg_restore: dropping CONSTRAINT tc_positions tc_positions_pkey
pg_restore: dropping CONSTRAINT tc_orders tc_orders_pkey
pg_restore: dropping CONSTRAINT tc_notifications tc_notifications_pkey
pg_restore: dropping CONSTRAINT tc_maintenances tc_maintenances_pkey
pg_restore: dropping CONSTRAINT tc_keystore tc_keystore_pkey
pg_restore: dropping CONSTRAINT tc_groups tc_groups_pkey
pg_restore: dropping CONSTRAINT tc_geofences tc_geofences_pkey
pg_restore: dropping CONSTRAINT tc_events tc_events_pkey
pg_restore: dropping CONSTRAINT tc_drivers tc_drivers_uniqueid_key
pg_restore: dropping CONSTRAINT tc_drivers tc_drivers_pkey
pg_restore: dropping CONSTRAINT tc_devices tc_devices_uniqueid_key
pg_restore: dropping CONSTRAINT tc_devices tc_devices_pkey
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 3411; 2606 16447 CONSTRAINT tc_devices tc_devices_pkey traccaruser
pg_restore: error: could not execute query: ERROR: cannot drop constraint tc_devices_pkey on table public.tc_devices because other objects depend on it
DETAIL: constraint fk_commands_queue_deviceid on table public.tc_commands_queue depends on index public.tc_devices_pkey
HINT: Use DROP ... CASCADE to drop the dependent objects too.
Command was: ALTER TABLE ONLY public.tc_devices DROP CONSTRAINT tc_devices_pkey;
pg_restore: dropping CONSTRAINT tc_commands tc_commands_pkey
pg_restore: dropping CONSTRAINT tc_calendars tc_calendars_pkey
pg_restore: dropping CONSTRAINT tc_attributes tc_attributes_pkey
pg_restore: dropping CONSTRAINT databasechangeloglock databasechangeloglock_pkey
pg_restore: dropping SEQUENCE tc_users_id_seq
pg_restore: dropping TABLE tc_users
pg_restore: dropping TABLE tc_user_user
pg_restore: dropping TABLE tc_user_order
pg_restore: dropping TABLE tc_user_notification
pg_restore: dropping TABLE tc_user_maintenance
pg_restore: dropping TABLE tc_user_group
pg_restore: dropping TABLE tc_user_geofence
pg_restore: dropping TABLE tc_user_driver
pg_restore: dropping TABLE tc_user_device
pg_restore: dropping TABLE tc_user_command
pg_restore: dropping TABLE tc_user_calendar
pg_restore: dropping TABLE tc_user_attribute
pg_restore: dropping SEQUENCE tc_statistics_id_seq
pg_restore: dropping TABLE tc_statistics
pg_restore: dropping SEQUENCE tc_servers_id_seq
pg_restore: dropping TABLE tc_servers
pg_restore: dropping SEQUENCE tc_positions_id_seq
pg_restore: dropping TABLE tc_positions
pg_restore: dropping SEQUENCE tc_orders_id_seq
pg_restore: dropping TABLE tc_orders
pg_restore: dropping SEQUENCE tc_notifications_id_seq
pg_restore: dropping TABLE tc_notifications
pg_restore: dropping SEQUENCE tc_maintenances_id_seq
pg_restore: dropping TABLE tc_maintenances
pg_restore: dropping SEQUENCE tc_keystore_id_seq
pg_restore: dropping TABLE tc_keystore
pg_restore: dropping SEQUENCE tc_groups_id_seq
pg_restore: dropping TABLE tc_groups
pg_restore: dropping TABLE tc_group_order
pg_restore: dropping TABLE tc_group_notification
pg_restore: dropping TABLE tc_group_maintenance
pg_restore: dropping TABLE tc_group_geofence
pg_restore: dropping TABLE tc_group_driver
pg_restore: dropping TABLE tc_group_command
pg_restore: dropping TABLE tc_group_attribute
pg_restore: dropping SEQUENCE tc_geofences_id_seq
pg_restore: dropping TABLE tc_geofences
pg_restore: dropping SEQUENCE tc_events_id_seq
pg_restore: dropping TABLE tc_events
pg_restore: dropping SEQUENCE tc_drivers_id_seq
pg_restore: dropping TABLE tc_drivers
pg_restore: dropping SEQUENCE tc_devices_id_seq
pg_restore: dropping TABLE tc_devices
pg_restore: from TOC entry 224; 1259 16440 TABLE tc_devices traccaruser
pg_restore: error: could not execute query: ERROR: cannot drop table public.tc_devices because other objects depend on it
DETAIL: constraint fk_commands_queue_deviceid on table public.tc_commands_queue depends on table public.tc_devices
HINT: Use DROP ... CASCADE to drop the dependent objects too.
Command was: DROP TABLE public.tc_devices;
pg_restore: dropping TABLE tc_device_order
pg_restore: dropping TABLE tc_device_notification
pg_restore: dropping TABLE tc_device_maintenance
pg_restore: dropping TABLE tc_device_geofence
pg_restore: dropping TABLE tc_device_driver
pg_restore: dropping TABLE tc_device_command
pg_restore: dropping TABLE tc_device_attribute
pg_restore: dropping SEQUENCE tc_commands_id_seq
pg_restore: dropping TABLE tc_commands
pg_restore: dropping SEQUENCE tc_calendars_id_seq
pg_restore: dropping TABLE tc_calendars
pg_restore: dropping SEQUENCE tc_attributes_id_seq
pg_restore: dropping TABLE tc_attributes
pg_restore: dropping TABLE databasechangeloglock
pg_restore: dropping TABLE databasechangelog
pg_restore: creating TABLE "public.databasechangelog"
pg_restore: creating TABLE "public.databasechangeloglock"
pg_restore: creating TABLE "public.tc_attributes"
pg_restore: creating SEQUENCE "public.tc_attributes_id_seq"
pg_restore: creating TABLE "public.tc_calendars"
pg_restore: creating SEQUENCE "public.tc_calendars_id_seq"
pg_restore: creating TABLE "public.tc_commands"
pg_restore: creating SEQUENCE "public.tc_commands_id_seq"
pg_restore: creating TABLE "public.tc_device_attribute"
pg_restore: creating TABLE "public.tc_device_command"
pg_restore: creating TABLE "public.tc_device_driver"
pg_restore: creating TABLE "public.tc_device_geofence"
pg_restore: creating TABLE "public.tc_device_maintenance"
pg_restore: creating TABLE "public.tc_device_notification"
pg_restore: creating TABLE "public.tc_device_order"
pg_restore: creating TABLE "public.tc_devices"
pg_restore: error: could not execute query: ERROR: relation "tc_devices" already exists
Command was: CREATE TABLE public.tc_devices (
id integer NOT NULL,
name character varying(128) NOT NULL,
uniqueid character varying(128) NOT NULL,
lastupdate timestamp without time zone,
positionid integer,
groupid integer,
attributes character varying(4000),
phone character varying(128),
model character varying(128),
contact character varying(512),
category character varying(128),
disabled boolean DEFAULT false,
status character(8),
geofenceids character varying(128),
expirationtime timestamp without time zone
);
pg_restore: creating SEQUENCE "public.tc_devices_id_seq"
pg_restore: from TOC entry 223; 1259 16439 SEQUENCE tc_devices_id_seq traccaruser
pg_restore: error: could not execute query: ERROR: relation "tc_devices_id_seq" already exists
Command was: ALTER TABLE public.tc_devices ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.tc_devices_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
pg_restore: creating TABLE "public.tc_drivers"
pg_restore: creating SEQUENCE "public.tc_drivers_id_seq"
pg_restore: creating TABLE "public.tc_events"
pg_restore: creating SEQUENCE "public.tc_events_id_seq"
pg_restore: creating TABLE "public.tc_geofences"
pg_restore: creating SEQUENCE "public.tc_geofences_id_seq"
pg_restore: creating TABLE "public.tc_group_attribute"
pg_restore: creating TABLE "public.tc_group_command"
pg_restore: creating TABLE "public.tc_group_driver"
pg_restore: creating TABLE "public.tc_group_geofence"
pg_restore: creating TABLE "public.tc_group_maintenance"
pg_restore: creating TABLE "public.tc_group_notification"
pg_restore: creating TABLE "public.tc_group_order"
pg_restore: creating TABLE "public.tc_groups"
pg_restore: creating SEQUENCE "public.tc_groups_id_seq"
pg_restore: creating TABLE "public.tc_keystore"
pg_restore: creating SEQUENCE "public.tc_keystore_id_seq"
pg_restore: creating TABLE "public.tc_maintenances"
pg_restore: creating SEQUENCE "public.tc_maintenances_id_seq"
pg_restore: creating TABLE "public.tc_notifications"
pg_restore: creating SEQUENCE "public.tc_notifications_id_seq"
pg_restore: creating TABLE "public.tc_orders"
pg_restore: creating SEQUENCE "public.tc_orders_id_seq"
pg_restore: creating TABLE "public.tc_positions"
pg_restore: creating SEQUENCE "public.tc_positions_id_seq"
pg_restore: creating TABLE "public.tc_servers"
pg_restore: creating SEQUENCE "public.tc_servers_id_seq"
pg_restore: creating TABLE "public.tc_statistics"
pg_restore: creating SEQUENCE "public.tc_statistics_id_seq"
pg_restore: creating TABLE "public.tc_user_attribute"
pg_restore: creating TABLE "public.tc_user_calendar"
pg_restore: creating TABLE "public.tc_user_command"
pg_restore: creating TABLE "public.tc_user_device"
pg_restore: creating TABLE "public.tc_user_driver"
pg_restore: creating TABLE "public.tc_user_geofence"
pg_restore: creating TABLE "public.tc_user_group"
pg_restore: creating TABLE "public.tc_user_maintenance"
pg_restore: creating TABLE "public.tc_user_notification"
pg_restore: creating TABLE "public.tc_user_order"
pg_restore: creating TABLE "public.tc_user_user"
pg_restore: creating TABLE "public.tc_users"
pg_restore: creating SEQUENCE "public.tc_users_id_seq"
pg_restore: processing data for table "public.databasechangelog"
pg_restore: processing data for table "public.databasechangeloglock"
pg_restore: processing data for table "public.tc_attributes"
pg_restore: processing data for table "public.tc_calendars"
pg_restore: processing data for table "public.tc_commands"
pg_restore: processing data for table "public.tc_device_attribute"
pg_restore: processing data for table "public.tc_device_command"
pg_restore: processing data for table "public.tc_device_driver"
pg_restore: processing data for table "public.tc_device_geofence"
pg_restore: processing data for table "public.tc_device_maintenance"
pg_restore: processing data for table "public.tc_device_notification"
pg_restore: processing data for table "public.tc_device_order"
pg_restore: processing data for table "public.tc_devices"
pg_restore: from TOC entry 3658; 0 16440 TABLE DATA tc_devices traccaruser
pg_restore: error: COPY failed for table "tc_devices": ERROR: duplicate key value violates unique constraint "tc_devices_pkey"
DETAIL: Key (id)=(288) already exists.
CONTEXT: COPY tc_devices, line 1
pg_restore: processing data for table "public.tc_drivers"
pg_restore: processing data for table "public.tc_events"
pg_restore: processing data for table "public.tc_geofences"
pg_restore: processing data for table "public.tc_group_attribute"
pg_restore: processing data for table "public.tc_group_command"
pg_restore: processing data for table "public.tc_group_driver"
pg_restore: processing data for table "public.tc_group_geofence"
pg_restore: processing data for table "public.tc_group_maintenance"
pg_restore: processing data for table "public.tc_group_notification"
pg_restore: processing data for table "public.tc_group_order"
pg_restore: processing data for table "public.tc_groups"
pg_restore: processing data for table "public.tc_keystore"
pg_restore: processing data for table "public.tc_maintenances"
pg_restore: processing data for table "public.tc_notifications"
pg_restore: processing data for table "public.tc_orders"
pg_restore: processing data for table "public.tc_positions"
pg_restore: processing data for table "public.tc_servers"
pg_restore: processing data for table "public.tc_statistics"
pg_restore: processing data for table "public.tc_user_attribute"
pg_restore: processing data for table "public.tc_user_calendar"
pg_restore: processing data for table "public.tc_user_command"
pg_restore: processing data for table "public.tc_user_device"
pg_restore: processing data for table "public.tc_user_driver"
pg_restore: processing data for table "public.tc_user_geofence"
pg_restore: processing data for table "public.tc_user_group"
pg_restore: processing data for table "public.tc_user_maintenance"
pg_restore: processing data for table "public.tc_user_notification"
pg_restore: processing data for table "public.tc_user_order"
pg_restore: processing data for table "public.tc_user_user"
pg_restore: processing data for table "public.tc_users"
pg_restore: executing SEQUENCE SET tc_attributes_id_seq
pg_restore: executing SEQUENCE SET tc_calendars_id_seq
pg_restore: executing SEQUENCE SET tc_commands_id_seq
pg_restore: executing SEQUENCE SET tc_devices_id_seq
pg_restore: executing SEQUENCE SET tc_drivers_id_seq
pg_restore: executing SEQUENCE SET tc_events_id_seq
pg_restore: executing SEQUENCE SET tc_geofences_id_seq
pg_restore: executing SEQUENCE SET tc_groups_id_seq
pg_restore: executing SEQUENCE SET tc_keystore_id_seq
pg_restore: executing SEQUENCE SET tc_maintenances_id_seq
pg_restore: executing SEQUENCE SET tc_notifications_id_seq
pg_restore: executing SEQUENCE SET tc_orders_id_seq
pg_restore: executing SEQUENCE SET tc_positions_id_seq
pg_restore: executing SEQUENCE SET tc_servers_id_seq
pg_restore: executing SEQUENCE SET tc_statistics_id_seq
pg_restore: executing SEQUENCE SET tc_users_id_seq
pg_restore: creating CONSTRAINT "public.databasechangeloglock databasechangeloglock_pkey"
pg_restore: creating CONSTRAINT "public.tc_attributes tc_attributes_pkey"
pg_restore: creating CONSTRAINT "public.tc_calendars tc_calendars_pkey"
pg_restore: creating CONSTRAINT "public.tc_commands tc_commands_pkey"
pg_restore: creating CONSTRAINT "public.tc_devices tc_devices_pkey"
pg_restore: from TOC entry 3411; 2606 16447 CONSTRAINT tc_devices tc_devices_pkey traccaruser
pg_restore: error: could not execute query: ERROR: multiple primary keys for table "tc_devices" are not allowed
Command was: ALTER TABLE ONLY public.tc_devices
ADD CONSTRAINT tc_devices_pkey PRIMARY KEY (id);
pg_restore: creating CONSTRAINT "public.tc_devices tc_devices_uniqueid_key"
pg_restore: creating CONSTRAINT "public.tc_drivers tc_drivers_pkey"
pg_restore: creating CONSTRAINT "public.tc_drivers tc_drivers_uniqueid_key"
pg_restore: creating CONSTRAINT "public.tc_events tc_events_pkey"
pg_restore: creating CONSTRAINT "public.tc_geofences tc_geofences_pkey"
pg_restore: creating CONSTRAINT "public.tc_groups tc_groups_pkey"
pg_restore: creating CONSTRAINT "public.tc_keystore tc_keystore_pkey"
pg_restore: creating CONSTRAINT "public.tc_maintenances tc_maintenances_pkey"
pg_restore: creating CONSTRAINT "public.tc_notifications tc_notifications_pkey"
pg_restore: creating CONSTRAINT "public.tc_orders tc_orders_pkey"
pg_restore: creating CONSTRAINT "public.tc_positions tc_positions_pkey"
pg_restore: creating CONSTRAINT "public.tc_servers tc_servers_pkey"
pg_restore: creating CONSTRAINT "public.tc_statistics tc_statistics_pkey"
pg_restore: creating CONSTRAINT "public.tc_users tc_users_email_key"
pg_restore: creating CONSTRAINT "public.tc_users tc_users_pkey"
pg_restore: creating INDEX "public.event_deviceid_servertime"
pg_restore: creating INDEX "public.idx_devices_uniqueid"
pg_restore: creating INDEX "public.idx_drivers_uniqueid"
pg_restore: creating INDEX "public.idx_users_email"
pg_restore: creating INDEX "public.idx_users_login"
pg_restore: creating INDEX "public.position_deviceid_fixtime"
pg_restore: creating INDEX "public.user_device_user_id"
pg_restore: creating FK CONSTRAINT "public.tc_device_command fk_device_command_commandid"
pg_restore: creating FK CONSTRAINT "public.tc_device_command fk_device_command_deviceid"
pg_restore: from TOC entry 3451; 2606 16620 FK CONSTRAINT tc_device_command fk_device_command_deviceid traccaruser
pg_restore: error: could not execute query: ERROR: insert or update on table "tc_device_command" violates foreign key constraint "fk_device_command_deviceid"
DETAIL: Key (deviceid)=(31) is not present in table "tc_devices".
Command was: ALTER TABLE ONLY public.tc_device_command
ADD CONSTRAINT fk_device_command_deviceid FOREIGN KEY (deviceid) REFERENCES public.tc_devices(id) ON DELETE CASCADE;
pg_restore: creating FK CONSTRAINT "public.tc_device_driver fk_device_driver_deviceid"
pg_restore: creating FK CONSTRAINT "public.tc_device_driver fk_device_driver_driverid"
pg_restore: creating FK CONSTRAINT "public.tc_device_geofence fk_device_geofence_deviceid"
pg_restore: from TOC entry 3454; 2606 16635 FK CONSTRAINT tc_device_geofence fk_device_geofence_deviceid traccaruser
pg_restore: error: could not execute query: ERROR: insert or update on table "tc_device_geofence" violates foreign key constraint "fk_device_geofence_deviceid"
DETAIL: Key (deviceid)=(75) is not present in table "tc_devices".
Command was: ALTER TABLE ONLY public.tc_device_geofence
ADD CONSTRAINT fk_device_geofence_deviceid FOREIGN KEY (deviceid) REFERENCES public.tc_devices(id) ON DELETE CASCADE;
pg_restore: creating FK CONSTRAINT "public.tc_device_geofence fk_device_geofence_geofenceid"
pg_restore: creating FK CONSTRAINT "public.tc_device_maintenance fk_device_maintenance_deviceid"
pg_restore: creating FK CONSTRAINT "public.tc_device_maintenance fk_device_maintenance_maintenanceid"
pg_restore: creating FK CONSTRAINT "public.tc_device_notification fk_device_notification_deviceid"
pg_restore: creating FK CONSTRAINT "public.tc_device_notification fk_device_notification_notificationid"
pg_restore: creating FK CONSTRAINT "public.tc_device_order fk_device_order_deviceid"
pg_restore: creating FK CONSTRAINT "public.tc_device_order fk_device_order_orderid"
pg_restore: creating FK CONSTRAINT "public.tc_devices fk_devices_groupid"
pg_restore: creating FK CONSTRAINT "public.tc_events fk_events_deviceid"
pg_restore: from TOC entry 3461; 2606 16670 FK CONSTRAINT tc_events fk_events_deviceid traccaruser
pg_restore: error: could not execute query: ERROR: insert or update on table "tc_events" violates foreign key constraint "fk_events_deviceid"
DETAIL: Key (deviceid)=(42) is not present in table "tc_devices".
Command was: ALTER TABLE ONLY public.tc_events
ADD CONSTRAINT fk_events_deviceid FOREIGN KEY (deviceid) REFERENCES public.tc_devices(id) ON DELETE CASCADE;
pg_restore: creating FK CONSTRAINT "public.tc_geofences fk_geofence_calendar_calendarid"
pg_restore: creating FK CONSTRAINT "public.tc_group_attribute fk_group_attribute_attributeid"
pg_restore: creating FK CONSTRAINT "public.tc_group_attribute fk_group_attribute_groupid"
pg_restore: creating FK CONSTRAINT "public.tc_group_command fk_group_command_commandid"
pg_restore: creating FK CONSTRAINT "public.tc_group_command fk_group_command_groupid"
pg_restore: creating FK CONSTRAINT "public.tc_group_driver fk_group_driver_driverid"
pg_restore: creating FK CONSTRAINT "public.tc_group_driver fk_group_driver_groupid"
pg_restore: creating FK CONSTRAINT "public.tc_group_geofence fk_group_geofence_geofenceid"
pg_restore: creating FK CONSTRAINT "public.tc_group_geofence fk_group_geofence_groupid"
pg_restore: creating FK CONSTRAINT "public.tc_group_maintenance fk_group_maintenance_groupid"
pg_restore: creating FK CONSTRAINT "public.tc_group_maintenance fk_group_maintenance_maintenanceid"
pg_restore: creating FK CONSTRAINT "public.tc_group_notification fk_group_notification_groupid"
pg_restore: creating FK CONSTRAINT "public.tc_group_notification fk_group_notification_notificationid"
pg_restore: creating FK CONSTRAINT "public.tc_group_order fk_group_order_groupid"
pg_restore: creating FK CONSTRAINT "public.tc_group_order fk_group_order_orderid"
pg_restore: creating FK CONSTRAINT "public.tc_groups fk_groups_groupid"
pg_restore: creating FK CONSTRAINT "public.tc_notifications fk_notification_calendar_calendarid"
pg_restore: creating FK CONSTRAINT "public.tc_positions fk_positions_deviceid"
pg_restore: from TOC entry 3477; 2606 16745 FK CONSTRAINT tc_positions fk_positions_deviceid traccaruser
pg_restore: error: could not execute query: ERROR: insert or update on table "tc_positions" violates foreign key constraint "fk_positions_deviceid"
DETAIL: Key (deviceid)=(34) is not present in table "tc_devices".
Command was: ALTER TABLE ONLY public.tc_positions
ADD CONSTRAINT fk_positions_deviceid FOREIGN KEY (deviceid) REFERENCES public.tc_devices(id) ON DELETE CASCADE;
pg_restore: creating FK CONSTRAINT "public.tc_user_attribute fk_user_attribute_attributeid"
pg_restore: creating FK CONSTRAINT "public.tc_user_attribute fk_user_attribute_userid"
pg_restore: creating FK CONSTRAINT "public.tc_user_calendar fk_user_calendar_calendarid"
pg_restore: creating FK CONSTRAINT "public.tc_user_calendar fk_user_calendar_userid"
pg_restore: creating FK CONSTRAINT "public.tc_user_command fk_user_command_commandid"
pg_restore: creating FK CONSTRAINT "public.tc_user_command fk_user_command_userid"
pg_restore: creating FK CONSTRAINT "public.tc_device_attribute fk_user_device_attribute_attributeid"
pg_restore: creating FK CONSTRAINT "public.tc_device_attribute fk_user_device_attribute_deviceid"
pg_restore: creating FK CONSTRAINT "public.tc_user_device fk_user_device_deviceid"
pg_restore: from TOC entry 3484; 2606 16790 FK CONSTRAINT tc_user_device fk_user_device_deviceid traccaruser
pg_restore: error: could not execute query: ERROR: insert or update on table "tc_user_device" violates foreign key constraint "fk_user_device_deviceid"
DETAIL: Key (deviceid)=(58) is not present in table "tc_devices".
Command was: ALTER TABLE ONLY public.tc_user_device
ADD CONSTRAINT fk_user_device_deviceid FOREIGN KEY (deviceid) REFERENCES public.tc_devices(id) ON DELETE CASCADE;
pg_restore: creating FK CONSTRAINT "public.tc_user_device fk_user_device_userid"
pg_restore: creating FK CONSTRAINT "public.tc_user_driver fk_user_driver_driverid"
pg_restore: creating FK CONSTRAINT "public.tc_user_driver fk_user_driver_userid"
pg_restore: creating FK CONSTRAINT "public.tc_user_geofence fk_user_geofence_geofenceid"
pg_restore: creating FK CONSTRAINT "public.tc_user_geofence fk_user_geofence_userid"
pg_restore: creating FK CONSTRAINT "public.tc_user_group fk_user_group_groupid"
pg_restore: creating FK CONSTRAINT "public.tc_user_group fk_user_group_userid"
pg_restore: creating FK CONSTRAINT "public.tc_user_maintenance fk_user_maintenance_maintenanceid"
pg_restore: creating FK CONSTRAINT "public.tc_user_maintenance fk_user_maintenance_userid"
pg_restore: creating FK CONSTRAINT "public.tc_user_notification fk_user_notification_notificationid"
pg_restore: creating FK CONSTRAINT "public.tc_user_notification fk_user_notification_userid"
pg_restore: creating FK CONSTRAINT "public.tc_user_order fk_user_order_orderid"
pg_restore: creating FK CONSTRAINT "public.tc_user_order fk_user_order_userid"
pg_restore: creating FK CONSTRAINT "public.tc_user_user fk_user_user_manageduserid"
pg_restore: creating FK CONSTRAINT "public.tc_user_user fk_user_user_userid"
pg_restore: warning: errors ignored on restore: 11
Anton Tananaev2 years ago

It could be restoring it in the wrong order or maybe you just have issues in the backup.

Key (deviceid)=(58) is not present in table "tc_devices".