Set "Default Quota" via occ command line

I wish to set “Default Quota” programmatically via a “Infrastructure as code” tool like Puppet or Ansible.

You can set it in the GUI as admin under /settings/users

But since I have to admin many NextCloud instances, and I set up everything else so far via occ cli automation, then I’d like to also set the default quota.

Maybe this is already possible somehow that I don’t know?

This is what I found for you so far.

https://docs.nextcloud.com/server/stable/admin_manual/configuration_user/instruction_set_for_users.html?highlight=quota

for ldap users

https://docs.nextcloud.com/server/stable/admin_manual/configuration_user/user_auth_ldap.html#special-attributes

But since that not relevant for your usecase try this.
For the Database You should be able to set the default with ansible pushing a SQL command

something like

UPDATE `oc_appconfig` SET `appid` = 'files',`configkey` = 'default_quota',`configvalue` = '6 GB'WHERE `appid` = 'files' COLLATE utf8mb4_bin AND `configkey` = 'default_quota' COLLATE utf8mb4_bin;

should set the default to 6 GB
tested with mariaDB 10.3

2 Likes

based on great research from @Vincent_Stans following command looks successful:

occ config:app:set files default_quota --value '6 GB'

(prepend with “docker exec --user www-data {containername} php ” in case of docker).

Unfortunately the value is not set by default and corresponding occ :get command doesn’t return anything initially… but :set works right away and changing user quota to “default value” picks up changed values immediately…

3 Likes

Thank you both very much!

I wish I could select both your answers as “Solution”.

The occ command from @wwe is exactly what I was looking for. Will be trying it out soon.

EDIT: This puppet code works:

  $occ = '/usr/libexec/docker/cli-plugins/docker-compose exec --user www-data app php occ'
  # Set Default Storage Quota for all users.
  exec { 'Set Quota':
    command => "${occ} config:app:set files default_quota --value '${data_quota} GB'",
    cwd     => $docker_nextcloud_path,
    unless  => "/usr/bin/test \"$(${occ} config:app:get files default_quota)\" = \"${data_quota} GB\"",
  }
1 Like

Thanks, helped me a lot !