Issue after migration

I have a problem with duplicate key after doing a migration.
I used rsync as per backup section in manual to move my data folder from one server to the new one. I successfully imported my data base. Then things got a bit off the rails because I needed to upgrade. occ upgrade seemed to work but scan files made a error.
I tried logging in and only the file app is making a folder permission denied error for the home page. It is occurring for the first user and many others are working fine. the other apps like dashboard and talk work. I decided I would perhaps migrate the folders to a new user. I did one folder but now the new user has the same problem.

the database log shows this

nextcloud@nextcloud ERROR:  duplicate key value violates unique constraint "fs_storage_path_hash"
2023-01-12 19:03:26.814 EST [59676] nextcloud@nextcloud DETAIL:  Key (storage, path_hash)=(32, 5c0b53e8586b4daf42cf5dd5ef4c6caf) already exists.
2023-01-12 19:03:26.814 EST [59676] nextcloud@nextcloud STATEMENT:  INSERT INTO "oc_filecache" ("mimepart", "mimetype", "mtime", "size", "etag", "storage_mtime", "permissions", "name", "parent", "checksum", "path_hash", "path", "storage") VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)

but when I try to see the duplicate I get this

postgres=# \c nextcloud;
You are now connected to database "nextcloud" as user "postgres".
nextcloud=# SELECT storage, path_hash FROM oc_filecache WHERE path_hash = '5c0b53e8586b4daf42cf5dd5ef4c6caf';
 storage | path_hash 
(0 rows)

Any Ideas on how to fix this problem?

Hi, did you follow all-in-one/ at main · nextcloud/all-in-one · GitHub for the migration to AIO?

In the migration docs is also explicitely stated that the Nextcloud version from which you are migrating and the Nextcloud version of AIO need to match which was obviously not the case here because updating would not have been necessary in that case.

1 Like

Thank you for the advise. I did install into a LXC container,
this then made issues so that the occ would not run.
I then installed in Debian container to migrate to.

I am thinking in my case migrating files only after adding matching users to a new install may be the best choice.

Can anyone share if any important data are lost when not migrating database?

So you did not use the built-in backup solution to migrate your data? This would have made migrating from AIO to another AIO much easier or am I misunderstanding something?

I did not install the AIO,
I used the zip file, I did not use the tool you mention.
I used these instructions

Ah I see. Then let me adjust your post.

Ticket Closed this is how I fixed it.
On a hunch I ran

sudo -u www-data php /var/www/nextcloud/occ groupfolders:scan 5

on all my group folders. just one threw up the error.
Then I removed this group from all the users that had it.

now all the scans ran successfully.
then I added the group back to my users.

Success! is sweet.

What kind of error did you get?

Seeing the same thing with one of our installations.
A post I saw a while back mentioned this was because of a CTRL-C being used during a OCC Scan. Did you do a occ scan and stopped it?

2023-11-21 09:24:30.976163+00:002023-11-21 09:24:30.976 UTC [695560] ERROR: duplicate key value violates unique constraint “fs_storage_path_hash”
2023-11-21 09:24:30.976216+00:002023-11-21 09:24:30.976 UTC [695560] DETAIL: Key (storage, path_hash)=(25, c8b7cae19100f962f3498414eedb171f) already exists.
2023-11-21 09:24:30.976238+00:002023-11-21 09:24:30.976 UTC [695560] STATEMENT: INSERT INTO “oc_filecache” (“mimepart”, “mimetype”, “mtime”, “size”, “etag”, “storage_mtime”, “permissions”, “name”, “parent”, “checksum”, “path_hash”, “path”, “storage”) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)

I do not recall that I stopped a manual scan.

However I do know that this scan runs regular and could have been interrupted by out of memory or possibly a ungraceful shutdown.

run the scan manually on each folder to see where the problem is.