Snap on a RPi external HDD wont sync after changing laptop

Hi
I have just got a new laptop, and ran Linux cp -pr to copy my files from the old disk to my new one
My RPi Ubuntu server nextcloud snap (which was running fine) then kept loosing the connection to host after checking for changes of a part of the data (there are 350 GB, 100K items, more or less in both folders I sync)
This then sometimes restarts once (whilst connection is lost I still have ssh access) but then starts again and then fails in a crash of the RPi

I have tried reinstalling Ubuntu Server and snap but to no avail

RPi is actually a NC Box with a 3B in it

Everything works otherwise - access via web, etc

Any ideas how to track down the problem?

please!

12 community/nextcloud-client 2:3.7.2-2 (3.9 MiB 14.7 MiB) (Installed)
    Nextcloud desktop client

And i also tried the windows client when dual booted into Win 11 - same thing

Happens at different files / progress each time, and on both large folders I have

I have cleaned versions and trash

Doesnt appear to be due to space on SD card:

ubuntu@ubuntu:~$ sudo snap logs nextcloud.mysql 
2023-02-11T04:49:58Z nextcloud.mysql[7417]:  * MySQL server PID file could not be found!
2023-02-11T04:50:28Z systemd[1]: snap.nextcloud.mysql.service: State 'stop-sigterm' timed out. Killing.
2023-02-11T04:50:28Z systemd[1]: snap.nextcloud.mysql.service: Killing process 6434 (mysqld_safe) with signal SIGKILL.
2023-02-11T04:50:28Z systemd[1]: snap.nextcloud.mysql.service: Killing process 7450 (mysqld) with signal SIGKILL.
2023-02-11T04:50:30Z systemd[1]: snap.nextcloud.mysql.service: Failed with result 'timeout'.
2023-02-11T04:50:30Z systemd[1]: snap.nextcloud.mysql.service: Consumed 4min 27.945s CPU time.
2023-02-11T04:50:31Z systemd[1]: snap.nextcloud.mysql.service: Scheduled restart job, restart counter is at 2.
2023-02-11T04:50:31Z systemd[1]: Stopped Service for snap application nextcloud.mysql.
2023-02-11T04:50:31Z systemd[1]: snap.nextcloud.mysql.service: Consumed 4min 27.945s CPU time.
2023-02-11T04:50:31Z systemd[1]: Started Service for snap application nextcloud.mysql.

other Snap logs

ubuntu@ubuntu:~$ sudo snap logs nextcloud
2023-02-11T04:19:56Z nextcloud.apache[2426]: System config value memcache.local set to string \OC\Memcache\Redis
2023-02-11T04:19:59Z nextcloud.apache[2509]: No such app enabled: updatenotification
2023-02-11T04:20:02Z nextcloud.apache[1208]: Making sure nextcloud is fully upgraded...
2023-02-11T04:20:05Z nextcloud.apache[2671]: Nextcloud is already latest version
2023-02-11T04:20:05Z nextcloud.apache[785]: All set! Running httpd...
2023-02-11T04:20:06Z nextcloud.apache[2699]: Certificates have been activated: using HTTPS only
2023-02-11T04:20:06Z nextcloud.apache[2699]: Certificates look to be in order: enabling HSTS
2023-02-11T04:20:06Z nextcloud.apache[2699]: HTTP compression is disabled
2023-02-11T04:20:07Z nextcloud.nextcloud-fixer[789]: done
2023-02-11T04:20:10Z nextcloud.nextcloud-fixer[2929]: run-parts: executing /snap/nextcloud/33592/fixes/existing-install/1_upgrade.sh

ubuntu@ubuntu:~$ sudo snap services nextcloud
Service                    Startup  Current   Notes
nextcloud.apache           enabled  active    -
nextcloud.logrotate        enabled  inactive  timer-activated
nextcloud.mdns-publisher   enabled  active    -
nextcloud.mysql            enabled  active    -
nextcloud.nextcloud-cron   enabled  active    -
nextcloud.nextcloud-fixer  enabled  inactive  -
nextcloud.php-fpm          enabled  active    -
nextcloud.redis-server     enabled  active    -
nextcloud.renew-certs      enabled  active    -
ubuntu@ubuntu:~$ sudo snap services nextcloud.apache
Service           Startup  Current  Notes
nextcloud.apache  enabled  active   -

ubuntu@ubuntu:~$ sudo snap logs nextcloud.apache
2023-02-11T04:19:49Z nextcloud.apache[2168]: System config value redis => port set to integer 0
2023-02-11T04:19:53Z nextcloud.apache[2249]: System config value memcache.locking set to string \OC\Memcache\Redis
2023-02-11T04:19:56Z nextcloud.apache[2426]: System config value memcache.local set to string \OC\Memcache\Redis
2023-02-11T04:19:59Z nextcloud.apache[2509]: No such app enabled: updatenotification
2023-02-11T04:20:02Z nextcloud.apache[1208]: Making sure nextcloud is fully upgraded...
2023-02-11T04:20:05Z nextcloud.apache[2671]: Nextcloud is already latest version
2023-02-11T04:20:05Z nextcloud.apache[785]: All set! Running httpd...
2023-02-11T04:20:06Z nextcloud.apache[2699]: Certificates have been activated: using HTTPS only
2023-02-11T04:20:06Z nextcloud.apache[2699]: Certificates look to be in order: enabling HSTS
2023-02-11T04:20:06Z nextcloud.apache[2699]: HTTP compression is disabled

ubuntu@ubuntu:~$ sudo snap logs nextcloud.mysql 
2023-02-10T23:11:57Z systemd[1]: snap.nextcloud.mysql.service: Killing process 17619 (mysqld) with signal SIGKILL.
2023-02-10T23:11:58Z systemd[1]: snap.nextcloud.mysql.service: Failed with result 'timeout'.
2023-02-10T23:11:58Z systemd[1]: snap.nextcloud.mysql.service: Consumed 16min 54.782s CPU time.
2023-02-10T23:11:58Z systemd[1]: snap.nextcloud.mysql.service: Scheduled restart job, restart counter is at 2.
2023-02-10T23:11:58Z systemd[1]: Stopped Service for snap application nextcloud.mysql.
2023-02-10T23:11:58Z systemd[1]: snap.nextcloud.mysql.service: Consumed 16min 54.782s CPU time.
2023-02-10T23:11:58Z systemd[1]: Started Service for snap application nextcloud.mysql.
2023-02-10T23:12:43Z nextcloud.mysql[17841]: Starting MySQL
2023-02-10T23:12:51Z nextcloud.mysql[17841]: ........ *
2023-02-11T04:19:32Z nextcloud.mysql[1444]: ......... *

ubuntu@ubuntu:~$ sudo snap logs nextcloud.mdns-publisher 
2023-02-11T04:17:35Z nextcloud.mdns-publisher[89905]: 2023/02/11 04:17:35 Failed to listen 224.0.0.251:5353: listen udp4 224.0.0.251:5353: setsockopt: no such device
2023-02-11T04:17:45Z systemd[1]: snap.nextcloud.mdns-publisher.service: Main process exited, code=exited, status=1/FAILURE
2023-02-11T04:17:45Z systemd[1]: snap.nextcloud.mdns-publisher.service: Failed with result 'exit-code'.
2023-02-11T04:17:45Z systemd[1]: snap.nextcloud.mdns-publisher.service: Scheduled restart job, restart counter is at 1747.
2023-02-11T04:17:45Z systemd[1]: Stopped Service for snap application nextcloud.mdns-publisher.
2023-02-11T04:17:45Z systemd[1]: Started Service for snap application nextcloud.mdns-publisher.
2023-02-11T04:17:45Z nextcloud.mdns-publisher[89941]: 2023/02/11 04:17:45 Failed to listen 224.0.0.251:5353: listen udp4 224.0.0.251:5353: setsockopt: no such device

ubuntu@ubuntu:~$ sudo snap logs nextcloud.nextcloud-cron
2023-02-10T19:36:23Z nextcloud.nextcloud-cron[2013]: Nextcloud is not installed - only a limited number of commands are available
2023-02-10T19:37:35Z systemd[1]: Stopping Service for snap application nextcloud.nextcloud-cron...
2023-02-10T19:37:36Z systemd[1]: snap.nextcloud.nextcloud-cron.service: Deactivated successfully.
2023-02-10T19:37:36Z systemd[1]: Stopped Service for snap application nextcloud.nextcloud-cron.
2023-02-10T19:37:36Z systemd[1]: snap.nextcloud.nextcloud-cron.service: Consumed 4.844s CPU time.
2023-02-10T19:37:50Z systemd[1]: Started Service for snap application nextcloud.nextcloud-cron.
2023-02-10T19:38:30Z nextcloud.nextcloud-cron[784]: Waiting for Nextcloud config dir... done
2023-02-10T19:39:07Z nextcloud.nextcloud-cron[2042]: Nextcloud is not installed - only a limited number of commands are available
2023-02-10T20:46:21Z systemd[1]: Started Service for snap application nextcloud.nextcloud-cron.
2023-02-10T20:46:27Z nextcloud.nextcloud-cron[788]: Waiting for Nextcloud config dir... done

ubuntu@ubuntu:~$ sudo snap logs nextcloud.php-fpm 
2023-02-10T19:37:36Z systemd[1]: Stopped Service for snap application nextcloud.php-fpm.
2023-02-10T19:37:36Z systemd[1]: snap.nextcloud.php-fpm.service: Consumed 5.595s CPU time.
2023-02-10T19:37:50Z systemd[1]: Started Service for snap application nextcloud.php-fpm.
2023-02-10T19:38:32Z nextcloud.php-fpm[786]: Waiting for MySQL...
2023-02-10T19:38:59Z nextcloud.php-fpm[786]: done
2023-02-10T19:38:59Z nextcloud.php-fpm[786]: Obtaining nextcloud mysql credentials... done
2023-02-10T20:46:21Z systemd[1]: Started Service for snap application nextcloud.php-fpm.
2023-02-10T20:46:29Z nextcloud.php-fpm[790]: Waiting for MySQL...
2023-02-11T04:19:34Z nextcloud.php-fpm[790]: done
2023-02-11T04:19:34Z nextcloud.php-fpm[790]: Obtaining nextcloud mysql credentials... done

ubuntu@ubuntu:~$ sudo snap logs nextcloud.redis-server 
2023-02-10T19:34:50Z systemd[1]: Started Service for snap application nextcloud.redis-server.
2023-02-10T19:35:52Z nextcloud.redis-server[1214]: 1214:C 10 Feb 2023 19:35:52.123 # Reading config from stdin
2023-02-10T19:37:36Z systemd[1]: Stopping Service for snap application nextcloud.redis-server...
2023-02-10T19:37:36Z systemd[1]: snap.nextcloud.redis-server.service: Deactivated successfully.
2023-02-10T19:37:36Z systemd[1]: Stopped Service for snap application nextcloud.redis-server.
2023-02-10T19:37:36Z systemd[1]: snap.nextcloud.redis-server.service: Consumed 4.332s CPU time.
2023-02-10T19:37:50Z systemd[1]: Started Service for snap application nextcloud.redis-server.
2023-02-10T19:38:38Z nextcloud.redis-server[1232]: 1232:C 10 Feb 2023 19:38:38.220 # Reading config from stdin
2023-02-10T20:46:21Z systemd[1]: Started Service for snap application nextcloud.redis-server.
2023-02-10T20:46:37Z nextcloud.redis-server[1246]: 1246:C 10 Feb 2023 20:46:37.287 # Reading config from stdin

ubuntu@ubuntu:~$ sudo snap logs nextcloud.logrotate
2023-02-11T00:00:07Z nextcloud.logrotate[29351]: empty log files are not rotated, old logs are removed
2023-02-11T00:00:07Z nextcloud.logrotate[29351]: considering log /var/snap/nextcloud/current/logs/mysql_errors.log
2023-02-11T00:00:07Z nextcloud.logrotate[29351]: Creating new state
2023-02-11T00:00:07Z nextcloud.logrotate[29351]:   Now: 2023-02-11 00:00
2023-02-11T00:00:07Z nextcloud.logrotate[29351]:   Last rotated at 2023-02-11 00:00
2023-02-11T00:00:07Z nextcloud.logrotate[29351]:   log does not need rotating (log has been already rotated)
2023-02-11T00:00:07Z systemd[1]: snap.nextcloud.logrotate.service: Deactivated successfully.
2023-02-11T04:19:25Z systemd[1]: Started Service for snap application nextcloud.logrotate.
2023-02-11T04:19:25Z nextcloud.logrotate[1713]: 2023-02-11T04:19:25Z: attempted to run "nextcloud.logrotate" timer outside of scheduled time "00:00"
2023-02-11T04:19:25Z systemd[1]: snap.nextcloud.logrotate.service: Deactivated successfully.

ubuntu@ubuntu:~$ sudo snap logs nextcloud.nextcloud-fixer 
2023-02-11T04:20:54Z nextcloud.nextcloud-fixer[789]: Enabling maintenance mode...
2023-02-11T04:20:57Z nextcloud.nextcloud-fixer[789]: done
2023-02-11T04:21:00Z nextcloud.nextcloud-fixer[3571]: run-parts: executing /snap/nextcloud/33592/fixes/existing-install/maintenance/1_convert-filecache-bigint.sh
2023-02-11T04:21:02Z nextcloud.nextcloud-fixer[3638]: Nextcloud is in maintenance mode, hence the database isn't accessible.
2023-02-11T04:21:02Z nextcloud.nextcloud-fixer[3638]: Cannot perform any command except 'maintenance:mode --off'
2023-02-11T04:21:04Z nextcloud.nextcloud-fixer[3638]: All tables already up to date!
2023-02-11T04:21:04Z nextcloud.nextcloud-fixer[789]: Disabling maintenance mode...
2023-02-11T04:21:06Z nextcloud.nextcloud-fixer[789]: done
2023-02-11T04:21:09Z systemd[1]: snap.nextcloud.nextcloud-fixer.service: Deactivated successfully.
2023-02-11T04:21:09Z systemd[1]: snap.nextcloud.nextcloud-fixer.service: Consumed 37.732s CPU time.

I have tried reinstalling everything from scratch on various SD cards, and reformatting (ext4) the HDD and repopulating that with a direct cp --pr from my laptop fils but still the same thing

I have had this problem for ages, its so annoying as before when it managed to sync once it was fine after that

Maybe its the original Nextcloud Box WDLabs HDD?

It works when connected to my lappy fine, no problems, but I found a guide for checking disks and this gave an error:

In gparted it says filesystem file and that it most definitely is ext4 (which I formatted it to)

leigh@T16-AL ~ % sudo fsck -y /dev/sda             
fsck from util-linux 2.38.1
e2fsck 1.46.6 (1-Feb-2023)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/sda

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

/dev/sda contains `DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x0,0,2), end-CHS (0x3ff,255,63), startsector 1, 1953458175 sectors, extended partition table (last)' data

Although:

leigh@T16-AL ~ % sudo fsck /dev/sda1     
[sudo] password for leigh: 
fsck from util-linux 2.38.1
e2fsck 1.46.6 (1-Feb-2023)
NCdisk: clean, 227808/61046784 files, 165237048/244181760 blocks

and:

leigh@T16-AL ~ % sudo badblocks -v /dev/sda
Checking blocks 0 to 976729087
Checking for bad blocks (read-only test): done                                                 
Pass completed, 0 bad blocks found. (0/0/0 errors)

And

leigh@T16-AL ~ % sudo smartctl -H /dev/sda 
[sudo] password for leigh: 
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-5.15.91-4-lts] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Status not supported: Incomplete response, ATA output registers missing
SMART overall-health self-assessment test result: PASSED
Warning: This result is based on an Attribute check.

I think this may be because I have some website backups in my synced files with htaccess files in them?
Would this make sense?