diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php index d943ba139c5afb7e185d7edd18d241c80d0b0d09..5850e527e44380c759f1d3d0823fb58caa52e601 100644 --- a/server/plugins-available/mail_plugin.inc.php +++ b/server/plugins-available/mail_plugin.inc.php @@ -431,7 +431,7 @@ class mail_plugin { if($old_maildir_path != $mail_config['homedir_path'] && strlen($old_maildir_path) > strlen($mail_config['homedir_path']) && !stristr($old_maildir_path, '//') && !stristr($old_maildir_path, '..') && !stristr($old_maildir_path, '*') && strlen($old_maildir_path) >= 10) { if ($mail_config['mailbox_soft_delete'] == 'y') { // Move it, adding a date based suffix. A cronjob should purge or archive. - $thrash_maildir_path = $old_maildir_path . '-' . date("YmdHis"); + $thrash_maildir_path = $old_maildir_path . '-deleted-' . date("YmdHis"); $app->system->exec_safe('mv ? ?', $old_maildir_path, $thrash_maildir_path); // Update the dir's timestamp to make filtering on age easier in any cleanup cronjob. diff --git a/server/scripts/handle_mailbox_soft_deleted.sh b/server/scripts/handle_mailbox_soft_deleted.sh index 7fea4cb839b3e085c520630d10b946747b92324b..f35a37a9395c69cb14e562ba61f0cd81e39f29da 100644 --- a/server/scripts/handle_mailbox_soft_deleted.sh +++ b/server/scripts/handle_mailbox_soft_deleted.sh @@ -4,7 +4,7 @@ delay_days=7 # Test if there is something to do... to avoid 'No such file or directory' from find later. -ls /var/vmail/*/[a-z0-9.-]*-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] >/dev/null 2>&1 +ls /var/vmail/*/[a-z0-9.-]*-deleted-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] >/dev/null 2>&1 if [ $? != 0 ]; then exit 0; fi @@ -36,7 +36,7 @@ echo tar cvfj "$backupfile" --remove-files "$dir" 2> >( grep -v "tar: Removin # -mtime +7 ===> Only mailboxes deleted more then 7 days ago # Test that the last dir component matches e.g. xxx-20220101094242 (14 digits) # command: xxx-`date "+%Y%m%d%H%M%S"` -find /var/vmail/*/[a-z0-9.-]*-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] -maxdepth 0 -type d -mtime +$delay_days | while read line; do +find /var/vmail/*/[a-z0-9.-]*-deleted-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] -maxdepth 0 -type d -mtime +$delay_days | while read line; do # example $line: "/var/vmail/example.com/info-20220101094242" dir=$line