NextcloudPi Backing Up - difficulties

I am experiencing issues with backing up
plus each time a backup fails the config.php has maintenance = true, and it needs to be changed maually.

This is what the system is and the outputs:

System details

NextCloudPi version	v1.36.3
NextCloudPi image	NextCloudPi_11-27-20
distribution	Debian GNU/Linux 10 \n \l
automount	yes
USB devices	sda sdb
datadir	/media/myCloudDrive/ncdata
data in SD	no
data filesystem	btrfs
data disk usage	87G/932G
rootfs usage	3.4G/29G
swapfile	/var/swap
dbdir	/var/lib/mysql
Nextcloud check	ok
Nextcloud version	20.0.2.2
HTTPD service	up
PHP service	up
MariaDB service	up
Redis service	up
Postfix service	up
internet check	ok
port check 80	open
port check 443	open
IP	192.168.1.94
gateway	192.168.1.254
interface	eth0
certificates	
NAT loopback	no
uptime	1:23

The output of your Nextcloud log in Admin > Logging:

[core] Error: Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory at <<closure>>

 0. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php line 1449
    OC\DB\Connection->connect()
 1. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php line 892
    Doctrine\DBAL\Connection->getWrappedConnection()
 2. /var/www/nextcloud/lib/private/DB/Connection.php line 202
    Doctrine\DBAL\Connection->executeQuery("SELECT * FROM `oc_appconfig`", [], [], null)
 3. /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php line 206
    OC\DB\Connection->executeQuery("SELECT * FROM `oc_appconfig`", [], [])
 4. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 217
    Doctrine\DBAL\Query\QueryBuilder->execute()
 5. /var/www/nextcloud/lib/private/AppConfig.php line 345
    OC\DB\QueryBuilder\QueryBuilder->execute()
 6. /var/www/nextcloud/lib/private/AppConfig.php line 110
    OC\AppConfig->loadConfigValues()
 7. /var/www/nextcloud/lib/private/AppConfig.php line 301
    OC\AppConfig->getApps()
 8. /var/www/nextcloud/lib/private/legacy/OC_App.php line 949
    OC\AppConfig->getValues(false, "installed_version")
 9. /var/www/nextcloud/lib/private/TemplateLayout.php line 185
    OC_App::getAppVersions()
10. /var/www/nextcloud/lib/private/legacy/OC_Template.php line 183
    OC\TemplateLayout->__construct("error", "")
11. /var/www/nextcloud/lib/private/Template/Base.php line 132
    OC_Template->fetchPage()
12. /var/www/nextcloud/lib/private/legacy/OC_Template.php line 332
    OC\Template\Base->printPage()
13. /var/www/nextcloud/index.php line 63
    OC_Template::printExceptionErrorPage(Doctrine\DBAL\DBALException {}, 500)

GET /apps/photos/
from at 2021-06-17T21:43:45+00:00

this was in the web browser

Your data directory is invalid Ensure there is a file called ".ocdata" in the root of the data directory. 

The output nc-backup gives is the following

Running nc-backup
check free space...
Maintenance mode enabled
backup database...
backup files...
tar: ncdata/Sherab/files/CamptiaV2/07 IP Addressing/039 CompTIA - Network+ - The Hierarchical IP Address Scheme.mkv: File shrank by 395451043 bytes; padding with zeros
tar: ncdata/Sherab/files/CamptiaV2/07 IP Addressing/041 CompTIA - Network+ - Internet Protocol Version 6 (IPv6).mkv: Read error at byte 0, while reading 1024 bytes: Input/output error
tar: /media/USBdrive//nextcloud-bkp_20210617_1623965356.tar: Cannot write: Read-only file system
tar: Error is not recoverable: exiting now
error generating backup
{"reqId":"vp7y067KZacNrsWVmzAp","level":2,"time":"2021-06-17T21:33:02+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":"20.0.2.2"}
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/20/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:168
Stack trace:
#0 /var/www/nextcloud/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}Abort...
{"reqId":"4pDBwXfN6XR0TRAtYJ8d","level":2,"time":"2021-06-17T21:33:03+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":"20.0.2.2"}
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/20/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:168
Stack trace:
#0 /var/www/nextcloud/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}Done. Press any key...

config.php

<?php
$CONFIG = array (
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    5 => 'nextcloudpi.local',
    7 => 'nextcloudpi',
    8 => 'nextcloudpi.lan',
    11 => '2a00:23c7:c89c:7001:5a41:49a6:4f5:1f27',
    1 => '192.168.1.94',
 
  ),
  'datadirectory' => '/media/myCloudDrive/ncdata',
  'dbtype' => 'mysql',
  'version' => '20.0.2.2',
  'overwrite.cli.url' => 'https:///',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncadmin',
  'dbpassword' => 'jDyt5H+SMl6ZgGvT95Ny/u3Z6EuNniHWy2Xq3xSkGUI=',
  'installed' => true,
  'instanceid' => 'ocwn0g3teaag',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
    'password' => '
  ),
  'tempdirectory' => '/media/myCloudDrive/ncdata/tmp',
  'mail_smtpmode' => 'sendmail',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'admin',
  'mail_domain' => 'ownyourbits.com',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'overwriteprotocol' => 'https',
  'maintenance' => true,
  'logfile' => '/media/myCloudDrive/ncdata/nextcloud.log',
  'loglevel' => '2',
  'log_type' => 'file',
  'htaccess.RewriteBase' => '/',
);