My disk is full in 10 days, culprit seems to be files_trashbin

Hi, I have a fresh install of Nextcloud on a 1984 VPS with Yunohost.
The disk is full

:/home$ df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  473M     0  473M   0% /dev
tmpfs          tmpfs      98M  540K   98M   1% /run
/dev/vda       xfs        25G   25G  945M  97% /
tmpfs          tmpfs     489M     0  489M   0% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs      98M     0   98M   0% /run/user/1007

files_trashbin grows continuously

--- /home/yunohost.app/nextcloud/data/myself -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   12.7 GiB [##########] /files_trashbin                                                                                                                                                                           
    2.4 GiB [#         ] /files
    1.0 GiB [          ] /files_versions
  191.7 MiB [          ] /uploads
e   0.0   B [          ] /cache

I tried to do this: https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/trashbin_configuration.html

# cat /var/www/nextcloud/config/config.php
<?php
$CONFIG = array (
  'passwordsalt' => 'xxxyyy',
  'secret' => 'xxxxyyyyy',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'mydomain.io',
  ),
  'datadirectory' => '/home/yunohost.app/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '22.2.3.0',
  'overwrite.cli.url' => 'https://mydomain.io',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'xxxyyyy',
  'installed' => true,
  'instanceid' => '1234',
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'updatechecker' => false,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'trashbin_retention_obligation' => 'auto',
  'versions_retention_obligation' => 'auto',
  'integrity.check.disabled' => true,
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => '6379',
    'timeout' => '0.0',
    'password' => '',
  ),
  'hashing_default_password' => true,
  'localstorage.allowsymlinks' => true,
  'simpleSignUpLink.shown' => false,
  'logout_url' => 'https://mydomain.io/yunohost/sso/?action=logout',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'me',
  'mail_domain' => 'mydomain.io',
  'mail_smtphost' => 'mydomain.io',
  'mail_smtpauth' => 1,
  'mail_smtpport' => '587',
  'mail_smtpname' => 'me',
  'mail_smtppassword' => 'password1234',
);

Thus I have 3 questions:

  1. How to empty this directory
  2. How to know what fills it
  3. Is my config.php ok ?

You can modify your retention policy to auto delete after a number of days:

'trashbin_retention_obligation' => 'auto, 30',

You can modify 30 to the number of days you think is necessary for trash retention; ex. 5. That will delete all files in trash older than X days.

You should also think about why Nextcloud is allowing deleted files to exceed 50% of allowable storage. The ‘auto’ setting is supposed to delete files when space is needed.

Do you have cron set up correctly?

https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/background_jobs_configuration.html

1 Like

Thank you for caring.
You are spot on ! (It’s my first server management, for my other domains I have a hoster^^)
Still two issiues !

  1. I’m stuck !
:/var/www/nextcloud# crontab -u www-data -e
no crontab for www-data - using an empty one
/tmp/crontab.n81uUE: No space left on device
Creation of temporary crontab file failed - aborting
  1. is it logical that this trashbin grows continuously ? (I made 1Go room yesterday morning…)

No usually you can’t go over your user limits. E.g. user has limited space 10 GB, and used 5 GB, than Trash bin size could not exceed 5 GB, or only for a shorter period. Cleanups are planned and executed via Cron job, seems you cron job does not work.

You can delete all Trash files of particular user by command (Using the occ command — Nextcloud latest Administration Manual latest documentation):

sudo -u www-data php occ trashbin:cleanup <USERNAME>

What are the limits for user myself ? If it set to “Unlimited”, you can set it to the size of the Partition, to make NC aware that this is also physical limit and trash and versions needs to be cleaned.

Usually you can see deleted files in UI, e.g. under https://mydomain.io/index.php/apps/files/?dir=/&view=trashbin

Thank you for this.

I’m really stuck.

:/var/www/nextcloud# sudo -u www-data php occ trashbin:cleanup me
PHP Warning:  Module 'apcu' already loaded in Unknown on line 0
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/nextcloud/lib/private/DB/Connection.php:87
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(236): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(287): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(344): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(109): OC\AppConfig->loadConfigValues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(300): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(971): OC\AppConfig->getValues()
#9 /var/www/nextcloud/lib/private/Server.php(687): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\Server->OC\{closure}()
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#13 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(182): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#19 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#21 /var/www/nextcloud/lib/private/Server.php(1064): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\Server->OC\{closure}()
#23 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#25 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#27 /var/www/nextcloud/lib/private/Server.php(2024): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/nextcloud/lib/private/Files/View.php(118): OC\Server->getLockingProvider()
#29 /var/www/nextcloud/lib/private/Server.php(435): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\Server->OC\{closure}()
#31 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#33 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#35 /var/www/nextcloud/lib/private/Server.php(1387): OC\AppFramework\Utility\SimpleContainer->get()
#36 /var/www/nextcloud/lib/base.php(594): OC\Server->boot()
#37 /var/www/nextcloud/lib/base.php(1089): OC::init()
#38 /var/www/nextcloud/console.php(48): require_once('/var/www/nextcl...')
#39 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')

I’m on the verge of deciding for a clean install.
Certainly fastidious, but I don’t have strategic content yet.

Disk full is always a problem. Perhaps a needed files was not writen.
root can write disk to 100%, www-data only perhaps to 95%.

And this file is perhaps not really needed.

Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/nextcloud/lib/private/DB/Connection.php:87

Perhaps you can restart MariaDB and perhaps reorg it.