I have setup a few servers with Ubuntu Server and one of the common security tools I use is Fail2Ban.
One of the common requirements that comes with Fail2Ban is the need to provide other administrative personnel with a place they can quickly check which IP’s have been banned. Using a cool program called incron and a short shell script (which I will provide below) I was able to push the contents of the fail2ban log file in more-or-less real time to a plain text file in the web directory. Hence anyone can just visit that page and view a list of banned and unbanned IP addresses.
I have put it off for a long time… You know… actually really deep-diving and really learning a programming language. After reading, and then reading some more, and then talking to some developers where I work (we are a Microsoft Shop from pretty much top to bottom), and then reading a few more things… I have come down to learning in basically this progression (which probably sounds… and probably is… a bit haphazard):
This tutorial assumes you have some experience with Linux administration although I try to hand-hold as much as possible. If you are on a shared hosting solution and don’t have root access, you can easily modify the shell script we will create later to target your user’s home directory on the server.
You also need to know the address of your SQL server. In my case, I am working on a VPS so the SQL server is local (so I just use localhost) but you might need to use a URL or IP where your SQL server is located.
Okay… digging in. Here is the gist’ of it…
1. Create a new user for your MySQL database that will be just for backups
2. Create some folders on your server to store your backups locally
3. Create a script to actually create the database backups, compress them, clean up backups older than 30 days
4. Test the script
5. Setup the script to run as a cron job.
Here we go!