Nextcloud instance destroyed due to nc-nextcloud instead of nc-limits - user failure, nc-restore help

first posting in GERMAN for the initial problem is not related to the actual problem of a screwed up nextcloud installation, please ignore the following and go straight down to
[Nextcloud instance destroyed due to nc-nextcloud instead of nc-limits - user failure, nc-restore help - #5 by Multisaft]

Hallo zusammen,

ich betreibe seit längerer Zeit eine NCP nextcloud und dies auch größtenteils erfolgreich.

Leider gibt es mit IPhones im automatischen Upload öfters Probleme, und die Performance für andere User außerhalb meines Netzwerks (manchmal auch innerhalb des LAN) lässt manchmal auch zu wünschen übrig trotz SSD als Daten- und Datenbankspeicher, großem Upload, täglichem Cron für Vorschaugenerierung usw.).

Darum soll es garnicht gehen,
ich habe ein Problem mit dem Verständnis über und der Config meines Zertifikates.

Ich nutze in der NCP Konfiguration die Letsencrypt Einstellungen, dies scheint auch zu funktionieren (zumindest wird das Zertifikat regelmäßig erneuert), forcehttps ist ebenfalls aktiv.

In meinen Nextcloud Benachrichtigung beim Login auf der weboberfläche der Nextcloud findet sich aber wöchentlich/alle zwei Wochen ein SSL renewal error mit Details im letsencrypt.log, der letzte vom 1.Mai.

das aktuelle letsencrypt.log file wirft aber deutlich mehr fehler, ca. 1-2 Mal am Tag wird ein renewale angestrebt welcher abgebrochen wird weil das config file broken ist?

hier der letzte Durchlauf

2022-05-05 02:06:41,781:DEBUG:certbot.main:certbot version: 0.31.0
2022-05-05 02:06:41,785:DEBUG:certbot.main:Arguments: ['-q']
2022-05-05 02:06:41,785:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2022-05-05 02:06:41,810:DEBUG:certbot.log:Root logging level set at 30
2022-05-05 02:06:41,811:INFO:certbot.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2022-05-05 02:06:41,840:DEBUG:certbot.plugins.selection:Requested authenticator <certbot.cli._Default object at 0xb5417190> and installer <certbot.cli._Default object at 0xb5417190>
2022-05-05 02:06:41,861:INFO:certbot.renewal:Cert not yet due for renewal
2022-05-05 02:06:41,863:DEBUG:certbot.plugins.selection:Requested authenticator webroot and installer None
2022-05-05 02:06:41,867:WARNING:certbot.renewal:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/certbot/renewal.py", line 68, in _reconstitute
    renewal_candidate = storage.RenewableCert(full_path, config)
  File "/usr/lib/python3/dist-packages/certbot/storage.py", line 463, in __init__
    self._check_symlinks()
  File "/usr/lib/python3/dist-packages/certbot/storage.py", line 522, in _check_symlinks
    "expected {0} to be a symlink".format(link))
certbot.errors.CertStorageError: expected /etc/letsencrypt/live/montino.duckdns.org/cert.pem to be a symlink
2022-05-05 02:06:41,872:WARNING:certbot.renewal:Renewal configuration file /etc/letsencrypt/renewal/montino.duckdns.org.conf is broken. Skipping.
2022-05-05 02:06:41,873:DEBUG:certbot.renewal:Traceback was:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/certbot/renewal.py", line 68, in _reconstitute
    renewal_candidate = storage.RenewableCert(full_path, config)
  File "/usr/lib/python3/dist-packages/certbot/storage.py", line 463, in __init__
    self._check_symlinks()
  File "/usr/lib/python3/dist-packages/certbot/storage.py", line 522, in _check_symlinks
    "expected {0} to be a symlink".format(link))
certbot.errors.CertStorageError: expected /etc/letsencrypt/live/montino.duckdns.org/cert.pem to be a symlink

2022-05-05 02:06:41,873:DEBUG:certbot.log:Exiting abnormally:
Traceback (most recent call last):
  File "/usr/bin/certbot", line 11, in <module>
    load_entry_point('certbot==0.31.0', 'console_scripts', 'certbot')()
  File "/usr/lib/python3/dist-packages/certbot/main.py", line 1365, in main
    return config.func(config, plugins)
  File "/usr/lib/python3/dist-packages/certbot/main.py", line 1272, in renew
    renewal.handle_renewal_request(config)
  File "/usr/lib/python3/dist-packages/certbot/renewal.py", line 490, in handle_renewal_request
    len(renew_failures), len(parse_failures)))
certbot.errors.Error: 0 renew failure(s), 1 parse failure(s)

ist es möglich, dass ich in meinem System zwei Setups betreibe (ich weiß es nicht mehr weil der Fehler mindestens schon 12-18 Monate besteht).

<–! Paste this in GitHub report →

NextCloudPi diagnostics

NextCloudPi version  v1.47.1
OS                   Raspbian GNU/Linux 10. 5.10.103-v7l+ (armv7l)
automount            yes
USB devices          sda 
datadir              /media/myCloudDrive/ncdata
data in SD           no
data filesystem      btrfs
data disk usage      371G/932G
rootfs usage         3.3G/29G
swapfile             /var/swap
dbdir                /media/USBdrive/ncdatabase
Nextcloud check      ok
Nextcloud version    23.0.2.1
HTTPD service        up
PHP service          up
MariaDB service      up
Redis service        up
HPB 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               10days

Nextcloud configuration

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": {
            "0": "localhost",
            "1": "192.168.1.4",
            "2": "montino.duckdns.org",
            "5": "nextcloudpi.local",
            "7": "nextcloudpi",
            "8": "nextcloudpi.lan",
            "12": "montino.duckdns.org",
            "3": "raspberrypi",
            "": "raspberrypi",
            "14": "raspberrypi"
        },
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "23.0.2.1",
        "overwrite.cli.url": "https:\/\/raspberrypi\/",
        "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": "\/media\/myCloudDrive\/ncdata\/tmp",
        "mail_smtpmode": "smtp",
        "mail_smtpauthtype": "LOGIN",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "preview_max_x": "2048",
        "preview_max_y": "2048",
        "jpeg_quality": "75",
        "overwriteprotocol": "https",
        "maintenance": false,
        "logfile": "\/media\/myCloudDrive\/ncdata\/nextcloud.log",
        "loglevel": "2",
        "log_type": "file",
        "mail_sendmailmode": "smtp",
        "mail_smtpsecure": "ssl",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "theme": "",
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***"
    }
}

HTTPd logs

[Thu May 05 08:20:28.680112 2022] [authz_host:error] [pid 11142:tid 2780947456] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /js/minified.js failed, reason: unable to get the remote host name
[Thu May 05 08:20:28.700780 2022] [authz_host:error] [pid 11142:tid 2806150144] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/reboot.svg failed, reason: unable to get the remote host name
[Thu May 05 08:20:28.700856 2022] [authz_host:error] [pid 11142:tid 2755744768] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/defaults.svg failed, reason: unable to get the remote host name
[Thu May 05 08:20:28.716510 2022] [authz_host:error] [pid 11142:tid 2755744768] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/favicon.png failed, reason: unable to get the remote host name
[Thu May 05 08:20:28.732298 2022] [authz_host:error] [pid 11142:tid 2755744768] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /ncp-output.php failed, reason: unable to get the remote host name
[Thu May 05 08:20:28.732298 2022] [authz_host:error] [pid 11142:tid 2806150144] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/search.svg failed, reason: unable to get the remote host name, referer: https://192.168.1.4:4443/css/ncp.css
[Thu May 05 08:20:28.732337 2022] [authz_host:error] [pid 11142:tid 2789348352] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/defaults-white.svg failed, reason: unable to get the remote host name, referer: https://192.168.1.4:4443/css/ncp.css
[Thu May 05 08:20:28.732348 2022] [authz_host:error] [pid 11142:tid 2764145664] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/settings-white.svg failed, reason: unable to get the remote host name, referer: https://192.168.1.4:4443/css/ncp.css
[Thu May 05 08:20:28.732586 2022] [authz_host:error] [pid 11142:tid 2764145664] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/logs.svg failed, reason: unable to get the remote host name, referer: https://192.168.1.4:4443/css/ncp.css
[Thu May 05 08:20:28.732590 2022] [authz_host:error] [pid 11142:tid 2797749248] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/dashboard.svg failed, reason: unable to get the remote host name, referer: https://192.168.1.4:4443/css/ncp.css
[Thu May 05 08:20:28.732590 2022] [authz_host:error] [pid 11142:tid 2772546560] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/wizard.svg failed, reason: unable to get the remote host name, referer: https://192.168.1.4:4443/css/ncp.css
[Thu May 05 08:20:28.732769 2022] [authz_host:error] [pid 11142:tid 2780947456] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/nc-button.svg failed, reason: unable to get the remote host name, referer: https://192.168.1.4:4443/css/ncp.css
[Thu May 05 08:20:28.740295 2022] [authz_host:error] [pid 11142:tid 2780947456] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /ncp-launcher.php failed, reason: unable to get the remote host name
[Thu May 05 08:20:33.738941 2022] [authz_host:error] [pid 11142:tid 2772546560] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/info-white.svg failed, reason: unable to get the remote host name, referer: https://192.168.1.4:4443/css/ncp.css
[Thu May 05 08:20:33.739187 2022] [authz_host:error] [pid 11142:tid 2806150144] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/files.svg failed, reason: unable to get the remote host name, referer: https://192.168.1.4:4443/css/ncp.css
[Thu May 05 08:20:33.739331 2022] [authz_host:error] [pid 11142:tid 2764145664] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/info.svg failed, reason: unable to get the remote host name, referer: https://192.168.1.4:4443/css/ncp.css
[Thu May 05 08:20:53.834470 2022] [authz_host:error] [pid 11142:tid 2780947456] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /ncp-launcher.php failed, reason: unable to get the remote host name
[Thu May 05 08:21:26.200836 2022] [authz_host:error] [pid 11142:tid 2780947456] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /ncp-launcher.php failed, reason: unable to get the remote host name
[Thu May 05 08:21:26.200921 2022] [authz_host:error] [pid 11142:tid 2806150144] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/delete.svg failed, reason: unable to get the remote host name
[Thu May 05 08:21:26.200920 2022] [authz_host:error] [pid 11142:tid 2764145664] [client 192.168.1.9:49762] AH01753: access check of 'localhost' to /img/download.svg failed, reason: unable to get the remote host name

Database logs


Nextcloud logs

REMOVED SENSITIVE VALUE"

Die Nextcloud logs habe ich entfernt weil ich 100te Fehler eines Sofortuploads gerade bekomme weil bei einem User das Passwort abgelaufen ist.

cat /var/log/ncp.log
Thu  5 May 06:25:09 CEST 2022 - Running /etc/cron.daily/ncp-autoupdate...
[ncp-update-nc]
Current   Nextcloud version 23.0.2.1
Available Nextcloud version 23.0.2
Nothing to update

Wenn ich das bereits aktivierte Letsencrypt Config in der NCP Weboberfläche erneut ausführe, dann erstellt er wohl ein neues Zertifikat mit 002. Eigentlich wollte ich nur ein Renewable anstoßen über die Oberfläche um zu gucken, was dann passiert.
Wie kann ich jetzt das 002 löschen, und zurück auf mein 001 gehen?
Folgender Log beim Ausführen des Letsencrypt in NCP Weboberfläche:

[ letsencrypt ] (Thu May 5 09:18:04 CEST 2022)
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for montino.duckdns.org
Using the webroot path /var/www/nextcloud for all unmatched domains.
Waiting for verification...
Cleaning up challenges
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/montino.duckdns.org-0002/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/montino.duckdns.org-0002/privkey.pem
Your cert will expire on 2022-08-03. To obtain a new or tweaked
version of this certificate in the future, simply run certbot
again. To non-interactively renew *all* of your certificates, run
"certbot renew"
- If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

INFO: Letsencrypt domain is montino.duckdns.org
System config value trusted_domains => 11 set to string montino.duckdns.org
System config value trusted_domains => 3 set to string montino.duckdns.org
System config value overwrite.cli.url set to string https://montino.duckdns.org/
System config value trusted_proxies => 11 set to string 127.0.0.1
System config value trusted_proxies => 12 set to string ::1
System config value trusted_proxies => 13 set to string montino.duckdns.org
System config value trusted_proxies => 14 set to string 84.148.160.88
✓ redis is configured
✓ push server is receiving redis messages
✓ push server can load mount info from database
✓ push server can connect to the Nextcloud server
✓ push server is a trusted proxy
✓ push server is running the same version as the app
configuration saved

Wegen des initialen Problems habe ich jetzt mal die Renewale conf gelöscht die nicht zu 001 und 002 gehört (eben der im letsencrypt.log bezeichnete Fehler:

WARNING:certbot.renewal:Renewal configuration file /etc/letsencrypt/renewal/montino.duckdns.org.conf is broken. Skipping.

Vielleicht hab ich damit ja schon den hier beschriebene Config-Fehler behoben?
Wie kann ich dann jetzt Safe das 002 Zertifikat löschen?

ich hoffe jemand kann mir helfen, die Fehler sind unschön. Der erste Fehler mit dem “renewal Problem” verunsicherte mich, ich würde diesen gerne beheben. Der zweite mit einem doppelten Zertifkat ist natürlich auch mist. Kan ich einfach alles 002 aus /etc/letsencrypt/live und /renewal löschen?

Sorry my German is rather rusty, please post in English if at all possible.

From your report I can see two things:

  • NCP 1.47.1 is still on NC22.2.2 and you are running NC 23.0.2.1 (Why?)
  • You are on armv7l, which is 32 bits and no longer supported by NCP, all images are 64 bits at present.

You need to make backups, install 64 bits OS if your hardware supports it or upgrade hardware and re-install, and restore from backups.

Alternatively, you can try to run certbot from the terminal to obtain a new certificate.

Hi OliverV,

I’m sorry for posting in German, I have seen a lot of german questions and answers and this morning I thought I will post my problem in German as I was pressed for time, i can change my intial post to english afterwards.

To get to your questions.

  • i have no Idea why my NCP Version and NC Version do not align? I use nc-autoupdate-nc as well as nc-autoupdate-ncp and had no issues whatsoever in the past 18 month or so?

  • update routine: i will look into the details for the update routine etc. for the moment I do daily backups without data to my SSD attached for the datebase and configs and rsync snapshots to my local NAS for the DATA folders. But I really dont look forward in a complete new setup (as I screwed that up in the past with older nextcloud instances and ncp routines).
    is it correct to go for the Raspberry Pi OS Lite release and the than most actual NCP setup?
    Release date: April 4th 2022
    System: 64-bit
    Kernel version: 5.15
    Debian version: 11 (bullseye)

If your hardware supports it (64bits), best use one of the available images.
I doubt the ncp install script works on various hardware at the moment. Last time I used it, it was on Buster (Debian v10).

holy smoke, now ive screwed my NCP instance up ones more!

I would ask for help to get back up and running!

what I have done!

i used the ncp web interface to look into the details of my configuration and saw that for 32bit, filesize above 2GB was not supported, my nextcloud config was set to 10GB (I have done that during the initial setup).

So i proceeded the following stuff:

  1. nc-limits
    [ nc-limits ] (Thu 5 May 16:37:09 CEST 2022) Using 3018906624B for PHP Using 6 PHP threads Using 955970560 memory for the database

after a reboot the ncp website shown
HPB service down

I wasnt aware of this line in the system info and checked the log files

System config value trusted_domains => 3 set to string montino.duckdns.org
System config value overwrite.cli.url set to string https://montino.duckdns.org/
System config value trusted_proxies => 11 set to string 127.0.0.1
System config value trusted_proxies => 12 set to string ::1
System config value trusted_proxies => 13 set to string montino.duckdns.org
System config value trusted_proxies => 14 set to string 84.148.160.88
✓ redis is configured
✓ push server is receiving redis messages
✓ push server can load mount info from database
✓ push server can connect to the Nextcloud server
🗴 push server is not a trusted proxy, please add '192.168.1.1' to the list of trusted proxies or configure any existing reverse proxy to forward the 'x-forwarded-for' send by the push server.
See https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/reverse_proxy_configuration.html#defining-trusted-proxies for how to set trusted proxies.
The following trusted proxies are currently configured: "127.0.0.1", "::1", "montino.duckdns.org", "84.148.160.88"
of which the following seem to be invalid: "montino.duckdns.org"
The following x-forwarded-for header was received by Nextcloud: 1.2.3.4
from the following remote: 192.168.1.1

If you're having issues getting the trusted proxy setup working, you can try bypassing any existing reverse proxy
in your setup by setting the `NEXTCLOUD_URL` environment variable to point directly to the internal Nextcloud webserver url
(You will still need the ip address of the push server added as trusted proxy)

I nevern seen this issues before. so i digged into the details and rebooted one or two times without resolving the issue (I first thought, maybe the nc-limit update went down the line).

but after that I missclicked and run
[ nc-nextcloud ] the reinstallation of the NC
I foreced a reboot during the runtime after some seconds with my ssh login to aboard this nc-nextcloud installation.

now my Nextcloud instance is gone.

the ncdata folder etc. is still present.
i have daily backups with nc-backup-auto without DATA

can someone tell me the next steps to restore my nextcloud instance
when i look into the details of Restoring a NCP instance
when I use nc-restore this will reset the data from my /media/USBdrive/ncdata path right? so all data of my users are gone from my ssd attached to the rapsberrypi.
can I (just for the sake of safty) backup this user data storage prior to nc-restore into another folder inside the ssd “USBdrive”. i have enought space left on the ssd for this duplication.
I cannot use NC-backup with included DATA for that, because I screwed up the nextcloud installation right? so this brings nothing.
shall i just deep copy the folder through bash console? can anyone give advice what the steps are for that or any hints what I must take into consideration?

please help.

I have updated the first post with another topic title and information that the intial problem is not a top priority for the moment :nauseated_face:

nice,

it happens again, my backups fail to work

what i have done
i just copied for god sake the ncdata path to another folder inside my connected USB SSD.
as nc-snapshot etc. did not worked due to my destroyed nextcloud installation (see above).
after that, I wiped the SD and installed raspberry pi os lite 64-bit 2022-04-04 bullseye.
with a hostname raspberrypi.local and ssh active I installed ncp again through

curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | bash

the install went smooth, after it, nextcloud welcome me with the login screen on the local ip adress, but not with the activation screen presenting the passwords for NCP:4443 and NC.
i managed to update the hostname with

hostnamectl set-hostname nextcloudpi --transient

as transient and static where different.
after a reboot, the activation screen was present and I was able to login into ncp:4443 web interface.

and now the real hassle beginns.
my plan was to

  1. nc-restore my nextcloud configurations/database
  2. restore the ncp configuration by hand (backup maybe broken as I did it yesterday after i destroyed my nextcloud installation)
  3. manuel copy back the user-data into the ncdata path#
  4. rescan the ncdata folder

I started with the wizzard that already failed at the nc-data folder that was “not emtpy”.

INFO: /media/myCloudDrive/ncdata is not empty. Creating backup /media/myCloudDrive/ncdata-05-06-22.1651838565
{"reqId":"LpQAHytfBEThn8Qt3JjQ","level":2,"time":"2022-05-06T12:02:46+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory /media/myCloudDrive/ncdata/data/tmp is not present or writable","userAgent":"--","version":"23.0.2.1"}
{"reqId":"K91gL5lZdBjiyEYARAgL","level":2,"time":"2022-05-06T12:02:47+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory /media/myCloudDrive/ncdata/data/tmp is not present or writable","userAgent":"--","version":"23.0.2.1"}
Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory


Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/23/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:164
Stack trace:
#0 /var/www/nextcloud/console.php(98): OC\Console\Application->loadCommands()
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}

I canceld the NCP Wizzard and tried to restore my backuped NC Instance
this also fails:


Restore a previously backuped NC instance
This new installation will cleanup current
NextCloud instance, including files and database.

** perform backup before proceding **

You can use 'nc-backup'

Backup file	 path exists
[ nc-restore ] (Fri May 6 14:13:24 CEST 2022)
check free space...
extracting backup file /media/USBdrive/ncp-backups/nextcloud-bkp_20220505_1651712402.tar.gz...
restore files...
restore database...
No datadir found in backup
{"reqId":"TVIPREikTGL5WdEZvSke","level":2,"time":"2022-05-06T12:20:52+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory /media/myCloudDrive/ncdata/tmp is not present or writable","userAgent":"--","version":"23.0.2.1"}
{"reqId":"TVIPREikTGL5WdEZvSke","level":3,"time":"2022-05-06T12:20:52+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fopen(/media/myCloudDrive/ncdata/data_dir_writability_test_627512a4d7580.tmp): failed to open stream: Permission denied at /var/www/nextcloud/lib/private/legacy/OC_Util.php#792","userAgent":"--","version":"23.0.2.1","exception":{"Exception":"Error","Message":"fopen(/media/myCloudDrive/ncdata/data_dir_writability_test_627512a4d7580.tmp): failed to open stream: Permission denied at /var/www/nextcloud/lib/private/legacy/OC_Util.php#792","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Util.php","line":792,"function":"fopen"},{"file":"/var/www/nextcloud/lib/private/Console/Application.php","line":157,"function":"checkServer","class":"OC_Util","type":"::"},{"file":"/var/www/nextcloud/console.php","line":98,"function":"loadCommands","class":"OC\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/occ","line":11,"args":["/var/www/nextcloud/console.php"],"function":"require_once"}],"File":"/var/www/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}
Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory.

Your data directory is not writable
Permissions can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/23/go.php?to=admin-dir_permissions.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:164
Stack trace:
#0 /var/www/nextcloud/console.php(98): OC\Console\Application->loadCommands()
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}{"reqId":"TVIPREikTGL5WdEZvSke","level":3,"time":"2022-05-06T12:20:52+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fopen(/media/myCloudDrive/ncdata/nextcloud.log): failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Log/File.php#84","userAgent":"--","version":"23.0.2.1"}
Cleanup...

i restared again, new Nextcloud instance created, changed nothing else.
only wanted to change the nextcloud data folder


[ nc-datadir ] (Fri May 6 14:00:47 CEST 2022)
INFO: /media/myCloudDrive/ncdata is not empty. Creating backup /media/myCloudDrive/ncdata-05-06-22.1651838448
Maintenance mode enabled
moving data directory from /var/www/nextcloud/data to /media/myCloudDrive/ncdata...
BTRFS filesystem detected
Create subvolume '/media/myCloudDrive/ncdata'
Nextcloud is in maintenance mode, hence the database isn't accessible.
Cannot perform any command except 'maintenance:mode --off'

System config value logfile set to string /media/myCloudDrive/ncdata/data/nextcloud.log
Nextcloud is in maintenance mode, hence the database isn't accessible.
Cannot perform any command except 'maintenance:mode --off'

System config value tempdirectory set to string /media/myCloudDrive/ncdata/data/tmp
Maintenance mode disabled
/usr/local/bin/ncp/SYSTEM/metrics.sh: line 9: DOCKERBUILD: unbound variable

[ nc-datadir ] (Fri May 6 14:02:44 CEST 2022)
INFO: /media/myCloudDrive/ncdata is not empty. Creating backup /media/myCloudDrive/ncdata-05-06-22.1651838565
{"reqId":"LpQAHytfBEThn8Qt3JjQ","level":2,"time":"2022-05-06T12:02:46+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory /media/myCloudDrive/ncdata/data/tmp is not present or writable","userAgent":"--","version":"23.0.2.1"}
{"reqId":"K91gL5lZdBjiyEYARAgL","level":2,"time":"2022-05-06T12:02:47+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory /media/myCloudDrive/ncdata/data/tmp is not present or writable","userAgent":"--","version":"23.0.2.1"}
Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory.

Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/23/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:164
Stack trace:
#0 /var/www/nextcloud/console.php(98): OC\Console\Application->loadCommands()
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}
[ nc-datadir ] (Fri May 6 14:07:31 CEST 2022)
{"reqId":"ok4FhvQF51QuWxMHvFlS","level":2,"time":"2022-05-06T12:07:31+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory /media/myCloudDrive/ncdata/data/tmp is not present or writable","userAgent":"--","version":"23.0.2.1"}
Error reading data directory. Is NextCloud running and configured?

I’m lost,

lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 931.5G  0 disk 
└─sda1        8:1    0 931.5G  0 part /media/myCloudDrive

and

df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/sda1      btrfs     932G  739G  193G  80% /media/myCloudDrive

I guess I need help with a step by step instruction how to recreate my nextcloud instance…

I was able to solve this by myself.

I try to type down what I did for future requests or other users with maybe the same problems.

  1. Pi Imager, Bullseye 64bit lite
  2. activated SSH
  3. Installl NCP from CLI
  4. to get the activation page of Nextcloud for the ncp passwords, the hostname at my installation was wrong in initial setup (raspberrypi instead of nextcloudpi, this happend 3 times with different settings from PI Imager under OS X, latest version). this can be fixed with
hostnamectl set-hostname nextcloudpi --transient
  1. run NCP Wizzard without storage formating, just move the data folder, the original ncdata folder will be moved instead of overwriting
  2. delete the newly created datafolder and rename your original nc-datadir back to default
  3. use nc-restore to restore nextcloud configuration and database, that did worked at my setup with the correct nc-datadir and subfolders in place (step 5)
  4. recreate your ncp settings from backup or by hand
  5. up and running again, i had some more problems/issues.

8.1 permissions to nc-data folder, i cannot remember the nextcloud log error anymore.
chown for www-data on nc-data folder fixed this

8.2 Error: disk_free_space(): No such file or directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#381, can be fixed manually with adding the commit to the ‘lib/private/legacy/OC_Helper.php’.

8.3. log2ram not running because of to large log folder/files (history) mainly from journald
added some settings e.g. SystemMaxUse to journald.conf
deleted rotated logs
restart journald and log2ram

service systemd-journald restart
systemctl restart log2ram

8.4. notify push was not activated - systemctl notify_push errors
updated apps from nextcloud and
systemctl restart notify_push