Nevar pievienot vairāk kā 25 tēmas
Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
|
- #!/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 {} \;
|