Restore share link - is it possible?

Hello,

I made a bone-headed move and removed a folder from my nextcloud that was being used to secure drop files. We had the hyperlink in our instruction guide for uploaded that we sent out to everyone that would upload files there.

Is there a way to restore that specific folder link? I tried to reupload the folder with the same name but it’s generating a new link. Am I pooched here?

Thanks!

Why not just set up a redirect on your server? You don’t need the old link to work again, just make it redirect to the new one.

For Apache:

Redirect 301 /OLD_SHARING_LINK https://NEXTCLOUD_SERVER.TLD/NEW_SHARING_LINK

For Nginx:

location /OLD_SHARING_LINK {
  return 301 https://NEXTCLOUD_SERVER.TLD/NEW_SHARING_LINK;
}
2 Likes

You’re a prince amongst men!

Hi Tom

I have installed new version of nextcloud and lost all the shared files, which I had to upload them again. Now the sharing links of previous shared files are not working any more, of course.

I have find your solution, but as my knowledge of nextcloud is poor, I would like to know, where I must put this line: Redirect 301 /OLD_SHARING_LINK https://NEXTCLOUD_SERVER.TLD/NEW_SHARING_LINK?

Where can I find old sharing links?

Regards

Mitja

I have installed new version of nextcloud and lost all the shared files, which I had to upload them again.

Hi Mitja, an upgrade should not cause data loss so that’s the first thing to troubleshoot. However if you re-installed instead of upgrading, then yes the data is lost because you installed it over the prior install.

I would like to know, where I must put this line: Redirect 301 /OLD_SHARING_LINK https://NEXTCLOUD_SERVER.TLD/NEW_SHARING_LINK?

The examples I supplied go on your server config. For Apache, it is the VirtualHost file for your site (probably in /etc/apache2/ somewhere). For Nginx it’s in the server block for your website. If it’s your server you should refer to the web server documentation and if you are using shared hosting try opening a support ticket with the hosting provider.

Where can I find old sharing links?

Those links were stored in Nextcloud’s database. If you upgraded they’re still there and should work. If you re-installed then that data is lost.

I don’t use Nextcloud any more so I’m afraid I have no further advice, but your best bet is to focus on what happened when you “installed new version of nextcloud and lost all the shared files”, because that’s what you need to undo. Something went wrong and when you discover what that was, the way forward will become clear. Good luck.

1 Like

It’s super simple and quick: You just create a new link, then you login to MySQL databases and in table named oc_shares (or some XX_shares) the link ending (suffix) is in the “token” column". So you find your new link token, and you change it’s “token” value to your old link token, and now your old link points to the new link :slight_smile:

1 Like

it is even simpler and quicker wit Configurable Share Links (cfg_share_links)

After you installed that app, you can edit any share link, give them human readable names or - as required in this case - tokens from old nextcloud instances, to “revive” those links.

Also you can use the app ShareRenamer.

Hello,

It appears that ShareRenamer is no longer in use and is not compatible with Nextcloud 27.

Do you know if it is possible to transfer or retrieve all the links created with ShareRenamer to Configurable Share Links?

I think it is not possible. But to minimize the effort you can dump your e.g. MariaDB and search the links (maybe you find them).

Instead of the app Configurable Share Links you also can use 301/302-redirects in .htaccess on a normal webserver to the normal Nextcloud shares. I use this with the small disadvantage that i have to make changes to links not in Nextcloud but on the further web server.

<AFAIK>
It doesn’t matter which tool you used to create or manipulate the link name. The name of the link is stored “as is” in the oc_share table. It should be irrelevant whether the tool with which the link was manipulated or renamed is still installed or not.
</AFAIK>

Much luck,
ernolf

Nice, thank you. It’s good to be aware of that.