Remove old Ubuntu- / Debian kernel images

#!/bin/bash
KEEP=2
CURRENT=$(uname -r)
KERNELCOUNT=$(dpkg -l linux-image-3* | grep ii | wc -l)
KERNELS=$(dpkg -l linux-image-3* | grep ii | cut -d' ' -f 3)
REMOVECOUNT=$((KERNELCOUNT-KEEP))
REMOVEKERNELS=$(dpkg -l linux-image-3* | grep -v $CURRENT | grep ii | cut -d' ' -f 3 | head -n $REMOVECOUNT)
if [ $REMOVECOUNT -le 0 ];
then
  echo "I was told to keep $KEEP kernel revisions (including current version), but only $KERNELCOUNT kernels are installed. Exiting now."
  exit 1
fi
echo "Currently running on kernel $CURRENT, found $KERNELCOUNT installed kernels:"
echo "$KERNELS"
echo "I was told to keep $KEEP kernel revisions (including current version), so i will remove $REMOVECOUNT old kernel packages."
echo
echo "About to purge kernel versions:"
echo $REMOVEKERNELS
echo
apt-get purge $REMOVEKERNELS

Make sure to be running the latest kernel image that is installed on your system! (also, use at your own risk)

WordPress Backup Shellscript

quick & dirty:

#!/bin/bash
#
# Simple script to backup a wordpress installation.
#
# That is:
#
# mysqldump of database schema
# mysqldump of database entries
# compressed tarball of database backups and wordpress itself
#
#
DATESTAMP=$(date +"%Y%m%d")
DBNAME="wordpress"
SRCDIR="/path/to/wordpress"
TARGET="wordpress-$DATESTAMP"

if [ ! -d $TARGET ];
then
mkdir $TARGET
else
echo "Error: working directory exists, bailing out."
exit 1
fi
echo "Dumping WordPress MySQL DB scheme..."
mysqldump --no-data wordpress -u wordpress -p > $TARGET/wordpress-$DATESTAMP.schema.sql
echo "Dumping WordPress MySQL DB data..."
mysqldump --no-create-info wordpress -u wordpress -p > $TARGET/wordpress-$DATESTAMP.data.sql

cp -rp $SRCDIR $TARGET

if [ ! -f $TARGET.tar.gz ];
then
tar cfvz ./$TARGET.tar.gz $TARGET
if [ $? -eq 0 ];
then
echo "Archive created successfully, removing working directory."
rm -rf $TARGET
exit 0
fi
else
echo "Error: target file exists, bailing out."
exit 1
fi