mail_backup.sh 623 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. # check if backup folder exists if not exit script
  3. ###
  4. if [ ! -d /backup ]; then
  5. exit 1
  6. fi
  7. # check if backup folder is to big / then delete all files older then 12 days
  8. ###
  9. size=$(du -s /backup | awk '{print $1}')
  10. if [ $size -gt 140000000 ]; then
  11. find /backup/Mailcow -mtime +12 -type d -exec rm -rf {} \;
  12. size=$(du -s /backup | awk '{print $1}')
  13. if [ $size -gt 140000000 ]; then
  14. find /backup/Mailcow -mtime +10 -type d -exec rm -rf {} \;
  15. fi
  16. fi
  17. # create new backup
  18. ###
  19. MAILCOW_BACKUP_LOCATION=/backup/Mailcow /opt/mailcow-dockerized/helper-scripts/backup_and_restore.sh backup all