Failed update on NS7.9 to NS8 migrated NextCloud

OK, I figured out how to export all the external storage information for all accounts and can see the incorrect IP address for each of the users.

occ files_external:export -a

I’m not sure how to get this into a file that can be edited and then reimported. I haven’t found a was to export to a file or what file type would be needed.

Assuming this would work, I am guessing I would need to edit the exported file and then import/overwrite the existing file and finally reboot the NextCloud container. Does that make sense?

While I know there is an occ command to delete a share and add a share, I don’t want to run the risk of deleting and in doing so delete all the user files on samba file server.

I could reproduce. It works when you login as Nextcloud admin but it doesn’t work when logged in as Domain user, even if she has admin rights…could be a bug.

I think the best way to map user home shares is to add them to the personal external storage of the user.

AFAIK it just removes the share from Nextcloud without deleting the data in the samba share.

EDIT:

Yes, I think it works without restart of Nextcloud when done via occ files_external:import

@mrmarkuz , where would I find out what format the file should be to be imported. I can’t find that anywhere. I suppose it might be text but importing an edited file with the wrong format could be a catastrophe.

It’s a json file (like the export), see also Using the occ command — Nextcloud latest Administration Manual latest documentation

To export to a file export.json:

occ files_external:export -a > export.json

Copy the file somewhere to have a backup.

Edit the file to your needs.

Copy the export.json to the nextcloud-app container:

podman cp export.json nextcloud-app:/

Import:

occ files_external:import /export.json

The import doesn’t overwrite shares, so you need to disconnect them first.

1 Like

Thanks again for the help and detailed reply.

When you say, you need to disconnect them first do you mean that the shares have to be manually removed in the Admin and User settings before importing?

If yes, I’m thinking I have to turn on maintenance mode. Delete all the shares vis occ files_external:delete each share for each user. Once all the shares are deleted, I can import the updated export.json file. After the import has finished, turn off maintenance mode and restart the container.

Does that make sense?

Yes, the occ import can’t import already existing shares.

Yes, just keep the original export.json as backup in case the updated one doesn’t work.
I don’t know if maintenance mode is really needed for that change, it’s used for backups or updates, see also Backup — Nextcloud latest Administration Manual latest documentation

Update for this evening.

I exported the json file of the external mounts and modified the file by removing the Home mount for each of the users. I edited the file in place to delete the user mounts and saved the modified import file as import_user.json. This file is found at:

# runagent -m nextcloud2
runagent: [INFO] starting bash -l
runagent: [INFO] working directory: /home1/nextcloud2/.config/state

$ ls -la
total 84
drwxr-xr-x 1 nextcloud2 nextcloud2   370 Apr  1 20:28 .
drwxr-xr-x 1 nextcloud2 nextcloud2   194 Mar 28 22:19 ..
-rw-r--r-- 1 nextcloud2 nextcloud2   103 Mar 27 06:58 CACHEDIR.TAG
-rw------- 1 nextcloud2 nextcloud2   286 Mar 28 20:51 agent.env
-rw------- 1 nextcloud2 nextcloud2   215 Mar 28 21:32 apitoken.cache
-rw-r--r-- 1 nextcloud2 nextcloud2   401 Mar 28 22:50 config.env
-rw-r--r-- 1 nextcloud2 nextcloud2   146 Mar 28 22:50 config.json
-rw-r--r-- 1 nextcloud2 nextcloud2   163 Mar 28 22:50 database.env
-rw-r--r-- 1 nextcloud2 nextcloud2  1421 Mar 29 17:36 environment
-rw-rw-r-- 1 nextcloud2 nextcloud2 10233 Apr  1 20:05 export.json
-rw-rw-r-- 1 nextcloud2 nextcloud2 10233 Apr  1 20:11 export.json.bak
**-rw-rw-r-- 1 nextcloud2 nextcloud2  8353 Apr  1 20:27 import_user.json**
-rw-r--r-- 1 nextcloud2 nextcloud2  8895 Mar 29 17:36 nginx.conf
-rw-r--r-- 1 nextcloud2 nextcloud2   173 Apr  1 19:56 notify_push.env
drwxr-xr-x 1 nextcloud2 nextcloud2     0 Mar 28 21:34 restore
-rw-r--r-- 1 nextcloud2 nextcloud2     0 Apr  1 19:55 smarthost.env
-rw-r--r-- 1 nextcloud2 nextcloud2   106 Mar 29 17:36 zzz_nethserver.conf

Then I delete the user mounts using occ files_external:delete <mount id> for each of the users mount ids. The mount ids are listed in the export.json.

I also updated to the samba NS8 IP address because that is why these user mount couldn’t find the samba mount after the migration. The user mount was still looking for the NS7 samba file server IP address.

I logged into the GUI and checked that the user mounts are gone. OK so far

So now to import the modified user mounts from import_user.json.

occ files_external:import import_user.json

File not found: import_user.json

Also tried

$ occ files_external:import ./import_user.json
[nextcloud][no app in context][0] {"reqId":"fzrZZkqyoHhpZ65xAHbF","level":0,"time":"2025-04-02T01:30:57+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"{\"Exception\":\"RuntimeException\",\"Message\":\"ignorable excep....
...
File not found: import_user.json

$ occ files_external:import <import_user.json
[nextcloud][no app in context][0] {"reqId":"rA2LgFRRJP8Ph0eg6QiX","level":0,"time":"2025-04-02T00:05:25+00:00","remoteAddr":"","user ...
[
    {   "mount_id": 2,
        "mount_point": "\/Home",
        "storage": "\\OCA\\Files_External\\Lib\\Storage\\SMB",
        "authentication_type": "password::password",
        "configuration": {
            "host": "192.168.1.20",
            "share": "user",
            "root": "",
            "domain": "DOMAIN",
            "show_hidden": true,
            "check_acl": false,
            "timeout": "",
            "user": "user",
            "password": "PASS[nextcloud ....

**Not enough arguments (missing: "path").**

files_external:import [--user [USER]] [--dry] [--output [OUTPUT]] [--] <path>

It seems that it needs the “<” to import but appears to not accept the relative path. This isn’t in the documentation or in any Google searches other than many instance of people trying to import the config.json but not finding the file.

I also tried this:

# runagent -m nextcloud2 occ files_external:import ./import_user.json
File not found: ./import_user.json

I tried the different variations and only the < import_user.json works but then I get the error

**Not enough arguments (missing: "path").**

I’m not sure what to try next or what to search on to figure this out.
I appreciate any suggestions.
Thanks!

You need to copy the file to the container root using podman cp so occ is able to import it like

occ files_external:import /export.json

Thanks @mrmarkuz .

I’m still confused as to how these containers are structured but your help gives me a direction to look. Thanks for all your help.

I’m getting a error that is a bit cryptic for me. Error while parsing json

I’m assuming that somehow I messed up the formatting in the json file, but the error message isn’t particularly helpful.

What is all this info [nextcloud] [no app in context] [0] ... about? Is this verbose debug code? Similar info is found at at the top of the files_export:export json file. Is this supposed to be inside the import_user.json or is this just the debug code that is spit out?

Here is the full error message in case it is helpful.

$ occ files_external:import /import_user.json
[nextcloud][no app in context][0] {"reqId":"iMr7T9kVJrLNSFAypVTh","level":0,"time":"2025-04-02T13:01:20+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"{\"Exception\":\"RuntimeException\",\"Message\":\"ignorable exception\",\"Code\":0,\"Trace\":[{\"file\":\"/var/www/html/lib/private/AppConfig.php\",\"line\":1180,\"function\":\"loadConfig\",\"class\":\"OC\\\\AppConfig\",\"type\":\"->\",\"args\":[null]},{\"file\":\"/var/www/html/lib/private/AppConfig.php\",\"line\":100,\"function\":\"loadConfigAll\",\"class\":\"OC\\\\AppConfig\",\"type\":\"->\",\"args\":[]},{\"file\":\"/var/www/html/lib/private/AllConfig.php\",\"line\":169,\"function\":\"getKeys\",\"class\":\"OC\\\\AppConfig\",\"type\":\"->\",\"args\":[\"user_ldap\"]},{\"file\":\"/var/www/html/apps/user_ldap/lib/Helper.php\",\"line\":111,\"function\":\"getAppKeys\",\"class\":\"OC\\\\AllConfig\",\"type\":\"->\",\"args\":[\"user_ldap\"]},{\"file\":\"/var/www/html/apps/user_ldap/lib/Helper.php\",\"line\":52,\"function\":\"getServersConfig\",\"class\":\"OCA\\\\User_LDAP\\\\Helper\",\"type\":\"->\",\"args\":[\"ldap_configuration_active\"]},{\"file\":\"/var/www/html/apps/user_ldap/lib/AppInfo/Application.php\",\"line\":114,\"function\":\"getServerConfigurationPrefixes\",\"class\":\"OCA\\\\User_LDAP\\\\Helper\",\"type\":\"->\",\"args\":[true]},{\"file\":\"/var/www/html/lib/private/AppFramework/Bootstrap/FunctionInjector.php\",\"line\":28,\"function\":\"OCA\\\\User_LDAP\\\\AppInfo\\\\{closure}\",\"class\":\"OCA\\\\User_LDAP\\\\AppInfo\\\\Application\",\"type\":\"->\",\"args\":[\"*** sensitive parameters replaced ***\"]},{\"file\":\"/var/www/html/lib/private/AppFramework/Bootstrap/BootContext.php\",\"line\":32,\"function\":\"injectFn\",\"class\":\"OC\\\\AppFramework\\\\Bootstrap\\\\FunctionInjector\",\"type\":\"->\",\"args\":[{\"__class__\":\"Closure\"}]},{\"file\":\"/var/www/html/apps/user_ldap/lib/AppInfo/Application.php\",\"line\":105,\"function\":\"injectFn\",\"class\":\"OC\\\\AppFramework\\\\Bootstrap\\\\BootContext\",\"type\":\"->\",\"args\":[{\"__class__\":\"Closure\"}]},{\"file\":\"/var/www/html/lib/private/AppFramework/Bootstrap/Coordinator.php\",\"line\":157,\"function\":\"boot\",\"class\":\"OCA\\\\User_LDAP\\\\AppInfo\\\\Application\",\"type\":\"->\",\"args\":[{\"__class__\":\"OC\\\\AppFramework\\\\Bootstrap\\\\BootContext\"}]},{\"file\":\"/var/www/html/lib/private/App/AppManager.php\",\"line\":434,\"function\":\"bootApp\",\"class\":\"OC\\\\AppFramework\\\\Bootstrap\\\\Coordinator\",\"type\":\"->\",\"args\":[\"user_ldap\"]},{\"file\":\"/var/www/html/lib/private/App/AppManager.php\",\"line\":211,\"function\":\"loadApp\",\"class\":\"OC\\\\App\\\\AppManager\",\"type\":\"->\",\"args\":[\"user_ldap\"]},{\"file\":\"/var/www/html/lib/private/Console/Application.php\",\"line\":84,\"function\":\"loadApps\",\"class\":\"OC\\\\App\\\\AppManager\",\"type\":\"->\",\"args\":[]},{\"file\":\"/var/www/html/console.php\",\"line\":81,\"function\":\"loadCommands\",\"class\":\"OC\\\\Console\\\\Application\",\"type\":\"->\",\"args\":[{\"__class__\":\"Symfony\\\\Component\\\\Console\\\\Input\\\\ArgvInput\"},{\"__class__\":\"Symfony\\\\Component\\\\Console\\\\Output\\\\ConsoleOutput\"}]},{\"file\":\"/var/www/html/occ\",\"line\":33,\"args\":[\"/var/www/html/console.php\"],\"function\":\"require_once\"}],\"File\":\"/var/www/html/lib/private/AppConfig.php\",\"Line\":1194,\"message\":\"The loading of lazy AppConfig values have been requested\",\"exception\":{},\"CustomMessage\":\"The loading of lazy AppConfig values have been requested\"}","userAgent":"--","version":"30.0.7.2"}
Error while parsing json

Thanks!

Maybe it helps to check the json for errors here: https://jsonlint.com/

Cool! Thanks
I’ll try that.

1 Like

An update.
Initially I got an error when checking the json.
When I deleted the first line of code that started with [nextcloud][no app in context][0] {"reqId":"rA2..., I got “Valid json”.
So I deleted the first line in the import_user.json and tried the file_external:import again but still get an error. Now it is “Error while parsing json”.

I’m scratching my head why there would be an error if the info from the test site says “Valid json”.

I’m wondering if editing the file with nano could have changed the encoding leading to a problem?

Figured it out. For some reason nano changed the line endings to DOS. I didn’t realize it until I looked at the file in vi. There were weird '^M" at the end of the lines.

Ran tr -d '\015' < import_user.json > import_user_unix.json, moved the file to the container with podman cp import_user_unix.json nextcloud-app:/ and then re-ran the occ files_external:import /import_user_unix.json and it imported without a problem.

Woo hoo it worked! :joy: :blush:

I have access to my files from the smb file share again. (And I figured out why this container didn’t fit in the allotted vm. My daughter did a backup of her Android phone to the InstantUpload folder but didn’t move anything to her smb file share folder.) :joy:

Thank you for all your help @mrmarkuz !!

2 Likes