Topic: Empty backup folders left behind after 90 days
==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.9
- Deployed with iRedMail Easy or the downloadable installer? No
- Linux/BSD distribution name and version: CentOS 7.7
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Apache
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
The backup script /var/vmail/backup/backup_mysql.sh leaves behind empty folders.
Is it possible to have the script clean them up after removing the last backup file from the folder?
# du --max-depth=1 /var/vmail/backup/mysql/2019 | sort -k2,2
682572 /var/vmail/backup/mysql/2019
4 /var/vmail/backup/mysql/2019/01
4 /var/vmail/backup/mysql/2019/02
4 /var/vmail/backup/mysql/2019/03
4 /var/vmail/backup/mysql/2019/04
4 /var/vmail/backup/mysql/2019/05
4 /var/vmail/backup/mysql/2019/06
253956 /var/vmail/backup/mysql/2019/07
234640 /var/vmail/backup/mysql/2019/08
185072 /var/vmail/backup/mysql/2019/09
8876 /var/vmail/backup/mysql/2019/10
[root@nebula ~]#
If you choose to remedy this, then I contribute this suggestion.
# if [[ $(ls -A1 /var/vmail/backup/mysql/2019/01/ | wc -l) -eq 0 ]];then echo empty; fi
empty
#
Of course "echo empty" would really be "rmdir ...."
And this would need to be done for the year-level directory too.
Thanks, Rob.
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.