Restoring From A Blank Config File

I seem to have encountered the issue where the config.php file is deleted but I’m not sure when as the server hasn’t been restarted for a long time. If I try to access the UI I recieve the error " * Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php"

I’ve checked my backups and they all have the config.php as 0 bytes so restoring from there is not possible. I’ve also looked in the data directory and can’t find an “upgrade-somethingsomething” folder to pull a backup from.
I’m using the nextcloud:25.0.3-apache docker image which has been updated many times in the past but I presume no backups are created if you simply update the docker image?

What I do have is

  • The instance ID of the Server
  • The complete Data Folder (Unencrypted)
  • Backups and currently running version of the mariadb database

What is the best way to get the server up and running. I could just do a fresh install and point back to the data files but I’m also running Calendar, Contacts and Tasks that I’d ideally not want to lose.

Any help on next steps would be greatly appreciated
Thanks

Update
I’ve managed to get everything up and running again by creating a new config file with the following

<?php
$CONFIG = array (
'instanceid' => 'the instance id',
  'trusted_domains' => 
  array (
    0 => 'domainname',
    1 => 'localip',
  ),
  'overwrite.cli.url' => 'https://domainname',
  'overwriteprotocol' => 'https',
  'overwritehost' => 'domainname',
  'version' => '25.0.3.2',
  'dbtype' => 'mysql',
  'dbhost' => 'nextclouddb',
  'dbname' => 'nextcloud',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'password',
  'installed' => true,
  'mysql.utf8mb4' => true,
  'supportedDatabases' => 
  array (
    0 => 'sqlite',
    1 => 'mysql',
    2 => 'pgsql',
    3 => 'oci',
  ),
 'secret' => '',
 'passwordsalt' => 'SOME MADE UP SALT'
);

It then made me perform an OCC Upgrade command, re-enable 2FA and re login with all my devices and apps. Everything seems to be working fine though and there has been no loss of data, calendar entries or tasks.

hello Oli @StormENT welcome to the forum :handshake: good first question and solution right away!

not many to add here some things a have on a test instance (should be close to default):

  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'redis-host',
    'password' => 'redis-pwd',
    'port' => 6379,
  ),
  'loglevel' => '1',
  'maintenance' => false,
  'trusted_proxies' =>
  array (
    0 => '172.16.0.0/12',
    1 => '192.168.0.0/16',
  ),

reference to the values:

https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/config_sample_php_parameters.html