ALL files retention - is it possible ?

yes there is a difference!

  • Nextcloud Enterprise = Professional paid support!
  • Nextcloud community forum = hobbyist voluntary support

If you run a licensed Nextcloud Enterprise, then it is highly advisable to contact Nextcloud GmbH support!


I’m not a developer and any real developer would probably laugh at my scripts calling me a novice.
While this is absolutely true, my scripts do what I expect them to do.

Here’s an example script for deleting all files in a defined path, min. directory depth 2, older than 7 days. you’ll need to adjust it to suit your needs i.e. valid path to OCC php-bin.

  #!/bin/bash

##############################################################
# DESCRIPTION #
##############################################################
# Find and delete all files from a defined nextcloud path 
# older than 7 days, run script daily as root cronjob
##############################################################
# VARIABLES #
##############################################################
LOG=".../logs/nextcloud-cleanup.log"  ## define path to logfile
TARGET="/.../nextcloud/data/__groupfolders/1"  ## define target 
##############################################################
# SCRIPT #
##############################################################
### become root for manual issue, otherwise root crontab
sudo pwd;
### find and delete files and directories! mindepth 2
sudo find $TARGET -mindepth 2 -mtime +7 >>$LOG ;
sudo find $TARGET -mindepth 2 -mtime +7 -delete ;
### Nextcloud cleanup jobs
echo "SCAN FILES AND PERFORM SOME MAINTENANCE";
sudo occ files:repair-tree -n -vvv;
sudo occ files:scan --all -n -vvv;
sudo occ files:scan-app-data -n -vvv;
sudo occ files:cleanup -n -vvv;
## force purge trashbin per user and groupfolders
echo "PURGE TRASHBIN";
sudo occ trashbin:cleanup --all-users ;
sudo occ groupfolders:trashbin:cleanup -f ;

exit

WARNING

:warning: Use scripts at own risk. Adapt them to your needs, but be careful and double check!

Notice how almost every line is commented? That’s because I like to know what is happening and if I don’t write it down I’m bound to forget!

If you found what you need, that’s great and you’re welcome :diving_mask: :ok_hand:

NOTE

If you find any errors or typo’s, you can keep 'em :rofl:

1 Like