Scripts

Clean Vcard:
This awk one liner will search your vcard file (vcf) for blocks that only have telephone numbers and prints them to std out.

awk ‘/BEGIN/ {p=1}; {a[NR]=$0}; /TEL/ {f=1}; /END/ {p=0; if (f==1) {for (i in a) print a[i]}; delete a;f=0}’ filename.vcf

MySQL Backup:

#!/bin/sh
#Written by Shawn Rapaz on May 13th, 2013
#This script backups up the complete MySQL database nightly.

curDate=”/bin/date +%Y-%m-%d”
DATESTAMP=`/bin/date “+%Y-%m-%d”`
BACKUP_DIR=”/root/backups/database_dumps/”

echo “Starting hourly backup of MySQL database (full)…”

#Does the pgsql dump and compresses it with bzip2
mysqldump –all-databases -u root -pPASSWORD > /tmp/alldatabases_nightly.sql
/bin/mv /tmp/alldatabases_nightly.sql /tmp/alldatabases_nightly-$DATESTAMP.sql
/usr/bin/bzip2 /tmp/alldatabases_nightly-*.sql

#This moves the hourly backup to the backup directory
/bin/mv -f /tmp/alldatabases_nightly-*.sql.bz2 $BACKUP_DIR

echo “Postgresql hourly backup completed.”

# look for files in archive directory and remove any that are older than 3*24hrs from current date of script starting
echo “Removing files older than 3 days”
find $BACKUP_DIR -type f -mtime +3 -exec rm {} \;
echo “MySql nightly dump completed at $DATESTAMP”
exit 0

Dirvish Run All:

#!/bin/bash

#Removes expired backups
/sbin/dirvish-expire

#Runs all dirvish backups
/sbin/dirvish-runall