Restore shares from backup database

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Hello,

Nextcloud version (eg, 20.0.5): 27.1.6.2
Operating system and version (eg, Ubuntu 20.04): Debian 12
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.57-2
PHP version (eg, 7.4): 8.2-fpm

The issue you are facing:

Last monday we lost a big series of share in our nextcloud, I don’t know why we lost them.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

In database oc_share restoration : 1469 rows
In database oc_share in prod : 787 rows

I try to restore the oc_share table from backup but share don’t seems to appear when I try to list them with sharing:list occ command. But I have all raw in oc_share table.

There is a solution to restore shares ?

Regards

In the table, you have item_source and item_target, if the target or source were changed or removed, it could explain why the shares were removed and perhaps why restoring just the shares does not work like this.

For me, the item_source is and object that is also in the filecache table, is that the case for you as well?

If I were you, I’d set up a small test instance and check how the sharing works, what tables are changed when you add one share. Or if you had very little changes since the last time, just make a complete restore of the old backup.

If you want to recreate shares the official way, you could also use the API:
https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-share-api.html