You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- #!/bin/bash
-
- # Variables
- MAIL_ROOT="/var/mail"
- BACKUP_ROOT_MAIL="/backup/mail"
- BACKUP_MAIL_RETENTION=31
-
- # Starting mail backup
- echo "Starting mail backup process ..."
-
- # Create directories if not exists
- mkdir -p ${BACKUP_ROOT_MAIL}
- HOUR=`date +%Y%m%d%H%M`
-
- # Create archive
- for domain in `ls ${MAIL_ROOT}`;
- do
- mkdir -p ${BACKUP_ROOT_MAIL}/${domain}
- for account in `ls ${MAIL_ROOT}/${domain}`;
- do
- tar czf ${BACKUP_ROOT_MAIL}/${domain}/${account}\_${HOUR}.tar.gz ${MAIL_ROOT}/${domain}/${account}
- done
- done
-
- # Purge old backup
- echo "Starting mail purge process for backup older than ${BACKUP_MAIL_RETENTION} ..."
- find ${BACKUP_ROOT_MAIL} -type f -mtime +${BACKUP_MAIL_RETENTION} -exec rm -f {} \;
|