Troubles with nextcloudcmd: "Too many open files"

The device is a Raspberry Pi 3 with armhf architecture (not arm64) running Debian Bookworm as a headless server and fully updated. It has a fully functioning Nextcloud server which is mounted on a 3TiB external drive as a ext4 Logical Volume at /var/www/html/nextcloud/data This cloud is successfully sync’ing about 80GiB from another device on my LAN. The cloud uses MySQL as the database.

On the same server at /var/www/html/joomla i have my website development work. I want to sync this work (about 108MiB) into the cloud at /var/www/html/nextcloud/data/joomla

The first difficulty was finding nextcloudcmd. It is in the Debian package nextcloud-desktop-cmd Unfortunately that package is not in the Raspberry Pi repositories so a simple apt install was not possible. I had to download the suitable package from the Debian repository. Using dpkg -i to install the .deb file presented about 6 unresolved dependencies and suggested dpkg --fix-missing install as the solution. All that achieved was to remove the initial .deb from the cache. Eventually I was able to manually install the missing dependencies and persuade dpkg to install the deb and then install all the remaining dependencies (about 30 many of which look as if they are intended for a GUI environment). The end result was that was finally able to run nextcloudcmd.

Running nextcloudcmd
I should comment here that I do have group permissions into the www-data group for the /var/www/html branches, so there is not a permissions problem.
The command I ran was:

nextcloudcmd -u joomla -pxxxxx /var/www/html/joomla

This produced a massive amount of screen output (I was running ssh onto the server) but the upshot was that it only transferred 32MiB of the expected 108MiB. The last few lines of the output are:

04-20 12:12:48:946 [ warning nextcloud.sync.propagator.bulkupload ]: Could not prepare upload device: “Too many open files”
04-20 12:12:48:946 [ info nextcloud.sync.propagator.bulkupload ]: Item completed “libraries/src/Form/Field/CalendarField.php” OCC::SyncFileItem::NormalError CSyncEnums::CSYNC_INSTRUCTION_NEW “Too many open files”
04-20 12:12:48:946 [ warning nextcloud.sync.propagator ]: Could not complete propagation of “libraries/src/Form/Field/CalendarField.php” by OCC::BulkPropagatorJob(0x6c2e00) with status OCC::SyncFileItem::NormalError and error: “Too many open files”
04-20 12:12:48:947 [ info nextcloud.sync.propagator.bulkupload ]: modify final status NormalError OCC::SyncFileItem::NormalError OCC::SyncFileItem::NormalError
04-20 12:12:48:948 [ info ]: OCC::SyncFileItem::NormalError slotSubJobsFinished OCC::PropagatorJob::Running pending uploads 0 subjobs state OCC::PropagatorJob::Finished
04-20 12:12:48:948 [ info nextcloud.sync.propagator ]: PropagateRootDirectory::slotSubJobsFinished emit finished OCC::SyncFileItem::NormalError
04-20 12:12:49:514 [ info nextcloud.sync.engine ]: Sync run took 72191 ms
04-20 12:12:51:251 [ warning default ]: Another sync is needed, but not done because restart count is exceeded 3
04-20 12:12:51:280 [ info nextcloud.sync.database ]: Closing DB “/var/www/html/joomla/.sync_191779cac248.db”

I notice that nextcloudcmb works with a SQLite database but only 2 tables in that database have much significance - uploadinfo and metadata. This makes me assume that the reference to “Too many open files” must be from the MySQL database.
I guess my question is twofold:

  1. Why am I getting this problem?
  2. How do I fix it?