Skip to content

Instantly share code, notes, and snippets.

@jrh-spg
jrh-spg / web_backup.sh
Last active January 9, 2016 19:18
Backup script to backup my document root and MySQL databases to a remote backup server.
#!/bin/bash
LOCKFILE=/tmp/.wb.lck
HOST=web01.fisys.us
BACKUPHOST=25.23.239.150
DOCROOT=/var/www
EXCLUDEDB='schema\|mysql'
EXCLUDE=.git
DATE=`date +%Y-%m-%d.%H%M`
BACKUPDIR=/mnt/backup
BACKUPFILE=$BACKUPDIR/$HOST.backup-$DATE.tar.bz2
@jrh-spg
jrh-spg / ipcheck.sh
Created October 26, 2013 20:05
Script to email you if your home IP changes.
#!/bin/bash
IP=`cat /tmp/ip`
PUBIP=`curl -s http://icanhazip.com`
EMAIL=youremail@domain.com
if [ "$IP" != "$PUBIP" ]; then
echo $PUBIP|mail -s "IP changed at home" $EMAIL
echo $PUBIP > /tmp/ip
fi
@jrh-spg
jrh-spg / named_check.sh
Created June 12, 2013 18:51
Q&D script for monitoring if named is running locally.
#!/bin/bash
contact=name@domain.tld
host=`ifconfig eth0|grep inet\ addr|cut -d: -f2|awk {'print $1'}`
check=`dig +short @$host localhost|awk {'print $1'}`
if [ $check != 127.0.0.1 ]
then
# Uncomment the next line for testing.
#echo "He's dead, Jim."
service named restart
grep named /var/log/messages|tail -300 |mail -s "Named failed on `hostname`" $contact