server-tools !?!
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.

27 lines
719 B

  1. #!/bin/bash
  2. # Variables
  3. WEBSITES="/var/www"
  4. BACKUP_ROOT_WEBSITES="/backup/websites"
  5. BACKUP_WEBSITES_RETENTION=10
  6. # Starting websites backup
  7. echo "Starting websites backup process ..."
  8. # Create directories if not exists
  9. mkdir -p ${BACKUP_ROOT_WEBSITES}
  10. HOUR=`date +%Y%m%d%H%M`
  11. # Create archive
  12. for website in `ls ${WEBSITES}`;
  13. do
  14. tar czf ${BACKUP_ROOT_WEBSITES}/${website}\_${HOUR}.tar.gz ${WEBSITES}/${website}
  15. if [ $? -ne 0 ]; then
  16. echo "ERROR - Archiving website \"${website}\""
  17. fi
  18. done
  19. # Purge old backup
  20. echo "Starting websites purge process for backup older than ${BACKUP_WEBSITES_RETENTION} ..."
  21. find ${BACKUP_ROOT_WEBSITES} -type f -mtime +${BACKUP_WEBSITES_RETENTION} -exec rm -f {} \;