Rotating backup my self hosted wordpress sites with a bash script and a cron job

Getting hacked sucks! I have never been able to recover from the last hack that I suffered. So Disaster Recovery is a priority. The last couple of days I've rebuild my blog on my own Linux server with NGINX, PHPFPM, and MySQL. Today I went ahead and created 4 folders, one for each week of the month, assuming 4 weeks per month. I wrote a quick backup.sh script, and setup a cron job with :
cd "$(dirname "$0")" value=$(cat count) value=$(($value%4 + 1)) echo $"tar -czf /opt/backups/week$value/www.tgz /var/www" tar -czf /opt/backups/week$value/www.tgz /var/www echo $"mysqldump --all-databases | gzip > /opt/backups/week$value/data.gz" mysqldump --all-databases -u root -p $MYSQL_PASSWORD | gzip > /opt/backups/week$value/data.gz echo $value > count
This script reads from a file, in order to keep count of which week it currently is. So you will need that in the same directory. Then I used this command to install the cron job
crontab -e
And used this to make it run every Thursday at 2 am.
# m h dom mon dow command 0 2 * * 4 /opt/backups/backup.sh
Next step is actually testing DR process by simulating a disaster and recovery. Here is a video if you need more information: