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
- WEBSITES="/var/www"
- BACKUP_ROOT_WEBSITES="/backup/websites"
- BACKUP_WEBSITES_RETENTION=10
-
- # Starting websites backup
- echo "Starting websites backup process ..."
-
- # Create directories if not exists
- mkdir -p ${BACKUP_ROOT_WEBSITES}
- HOUR=`date +%Y%m%d%H%M`
-
- # Create archive
- for website in `ls ${WEBSITES}`;
- do
- tar czf ${BACKUP_ROOT_WEBSITES}/${website}\_${HOUR}.tar.gz ${WEBSITES}/${website}
- if [ $? -ne 0 ]; then
- echo "ERROR - Archiving website \"${website}\""
- fi
- done
-
- # Purge old backup
- echo "Starting websites purge process for backup older than ${BACKUP_WEBSITES_RETENTION} ..."
- find ${BACKUP_ROOT_WEBSITES} -type f -mtime +${BACKUP_WEBSITES_RETENTION} -exec rm -f {} \;
|