Mar 5

Auto-detects databases, has the temp file and backup file locations separated, purple colored real-time output, only logs important output, md5sums into a text file for databases, every filename uniquely hashed with month, day, year, hour, minute, and second, timestamps everything, uses bzip2 compression for smallest file sizes.

#!/bin/bash

# vars – no trailing slash please
THEDATE=$(date +%m%d%y%H%M%S)
BACKUPDIR=’/backups/mysql’
TEMPDIR=’/backups/mysql/temp’
LOGFILE=”$TEMPDIR/info-$THEDATE.txt”
USER=root
PASSWORD=password
date > $LOGFILE

date

echo -e “\e[1;35m[ " $(date +%H:%M:%S) "-- Starting MySQL Backup Script v0.3 by Seanp2k ]\e[00m"

# magic
DATABASES=$(mysql --user=$USER --password=$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database)

echo -e "\e[1;35m[ " $(date +%H:%M:%S) "-- Found" $(echo $DATABASES | wc -w) "databases:" $DATABASES "]\e[00m"

# loop -- dump and hash
for DB in $DATABASES; do

echo -en "\e[1;35m[ " $(date +%H:%M:%S)
echo -n " -- Processing " $DB ".."
mysqldump --user=$USER --password=$PASSWORD --databases $DB > $TEMPDIR/$DB-$THEDATE.sql
echo -n "..md5sum..."
md5sum $TEMPDIR/$DB-$THEDATE.sql >> $LOGFILE
echo -e "Done ]\e[00m"
done

# compress and clean
echo -e "\e[1;35m[ " $(date +%H:%M:%S) "-- Creating Archive " $BACKUPDIR/mysql-THEDATE.tar.bz2 "]\e[00m"
time tar -cvvjf $BACKUPDIR/mysql-$THEDATE.tar.bz2 $TEMPDIR/*.sql $TEMPDIR/info-$THEDATE.txt
rm -rf $TEMPDIR/*.sql $TEMPDIR/info-$THEDATE.txt
date
echo -e "\e[1;35m[ " $(date +%H:%M:%S) "-- Finished ]\e[00m”

Feb 1

And the banner at the top read:

“Aaaaaaaaaaaaaaaaaaaa.com

What you need, when you need it”

Somehow, I HIGHLY doubt that.

Jan 23

I had a problem: I wanted my radio station to automagically play my newer music and update the stuff that it plays every day, yet keep enough older stuff that there is still some variety, especially if no new music gets discovered for a while. I’d need to find some way to keep the most recent 200 or so tracks playing on my station.

Let’s start by looking at what we have and what we have to do:
Files on a Linux fileserver playing on a Windows server (via samba) in Winamp using EdCast to stream to sc_serv (Shoutcast) on a different Linux server in the DMZ. Currently, I have the X: drive on the Windows server mapped to the Linux Fileserver. Winamp re-scans the fileserver every 3 days for new music and adds it to the library, but I still have to manually go in and add new tracks to the playlist.

Some initial ideas and problems:
-Use XML-RPC / SOAP from another music cataloging program that I currently use
+I just really feel like there was an easier way to do what I wanted without going through all the trouble.

-Telling Winamp to [re]load the playlist: the Winamp API Uses C++…yuck…I don’t know or want to learn C++ just for this project. Plus, DRY applies, someone HAS to have thought of this before.
+Solution: httpQ, a simple http listener plugin for Winamp that uses a simple and easy to implement control scheme: simply call the right URL and Winamp does what you want. Awesome. ( http://httpq.sourceforge.net )

-Finding files that have been modified recently, and if none have been modified in the time specified, keep looking until you find enough files
Read the rest of this entry »

Dec 25

12-26-08: Edited to acknowledge the hypocrisy of the new even more intrusive video ads to the right on this site. Tehehehehe.

I love Wikipedia, I really do.  In fact, one of the things I really appreciate about Wikipedia and the open-source community in general is the rejection of advertizing and the non-profit nature of it all.  However, sometimes nagware can be annoying, and I refuse to be annoyed by a computer.  One of my favorite Firefox plugins and probably the most useful is Adblock Plus.  Adblock Plus downloads a free, continually updated list of filters for things that should be blocked, and it does an amazing job of killing the ads on most sites without even wasting bandwidth downloading the ads.  Now, this may be great for the user, but I believe that it’s also not too terrible for the advertizers…if people that obviously aren’t going to be click on your ads anyway because they despise advertizing as a whole, why not let them do you a favor and save you bandwidth?  They don’t want to see your crappy banners and annoying flash pop-ups, so why try to get around Adblock?  Just accept it as an advertizing opt-out.  Now, Wikipedia should be accepting of this mentality more than anyone, so it’s with that reasoning that I publish a very simple hack that anyone remotely familiar with the way ABP and javascript works could easily figure out for themselves.  Without further ado, I give you the filter that will remove the annoying header from Wikipedia:

|*centralnotice.js?192xx

Be sure to include the bar “|” at the beginning. As a more generalized filter that would probably block stuff in the future, you could also try:

|*centralnotice.js*

but I have not yet tested it as they have not yet changed their banner. To add this filter, simply pop open ABP and click the “Add Filter” button at the bottom left of the ABP dialog and paste or type it in there. Couldn’t be easier. Enjoy.

Oct 7

I finally got around to getting my radio station working, currently it’s 128kbps stereo and 16 listener limit, we’ll see how things go.  I already have a few people lined up that are supposed to be doing shows and maybe more in store…just trying to work the bugs out right now.  My setup is kind of wacky, but it works…basically I stream from a music server on my LAN to Winamp on a windows 2k3 server to my webserver for final distribution.

http://seanp2k.com:12000/listen.pls

Check it out!

Aug 13

MySQL has become an important part of most Web servers, especially over the last few years. With all those databases, the risk of corruption, intrustion, data loss, hardware failure, and lots of other factors necessitate automated backups.

Luckily, backing up MySQL isn’t nearly as hard as it might sound. Actually, it’s only one command. But, not many people have only one MySQL DB, and dumping all of them to a single file can be hard to parse should you only need to import one. This is easily remedied by making a script run on cron to dump them all individually.

I set this script to run once a week, monday morning at 5am. It generates a logfile as well, info.txt.sl, which contains the date, a list of files, and their MD5Sum. Finally, it uses bzip2 to compress the files efficiently. MD5Sums are critical in determining the integrity of the archive and to ensure the database has not been corrupted or altered since the snapshot was taken.
Read the rest of this entry »