# Export all share for migration

**URL:** <https://help.nextcloud.com/t/export-all-share-for-migration/178179>\
**Category:** ℹ️ Support\
**Tags:** server\_migration, user-migration-app, sharelisting-app\
**Created:** [January 4, 2024, 9:07am UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179 "2024-01-04T09:07:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aukfood85](https://help.nextcloud.com/letter_avatar/aukfood85/32/6_22734026db12803ebb3e059622ac3534.png) [@Aukfood85](https://help.nextcloud.com/u/Aukfood85)\
**Post date:** [January 4, 2024, 9:07am UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179/1 "2024-01-04T09:07:06Z")

</div>

Hello,

I search an idea for exporting share from a Nextcloud to import them in another Nextcloud.

For now I have a sql request like that to export share initialised by an admin user

```auto
select share_type,share_with,password,uid_owner,uid_initiator,item_type,item_source,item_target,file_source,file_target,permissions,accepted,expiration,token,note,hide_download,password_expiration_time from nextcloud.oc_share where uid_initiator='admin'

```

Does someone have a better idea ? A script to do that ?

Best regards

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [January 4, 2024, 11:53am UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179/2 "2024-01-04T11:53:59Z")

</div>

Usually you want to migrate not only the share information but all server data as well:

[https://docs.nextcloud.com/server/latest/admin\_manual/maintenance/migrating.html#migrating-to-a-different-server](https://docs.nextcloud.com/server/latest/admin_manual/maintenance/migrating.html#migrating-to-a-different-server)

If you really only want to migrate share URLs I think your query will export everybody shares once you remove `where uid_initiator='admin'` from the SQL statement… You can use [Configurable Share Links](https://apps.nextcloud.com/apps/cfg_share_links) app on the new instance to re-create shares using old links.

---

<div class="post-metadata">

**Author:** ![Aukfood85](https://help.nextcloud.com/letter_avatar/aukfood85/32/6_22734026db12803ebb3e059622ac3534.png) [@Aukfood85](https://help.nextcloud.com/u/Aukfood85)\
**Post date:** [January 4, 2024, 12:49pm UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179/3 "2024-01-04T12:49:38Z")

</div>

@wwe I have to consolidate two Nextcloud in a new one, so I have to export all share for all users in the two nextcloud and change user mapping (bad ad mapping) and integrate them in a new installation.

With occ i can export groupfolders list but not classic share

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [January 4, 2024, 3:55pm UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179/4 "2024-01-04T15:55:45Z")

</div>

interesting challenge! if you are looking for internal shares as well I think it will be pretty hard to migrate them. may be the easier approach would be to migrate the data of individual users to the new instance using [user migration](https://apps.nextcloud.com/apps/user_migration) app and then setup all required internal shares from scratch. maybe worth to look through #user-migration-app topics - maybe you can find useful hints.

UPDATE: I’m wondering you are aware of official `occ sharing:list` command which lists all the shares in the system? (likely the same you get with a SQL query above)

```auto
    {
        "id": "140",
        "file_id": 4305614,
        "owner": "user1",
        "initiator": "user1",
        "time": "2023-05-04T14:36:26+00:00",
        "permissions": 17,
        "path": "\/Fotos\/cat",
        "name": "cat",
        "is_directory": true,
        "type": "email",
        "recipient": "share.recipient@some.domain",
        "token": "M76d6HnMjQsdfasdf"
    },

```

---

<div class="post-metadata">

**Author:** ![Aukfood85](https://help.nextcloud.com/letter_avatar/aukfood85/32/6_22734026db12803ebb3e059622ac3534.png) [@Aukfood85](https://help.nextcloud.com/u/Aukfood85)\
**Post date:** [January 4, 2024, 5:05pm UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179/5 "2024-01-04T17:05:09Z")

</div>

@wwe I haven’t got this command sharing:list

```auto
 php occ sharing

                                       
  Command "sharing" is not defined.    
                                       
  Did you mean one of these?           
      sharing:cleanup-remote-storages  
      sharing:expiration-notification  

```

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [January 4, 2024, 8:42pm UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179/6 "2024-01-04T20:42:35Z")

</div>

> [@Aukfood85](#):
>
> I haven’t got this command sharing:list

I have to admit the hint was misleading 🙊  
the command comes from the app [Share listing](https://apps.nextcloud.com/apps/sharelisting) + [Share listing Github](https://github.com/nextcloud/sharelisting) ! not official but worth installing.

---

<div class="post-metadata">

**Author:** ![Aukfood85](https://help.nextcloud.com/letter_avatar/aukfood85/32/6_22734026db12803ebb3e059622ac3534.png) [@Aukfood85](https://help.nextcloud.com/u/Aukfood85)\
**Post date:** [January 5, 2024, 12:30pm UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179/7 "2024-01-05T12:30:16Z")

</div>

Ok very good I didn’t know this app. So It’s interesting for exporting share but after i can’t recreate them on another nextcloud unless there is an application like sharing:import ?

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [January 5, 2024, 3:20pm UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179/8 "2024-01-05T15:20:34Z")

</div>

I don’t think there is general way to import/re-create shares on another system - too many moving parts, user id might change, files and folders have another IDs - mission impossible I would say.

---

<div class="post-metadata">

**Author:** ![Aukfood85](https://help.nextcloud.com/letter_avatar/aukfood85/32/6_22734026db12803ebb3e059622ac3534.png) [@Aukfood85](https://help.nextcloud.com/u/Aukfood85)\
**Post date:** [January 9, 2024, 8:17am UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179/9 "2024-01-09T08:17:34Z")

</div>

@wwe you know where file and directory id are stored ?

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [January 9, 2024, 9:18pm UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179/10 "2024-01-09T21:18:35Z")

</div>

I’m not ware of any official documentation of DB structure. we had pretty comprehensive reverse engineering of the DB in this thread [Desktop client 3.4.0 destroys local time stamp and keeps uploading data to server](https://help.nextcloud.com/t/desktop-client-3-4-0-destroys-local-time-stamp-and-keeps-uploading-data-to-server/128512) maybe this is the best source I have handy…

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [October 17, 2024, 11:19am UTC](https://help.nextcloud.com/t/export-all-share-for-migration/178179/11 "2024-10-17T11:19:36Z")

</div>


