NextCloud 设置自动清理回收站和过期版本

由于使用习惯的原因,公司很多同事都是直接使用 NextCloud 客户端进行同步的,极少会到网页上进行 NextCloud 回收站的清理。并且由于很少登录网页版,故很多人也都不知道有网页回收站这个东西,大都是从本地回收站找回文件。这就导致了一个问题,就是 NextCloud 网页版上的回收站用处不大,并且还会浪费很多空间,但是又不能没有。。。所以,设定回收站定期清理规则很重要。并且,为了进一步释放空间,设定版本过期时间也尤为重要。

设定 NextCloud 回收站过期时间

通过查找官方文档,找到了 Deleted Items (trash bin) 的配置文档,其参数如下:

# 配置
'trashbin_retention_obligation' => 'auto',

# 参数说明

# Available values:
# 
# auto
# default setting. keeps files and folders in the trash bin for 30 days and automatically deletes anytime after that if space is needed (note: files may not be deleted if space is not needed).
# 默认设置。将文件和文件夹保存在垃圾桶中30天,如果需要空间,在30天之后自动删除(注意:如果不需要空间,文件可能不会被删除)。
# 
# D, auto
# keeps files and folders in the trash bin for D+ days, delete anytime if space needed (note: files may not be deleted if space is not needed)
# 将文件和文件夹保存在垃圾箱中长达D+天,如果需要空间可以随时删除(注:如果不需要空间,文件可能不会被删除)
# 
# auto, D
# delete all files in the trash bin that are older than D days automatically, delete other files anytime if space needed
# 自动删除垃圾箱中超过D天的所有文件,如果空间需要,随时删除其他文件
# 
# D1, D2
# keep files and folders in the trash bin for at least D1 days and delete when exceeds D2 days (note: files will not be deleted automatically if space is needed)
# 将文件和文件夹保存在垃圾桶内至少D1天,超过D2天后删除(注:如果有空间,文件不会自动删除)
# 
# disabled
# trash bin auto clean disabled, files and folders will be kept forever
# 垃圾桶自动清理禁用,文件和文件夹将永远保存
# 
# Defaults to auto
# 默认配置为 auto

设定版本过期时间

在同样的链接下面,还有个 File versions 的配置说明,这个是用来控制文件版本过期时间的,有需要的童鞋也可以进行配置,参数同回收站过期时间类似:

# 配置
'versions_retention_obligation' => 'auto',

# 参数说明

# Available values:
# 
# auto
# default setting. Automatically expire versions according to expire rules. Please refer to Controlling file versions and aging for more information.
# 默认设置。根据过期规则自动过期版本。有关更多信息,请参阅控制文件版本和老化。
# 
# D, auto
# keep versions at least for D days, apply expire rules to all versions that are older than D days
# 将版本至少保留D天,对所有超过D天的版本应用过期规则
# 
# auto, D
# delete all versions that are older than D days automatically, delete other versions according to expire rules
# 自动删除所有超过D天的版本,其他版本按照过期规则删除
# 
# D1, D2
# keep versions for at least D1 days and delete when exceeds D2 days
# 版本保存时间至少为D1天,超过D2天则删除
# 
# disabled
# versions auto clean disabled, versions will be kept forever
# 版本自动清理禁用,版本将永远保持
# 
# Defaults to auto
# 默认配置为 auto

示例

编辑 nextcloud/html/config/config.php 文件,在 $CONFIG = array () 之间插入即可:

  'trashbin_retention_obligation' => 'auto,7',
  'versions_retention_obligation' => 'auto,7',

手动执行

如果想要配置快速生效,还可以手动执行立即清理,如下:

[root@cdc_ncapp ~]# docker exec -u www-data nextcloud-app /var/www/html/occ trashbin:expire
    0 [>---------------------------]
    3 [->--------------------------]
    5 [--->------------------------]
    7 [----->----------------------]
    9 [------->--------------------]
   11 [--------->------------------]
   18 [----------->----------------]
   20 [------------->--------------]
   22 [-------------->-------------]
   25 [---------------->-----------]
   26 [------------------>---------]
   28 [-------------------->-------]
   35 [---------------------->-----]
   37 [------------------------>---]
[root@cdc_ncapp ~]# docker exec -u www-data nextcloud-app /var/www/html/occ versions:expire
    0 [>---------------------------]
    3 [->--------------------------]
    5 [--->------------------------]
    7 [----->----------------------]
   10 [------->--------------------]
   13 [--------->------------------]
   18 [----------->----------------]
   23 [------------->--------------]
   25 [-------------->-------------]
   33 [---------------->-----------]
   35 [------------------>---------]
   37 [-------------------->-------]

执行完成后,空间即可立即释放。

消息盒子

# 暂无消息 #

只显示最新10条未读和已读信息