Can't migrate files with occ as doesn't recognize data directory changed

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

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:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 10.5.0
  • Operating system and version (e.g., Ubuntu 24.04):
    • TrueNAS SCALE 24.10.2 Ubuntu 24.04 VM
  • Web server and version (e.g, Apache 2.4.25):
    • replace me
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • Pfsense HAProxy 2.8.3-86e043a
  • PHP version (e.g, 8.3):
    • 8.3.16
  • Is this the first time you’ve seen this error? (Yes / No):
    • yes
  • When did this problem seem to first start?
    • after running occ command to update files that were migrated
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • AIO
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • CloudFlare for DNS

Summary of the issue you are facing:

[I migrated all my files from an old install, change the permissions to 33:0 and chmod 750. Then ran the occ command below…]

Steps to replicate it (hint: details matter!):

  1. Fresh install copied old files to new dir sudo rsync -avr /mnt/nextcloud/files/admin/files/* /mnt/docker/nextcloud/admin/files/
  2. sudo chown -R 33:0 …/nextcloud/
  3. sudo chmod -R 750 …/nextcloud/
  4. sudo docker exec --user www-data -it nextcloud-aio-nextcloud php occ files:scan-app-data && sudo docker exec --user www-data -it nextcloud-aio-nextcloud php occ files:scan --all
  5. get this error
    ±--------±------±-------------+
    | Folders | Files | Elapsed time |
    ±--------±------±-------------+
    | 20 | 56 | 00:00:00 |
    ±--------±------±-------------+
    Starting scan for user 1 out of 3 (admin)
    Error during scan: opendir(/mnt/ncdata/admin/files/Pvt): Failed to open directory: Permission denied
    It seems to think my data dir is /mnt/ncdata but I changed it with the environment variable. Tried to stop and remove the mastercontainer and then re run the docker compose
  nextcloud:
    image: nextcloud/all-in-one:latest # Must be changed to 'nextcloud/all-in-one:latest-arm64' when used with an arm64 CPU
    restart: always
    container_name: nextcloud-aio-mastercontainer
    volumes:
      - nextcloud_aio_mastercontainer:/mnt/docker-aio-config
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - 7080:8080
    environment:
      - APACHE_PORT=11000
      - NEXTCLOUD_DATADIR=/mnt/docker/nextcloud # Allows to set the host directory for Nextcloud's datadir. See https://github.com/nextcloud/all-in-one#how-to-change-the-default-location-of-nextclouds-datadir
      - NEXTCLOUD_MOUNT=/mnt/media # Allows the Nextcloud container to access the chosen directory on the host. See https://github.com/nextcloud/all-in-one#how-to-allow-the-nextcloud-container-to-access-directories-on-the-host
      - NEXTCLOUD_MEMORY_LIMIT=4096M
networks: {}
volumes:
  nextcloud_aio_mastercontainer:
    name: nextcloud_aio_mastercontainer

Log entries

{"reqId":"wwq5nSc3os6zIyodE0HD","level":3,"time":"2025-02-08T22:09:58+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Storage home::admin not available","userAgent":"--","version":"30.0.5.1","exception":{"Exception":"OCP\\Files\\StorageNotAvailableException","Message":"Directory listing failed","Code":1,"Trace":[{"function":"getDirectoryContent","class":"OC\\Files\\Storage\\Common","type":"->","args":["files/Pvt"]},{"file":"/var/www/html/lib/private/Files/Cache/Scanner.php","line":468,"function":"iterator_to_array","args":[{"__class__":"Generator"}]},{"file":"/var/www/html/lib/private/Files/Cache/Scanner.php","line":425,"function":"handleChildren","class":"OC\\Files\\Cache\\Scanner","type":"->","args":["files/Pvt",true,3,162,true,0,false]},{"file":"/var/www/html/lib/private/Files/Cache/Scanner.php","line":430,"function":"scanChildren","class":"OC\\Files\\Cache\\Scanner","type":"->","args":["files/Pvt",true,3,162,true,-1,false]},{"file":"/var/www/html/lib/private/Files/Cache/Scanner.php","line":430,"function":"scanChildren","class":"OC\\Files\\Cache\\Scanner","type":"->","args":["files",true,3,2,true,-1,1]},{"file":"/var/www/html/lib/private/Files/Cache/Scanner.php","line":331,"function":"scanChildren","class":"OC\\Files\\Cache\\Scanner","type":"->","args":["",true,3,1,true,-1]},{"file":"/var/www/html/lib/private/Files/Utils/Scanner.php","line":255,"function":"scan","class":"OC\\Files\\Cache\\Scanner","type":"->","args":["",true,3]},{"file":"/var/www/html/apps/files/lib/Command/Scan.php","line":153,"function":"scan","class":"OC\\Files\\Utils\\Scanner","type":"->","args":["/admin",true,null]},{"file":"/var/www/html/apps/files/lib/Command/Scan.php","line":214,"function":"scanFiles","class":"OCA\\Files\\Command\\Scan","type":"->","args":["admin","/admin",null,{"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"},false,true,false]},{"file":"/var/www/html/3rdparty/symfony/console/Command/Command.php","line":326,"function":"execute","class":"OCA\\Files\\Command\\Scan","type":"->","args":[{"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"},{"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"}]},{"file":"/var/www/html/core/Command/Base.php","line":161,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->","args":[{"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"},{"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"}]},{"file":"/var/www/html/3rdparty/symfony/console/Application.php","line":1078,"function":"run","class":"OC\\Core\\Command\\Base","type":"->","args":[{"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"},{"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"}]},{"file":"/var/www/html/3rdparty/symfony/console/Application.php","line":324,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->","args":[{"__class__":"OCA\\Files\\Command\\Scan"},{"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"},{"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"}]},{"file":"/var/www/html/3rdparty/symfony/console/Application.php","line":175,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->","args":[{"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"},{"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"}]},{"file":"/var/www/html/lib/private/Console/Application.php","line":183,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->","args":[{"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"},{"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"}]},{"file":"/var/www/html/console.php","line":87,"function":"run","class":"OC\\Console\\Application","type":"->","args":[{"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"}]},{"file":"/var/www/html/occ","line":11,"args":["/var/www/html/console.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Files/Storage/Common.php","Line":845,"Hint":"Storage is temporarily not available","message":"Storage home::admin not available","exception":[],"CustomMessage":"Storage home::admin not available"},"id":"67a7da8041316"}```
#### Nextcloud
Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the *Copy raw* option from *Administration settings->Logging* screen or from your `nextcloud.log` located in your data directory). Feel free to use a pastebin/gist service if necessary.

```{"reqId":"cbX0muLfr2p6See3ufRp","level":3,"time":"2025-02-08T22:14:33+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"opendir(/mnt/ncdata/admin/files/CBT): Failed to open directory: Permission denied at /var/www/html/lib/private/Files/Storage/Local.php#129","userAgent":"--","version":"30.0.5.1","data":{"app":"PHP"},"id":"67a7da80412cb"}```

#### Web Browser

If the problem is related to the Web interface, open your browser inspector *Console* and *Network* tabs while refreshing (reloading) and reproducing the problem. Provide any relevant output/errors here that appear.

PASTE


#### Web server / Reverse Proxy

The output of your Apache/nginx/system log in `/var/log/____`:

PASTE HERE



### Configuration
 ```{
    "system": {
        "one-click-instance": true,
        "one-click-instance.user-limit": 100,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "check_data_directory_permissions": false,
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "overwritehost": "nc.warrenbuc.com",
        "overwriteprotocol": "https",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "nc.warrenbuc.com"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "30.0.5.1",
        "overwrite.cli.url": "https:\/\/nc.warrenbuc.com\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "loglevel": 2,
        "log_type": "file",
        "logfile": "\/var\/www\/html\/data\/nextcloud.log",
        "log_rotate_size": 10485760,
        "log.condition": {
            "apps": [
                "admin_audit"
            ]
        },
        "preview_max_x": 2048,
        "preview_max_y": 2048,
        "jpeg_quality": 60,
        "enabledPreviewProviders": {
            "1": "OC\\Preview\\Image",
            "2": "OC\\Preview\\MarkDown",
            "3": "OC\\Preview\\MP3",
            "4": "OC\\Preview\\TXT",
            "5": "OC\\Preview\\OpenDocument",
            "6": "OC\\Preview\\Movie",
            "7": "OC\\Preview\\Krita",
            "0": "OC\\Preview\\Imaginary",
            "23": "OC\\Preview\\ImaginaryPDF"
        },
        "enable_previews": true,
        "upgrade.disable-web": true,
        "mail_smtpmode": "smtp",
        "trashbin_retention_obligation": "auto, 30",
        "versions_retention_obligation": "auto, 30",
        "activity_expire_days": 30,
        "simpleSignUpLink.shown": false,
        "share_folder": "\/Shared",
        "one-click-instance.link": "https:\/\/nextcloud.com\/all-in-one\/",
        "upgrade.cli-upgrade-link": "https:\/\/github.com\/nextcloud\/all-in-one\/discussions\/2726",
        "updatedirectory": "\/nc-updater",
        "maintenance_window_start": 100,
        "allow_local_remote_servers": true,
        "davstorage.request_timeout": 3600,
        "documentation_url.server_logs": "https:\/\/github.com\/nextcloud\/all-in-one\/discussions\/5425",
        "htaccess.RewriteBase": "\/",
        "dbpersistent": false,
        "auth.bruteforce.protection.enabled": true,
        "ratelimit.protection.enabled": true,
        "files_external_allow_create_new_local": true,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "preview_imaginary_url": "***REMOVED SENSITIVE VALUE***",
        "preview_imaginary_key": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "US",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "DOMAIN": "mydomain.com"
    }
}```
#### Nextcloud

The output of `occ config:list system` or similar is best, but, if not possible, the contents of your `config.php` file from `/path/to/nextcloud` is fine (make sure to remove any identifiable information!):

PASTE HERE


#### Apps

The output of `occ app:list` (if possible).

### Tips for increasing the likelihood of a response

* Use the `preformatted text` formatting option in the editor for all log entries and configuration output.
* If screenshots are useful, feel free to include them. 
  - If possible, also include key error output in text form so it can be searched for.
* Try to edit log output only minimally (if at all) so that it can be ran through analyzers / formatters by those trying to help you.

The sudo chown - command seems to be the reason.
Try

sudo chown -R www-data:www-data /path/to/localdir

if “www-data” exists. - It is the username of the Nextcloud-instance.

recommends chown -R 33:0 the directory.

I got everything working. Need to change the data to the /mnt/ncdata directory with this docker run.

sudo docker run \
--init \
--sig-proxy=false \
--name nextcloud-aio-mastercontainer \
--restart always \
--publish 7080:8080 \
--env APACHE_PORT=11000 \
--env APACHE_IP_BINDING=0.0.0.0 \
--env APACHE_ADDITIONAL_NETWORK="" \
--env NEXTCLOUD_DATADIR="/mnt/ncdata" \
--env NEXTCLOUD_MOUNT="/mnt/media" \
--env SKIP_DOMAIN_VALIDATION=false \
--volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
nextcloud/all-in-one:latest

stopped the containers
rsync -avr
chown -R www-data:root /mnt/ncdata
chmod -R 750 /mnt/ncdata
Start containers

sudo docker exec --user www-data -it nextcloud-aio-nextcloud php occ files:scan-app-data && sudo docker exec --user www-data -it nextcloud-aio-nextcloud php occ files:scan --all

Happy it is all working but I have 2 questions that arise from this process.

  1. Can you use any datadir or do you have to use ncdata?
  2. Does the docker compose not work as well as the docker run with variables NEXTCLOUD_DATADIR and NEXTCLOUD_MOUNT options?

See GitHub - nextcloud/all-in-one: 📦 The official Nextcloud installation method. Provides easy deployment and maintenance with most features included in this one Nextcloud instance.

See all-in-one/compose.yaml at main · nextcloud/all-in-one · GitHub