server-tools !?!
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. # Variables
  3. MAIL_ROOT="/var/mail"
  4. BACKUP_ROOT_MAIL="/backup/mail"
  5. BACKUP_MAIL_RETENTION=31
  6. # Starting mail backup
  7. echo "Starting mail backup process ..."
  8. # Create directories if not exists
  9. mkdir -p ${BACKUP_ROOT_MAIL}
  10. HOUR=`date +%Y%m%d%H%M`
  11. # Create archive
  12. for domain in `ls ${MAIL_ROOT}`;
  13. do
  14. mkdir -p ${BACKUP_ROOT_MAIL}/${domain}
  15. for account in `ls ${MAIL_ROOT}/${domain}`;
  16. do
  17. tar czf ${BACKUP_ROOT_MAIL}/${domain}/${account}\_${HOUR}.tar.gz ${MAIL_ROOT}/${domain}/${account}
  18. done
  19. done
  20. # Purge old backup
  21. echo "Starting mail purge process for backup older than ${BACKUP_MAIL_RETENTION} ..."
  22. find ${BACKUP_ROOT_MAIL} -type f -mtime +${BACKUP_MAIL_RETENTION} -exec rm -f {} \;