Skip to content

Instantly share code, notes, and snippets.

@tsohr
Created August 14, 2014 00:20
Show Gist options
  • Select an option

  • Save tsohr/2b47c28e46647a63643e to your computer and use it in GitHub Desktop.

Select an option

Save tsohr/2b47c28e46647a63643e to your computer and use it in GitHub Desktop.
#!/bin/bash
DIR="$( cd "$( dirname "$0" )" && pwd )"
pushd "$DIR" > /dev/null
tar -z -p -c -f `date +"%Y%m%d-%H%M%S"`.www.gz -C / -P /etc/httpd/ /srv/www/
BACKUP_CNT=`ls *.www.gz | wc -l`
if [ "$BACKUP_CNT" -gt "15" ]; then
LAST_BACKUP=`ls *.www.gz | sort | head -n 1`
rm -f $LAST_BACKUP
fi
popd > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment