NCP: cannot move datadir

I have a fresh install of NCP on Raspberry Pi, updated to latest versions. I have an external SSD attached, and was able to move database and swap to the SSD. But not the datadir. I did create the ncdata directory, so it exists.

Running nc-datadir
Nextcloud is in maintenance mode - no apps have been loaded

INFO: /media/MX500/ncdata is not empty. Creating backup /media/MX500/ncdata-09-11-19
Maintenance mode already enabled
moving data directory from /var/www/nextcloud/data to /media/MX500/ncdata…
/usr/local/bin/ncp/CONFIG/nc-datadir.sh: line 73: cd: /media/MX500/ncdata: No such file or directory
cp: cannot create directory ‘’: No such file or directory
Done. Press any key…

What should I do?

the same here

I finally managed to move the datadir to the USB disk. I found instructions on how to do it manually here: https://pimylifeup.com/raspberry-pi-nextcloud-server/ “Moving Nextcloud’s data folder”.
I also needed to run nc-fix-permissions.

Thanks for reporting your issue is fixed.

1 Like

same problem here
brand new pi 4,
nothing else installed
fixed ip adress
apt-get update and upgrade and used this nextcloudpi config:
wget https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh
sudo bash install.sh

error the same after setup and wizzard for nc-datadir.
no such file or directory .

OK,
i started from scratch, with

  1. buster lite,

  2. apt-get update/upgrade

  3. password change of pi user

  4. sudo bash

  5. raspberrypi installation script ```
    curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | bash

  6. after setup, wizard start for change of data directory to usb storage:
    [ nc-automount ]
    Created symlink /etc/systemd/system/multi-user.target.wants/nc-automount.service → /usr/lib/systemd/system/nc-automount.service.
    Created symlink /etc/systemd/system/multi-user.target.wants/nc-automount-links.service → /usr/lib/systemd/system/nc-automount-links.service.
    automount enabled

    [ nc-format-USB ]
    /dev/sda: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
    /dev/sda: 8 bytes were erased at offset 0xdf90355e00 (gpt): 45 46 49 20 50 41 52 54
    /dev/sda: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa
    Drive sda formatted successfuly and labeled myCloudDrive

    [ nc-datadir ]
    Maintenance mode enabled
    moving data directory from /var/www/nextcloud/data to /media/USBdrive/ncdata…
    BTRFS filesystem detected
    ERROR: target path already exists: /media/myCloudDrive/ncdata

ls -l /media gives me
total 16

drwxr-xr-x 1 root root 0 Sep 13 12:29 myCloudDrive
lrwxrwxrwx 1 root root 19 Sep 13 12:29 USBdrive → /media/myCloudDrive

so Link is /media/USBdrive
to Device /media/myCloudDrive
as it was formated to btrfs from [ nc-format-USB ]

the chmod looks good right? read write access for root

if found that discussion on githup from 2017 (quite old I know):

there someone has the same strange behaviour
I’ve tried almost everything from nachoparker with removed media symlinks,
changed devicenames
and especially wayneouttheres description of his fix: https://github.com/nextcloud/nextcloudpi/issues/305#issuecomment-377697798

but when I switch to ncp control panel to use nc-datadir with the Data directory:
/media/myCloudDrive/ncdata

it gives:
[ nc-datadir ]
Nextcloud is in maintenance mode - no apps have been loaded

INFO: /media/myCloudDrive/ncdata is not empty. Creating backup /media/myCloudDrive/ncdata-09-13-19
Maintenance mode already enabled
moving data directory from /var/www/nextcloud/data to /media/myCloudDrive/ncdata…
BTRFS filesystem detected
ERROR: target path already exists: /media/myCloudDrive/ncdata

  1. the actual status of ncp-report gives:

<–! Paste this in GitHub report →

NextCloudPi diagnostics

cat: /usr/local/etc/ncp-version: No such file or directory
Nextcloud is in maintenance mode - no apps have been loaded

NextCloudPi version
distribution         Raspbian GNU/Linux 10 \n \l
automount            yes
USB devices          sda 
datadir              /var/www/nextcloud/data
data in SD           yes
data filesystem      ext2/ext3
data disk usage      2.1G/29G
rootfs usage         2.1G/29G
swapfile             /var/swap
dbdir                /var/lib/mysql
Nextcloud check      ok
Nextcloud version    16.0.4.1
HTTPD service        up
PHP service          up
MariaDB service      up
Redis service        up
Postfix service      up
internet check       ok
port check 80        closed
port check 443       closed
IP                   ***REMOVED SENSITIVE VALUE***
gateway              ***REMOVED SENSITIVE VALUE***
interface            eth0
certificates         ***REMOVED SENSITIVE VALUE***
NAT loopback         no
uptime               31min

Nextcloud configuration

Nextcloud is in maintenance mode - no apps have been loaded

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": {
            "0": "localhost",
            "11": "<!DOCTYPE HTML PUBLIC \"-\/\/IETF\/\/DTD HTML 2.0\/\/EN\">\n<html><head>\n<title>302 Found<\/title>\n<\/head><body>\n<h1>Found<\/h1>\n<p>The document has moved <a href=\"https:\/\/icanhazip.com\/\">here<\/a>.<\/p>\n<\/body><\/html>",
            "1": "192.168.1.162",
            "5": "nextcloudpi.local",
            "7": "nextcloudpi",
            "8": "nextcloudpi.lan"
        },
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "16.0.4.1",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 0,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "tempdirectory": "\/var\/www\/nextcloud\/data\/tmp",
        "mail_smtpmode": "sendmail",
        "mail_smtpauthtype": "LOGIN",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "preview_max_x": "2048",
        "preview_max_y": "2048",
        "jpeg_quality": "60",
        "overwriteprotocol": "https",
        "maintenance": true
    }
}

HTTPd logs

[Fri Sep 13 11:55:22.480086 2019] [ssl:error] [pid 18866:tid 3069219344] AH02604: Unable to configure certificate localhost:443:0 for stapling
[Fri Sep 13 11:55:22.481142 2019] [mpm_event:notice] [pid 18866:tid 3069219344] AH00489: Apache/2.4.38 (Raspbian) OpenSSL/1.1.1c configured -- resuming normal operations
[Fri Sep 13 11:55:22.481178 2019] [core:notice] [pid 18866:tid 3069219344] AH00094: Command line: '/usr/sbin/apache2'
[Fri Sep 13 12:27:24.283574 2019] [mpm_event:notice] [pid 18866:tid 3069219344] AH00491: caught SIGTERM, shutting down
[Fri Sep 13 12:27:45.314416 2019] [ssl:warn] [pid 631:tid 3069792784] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Fri Sep 13 12:27:45.317799 2019] [ssl:error] [pid 631:tid 3069792784] AH02217: ssl_stapling_init_cert: can't retrieve issuer certificate! [subject: CN=raspberrypi / issuer: CN=raspberrypi / serial: 771216E2AA462623F6FC197FB6FED6688F741040 / notbefore: Sep 13 10:50:31 2019 GMT / notafter: Sep 10 10:50:31 2029 GMT]
[Fri Sep 13 12:27:45.317833 2019] [ssl:error] [pid 631:tid 3069792784] AH02604: Unable to configure certificate localhost:443:0 for stapling
[Fri Sep 13 12:27:45.347486 2019] [ssl:warn] [pid 805:tid 3069792784] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Fri Sep 13 12:27:45.347805 2019] [ssl:error] [pid 805:tid 3069792784] AH02217: ssl_stapling_init_cert: can't retrieve issuer certificate! [subject: CN=raspberrypi / issuer: CN=raspberrypi / serial: 771216E2AA462623F6FC197FB6FED6688F741040 / notbefore: Sep 13 10:50:31 2019 GMT / notafter: Sep 10 10:50:31 2029 GMT]
[Fri Sep 13 12:27:45.347847 2019] [ssl:error] [pid 805:tid 3069792784] AH02604: Unable to configure certificate localhost:443:0 for stapling
[Fri Sep 13 12:27:45.353170 2019] [mpm_event:notice] [pid 805:tid 3069792784] AH00489: Apache/2.4.38 (Raspbian) OpenSSL/1.1.1c configured -- resuming normal operations
[Fri Sep 13 12:27:45.353263 2019] [core:notice] [pid 805:tid 3069792784] AH00094: Command line: '/usr/sbin/apache2'
[Fri Sep 13 12:28:48.017685 2019] [mpm_event:notice] [pid 805:tid 3069792784] AH00493: SIGUSR1 received.  Doing graceful restart
[Fri Sep 13 12:28:48.042836 2019] [ssl:warn] [pid 805:tid 3069792784] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name
[Fri Sep 13 12:28:48.043021 2019] [ssl:error] [pid 805:tid 3069792784] AH02217: ssl_stapling_init_cert: can't retrieve issuer certificate! [subject: CN=raspberrypi / issuer: CN=raspberrypi / serial: 771216E2AA462623F6FC197FB6FED6688F741040 / notbefore: Sep 13 10:50:31 2019 GMT / notafter: Sep 10 10:50:31 2029 GMT]
[Fri Sep 13 12:28:48.043039 2019] [ssl:error] [pid 805:tid 3069792784] AH02604: Unable to configure certificate localhost:4443:0 for stapling
[Fri Sep 13 12:28:48.044091 2019] [mpm_event:notice] [pid 805:tid 3069792784] AH00489: Apache/2.4.38 (Raspbian) OpenSSL/1.1.1c configured -- resuming normal operations
[Fri Sep 13 12:28:48.044111 2019] [core:notice] [pid 805:tid 3069792784] AH00094: Command line: '/usr/sbin/apache2'
[Fri Sep 13 12:29:07.205573 2019] [proxy_fcgi:error] [pid 1558:tid 2755716128] [client 192.168.1.181:50067] AH01071: Got error 'PHP message: PHP Notice:  Undefined index: app in /var/www/ncp-web/index.php on line 238PHP message: PHP Notice:  Undefined index: app in /var/www/ncp-web/index.php on line 244'
[Fri Sep 13 12:31:17.467573 2019] [proxy_fcgi:error] [pid 1558:tid 2822923296] [client 192.168.1.181:50067] AH01071: Got error 'PHP message: PHP Notice:  Undefined index: app in /var/www/ncp-web/index.php on line 238PHP message: PHP Notice:  Undefined index: app in /var/www/ncp-web/index.php on line 244'

Database logs

2019-09-13 12:27:46 0 [Note] InnoDB: Uses event mutexes
2019-09-13 12:27:46 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-09-13 12:27:46 0 [Note] InnoDB: Number of pools: 1
2019-09-13 12:27:46 0 [Note] InnoDB: Using generic crc32 instructions
2019-09-13 12:27:46 0 [Note] InnoDB: Initializing buffer pool, total size = 1.625G, instances = 1, chunk size = 128M
2019-09-13 12:27:46 0 [Note] InnoDB: Completed initialization of buffer pool
2019-09-13 12:27:46 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-09-13 12:27:46 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-09-13 12:27:46 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-09-13 12:27:46 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-09-13 12:27:46 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-09-13 12:27:46 0 [Note] InnoDB: 10.3.17 started; log sequence number 6801485; transaction id 5149
2019-09-13 12:27:46 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-09-13 12:27:46 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-09-13 12:27:46 0 [Note] Server socket created on IP: '127.0.0.1'.
2019-09-13 12:27:46 0 [Note] Reading of all Master_info entries succeeded
2019-09-13 12:27:46 0 [Note] Added new Master_info '' to hash table
2019-09-13 12:27:46 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '10.3.17-MariaDB-0+deb10u1'  socket: '/run/mysqld/mysqld.sock'  port: 3306  Raspbian 10
2019-09-13 12:27:47 0 [Note] InnoDB: Buffer pool(s) load completed at 190913 12:27:47

Nextcloud logs


so after some more investigation.
the nc-datadir.sh fails at line 74 or below when the btrfs subvolumes should be used.

# resolve symlinks and use the real path
  mkdir -p "$DATADIR"
  DATADIR=$(cd "$DATADIR" && pwd -P)

  # use subvolumes, if BTRFS
  [[ "$( stat -fc%T "$BASEDIR" )" == "btrfs" ]] && {
    echo "BTRFS filesystem detected"
    btrfs subvolume create "$DATADIR" || return  1
  }

my usb device was formated using the wizard, ls -l /media gives

total 16
drwxr-xr-x 1 root root 18 Sep 13 17:24 myCloudDrive
lrwxrwxrwx 1 root root 19 Sep 13 14:56 USBdrive -> /media/myCloudDrive

nc-automount shows
systemctl status nc-automount
● nc-automount.service - Automount USB drives
Loaded: loaded (/usr/lib/systemd/system/nc-automount.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-09-13 14:56:00 BST; 3h 3min ago
Process: 402 ExecStartPre=/bin/bash -c rmdir /media/* || true (code=exited, status=0/SUCCESS)
Main PID: 416 (udiskie)
Tasks: 3 (limit: 4915)
Memory: 14.7M
CGroup: /system.slice/nc-automount.service
└─416 /usr/bin/python3 /usr/bin/udiskie -NTF

Sep 13 14:56:00 raspberrypi systemd[1]: Starting Automount USB drives...
Sep 13 14:56:00 raspberrypi bash[402]: rmdir: failed to remove '/media/USBdrive': Not a directory
Sep 13 14:56:00 raspberrypi systemd[1]: Started Automount USB drives.
Sep 13 14:56:02 raspberrypi udiskie[416]: mounted /org/freedesktop/UDisks2/block_devices/sda1 on /media/myCloudDrive

what is wrong with my automount? or btfrs subvolumes?
what I’m doing wrong in this easy setup?
I’m running a nextcloud instance on an vps server since two years without a flaw, but I fail to scan this raspberrypi-nextcloud .sh scripts … I’m lost… any help is highly welcome…

Hi,

Your last issue seems like a mistake with the fail2ban fix. Can you try sudo ncp-update devel and let me know if it works for you after that?

1 Like

Hi nachoparker,
first of all, thanks for your fast reply.
tried the development branche and that solved the problem.
datadir and database could be moved without a problem.

just for the sake of learning: can you point me to the problem in the actual ncp version? what script fails, why is it the fail2ban fix? that is not even close to what i thought about the btrfs subvolume mounting point or the nc-datadir.sh lines i’ve highlighted above.

greetings

Wizard fails.
[ nc-format-USB ]
/dev/sda: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
/dev/sda: 8 bytes were erased at offset 0x747024ffe00 (gpt): 45 46 49 20 50 41 52 54
/dev/sda: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa
WARNING: failed to open /dev/btrfs-control, skipping device registration: No such device
Drive sda formatted successfuly and labeled myCloudDrive

[ nc-datadir ]
/media/USBdrive does not exist

I moved the point where the directory is created, but didn’t realize that in the BTRFS case it assumes that it doesn’t exist, so the btrfs command fails