Category Archives: Webdevelopment

Dreamhost How to Use Cronjobs to Email Backup MySQL Databases

I’ve been using Dreamhost for a while (works great btw), I had been backing things up manually but I thought it was about time to start automated mysql backups. Looking around online I found these instructions but they simply say to modify the instructions and add this mutt command

mutt -a /home/username/backups/archives/mysql_backup.$suffix.tar -s "MySQL Backup"

to get e-mail backups working. In reality, this command will merely open up mutt and create a new message but it will not automatically send it without additional input. Buried online I found someone else who said to simply:

mutt -s "MySQL Backup" < /home/username/backups/archives/mysql_backup.$suffix.tar

which does automatically e-mail you, but it just dumps the file into the e-mail body without attaching it as a document. What that statement is really doing is piping in body text and completing the e-mail prompts magically, which isn’t what I wanted to do. The solution is to:

mutt -a /home/username/backups/archives/mysql_backup.$suffix.tar -s "MySQL Backup" < emailbody.txt

What this gives you is an attachment of your file, and then it pipes in an e-mail body (put it in the same location that this script is running from) and sends the message. You would also use echo statements to “type” whatever additional input you wanted in mutt and script the rest of the message completion [untested but it conceptually should work, YMMV]

Full Script:

cd /home/username/backups/
mkdir mysql
suffix=$(date +%y%m%d)
mysqldump --opt -uUser -ppass -h db_nameA > mysql/db_nameA.$suffix.sql
mysqldump --opt -uUser -ppass -h db_nameB > mysql/db_nameB.$suffix.sql
tar -cf archives/mysql_backup.$suffix.tar mysql/*
mutt -a /home/username/backups/archives/mysql_backup.$suffix.tar -s "MySQL Backup" < emailbody.txt
rm -r mysql/

Googlebot Crawl Rate for Blank Website

I’ve got a blank site that I’ve had hosted for a while now and I was adding all of my websites to Google’s Webmaster tools. Interestingly the site crawl statistics tell us that Google’s bot will crawl a index.html only site (with no changes over 6 months of crawling) every 4.5 days.  If you take a look at the graph below, you’ll see the crawler looked at the page 20 time over 90 days, or every 4.5 days.  You can also see the variety of site response time from my host.

Google Crawler Frequency Statistics

Google Crawler Frequency Statistics

So for those of you paranoid about when Google will crawl your site next to get updates, it shouldn’t be more than 4.5 days assuming it’s not a brand new site.  The rest of my sites are crawled daily. . .

Microsoft Closes Hotmail Account

I’ve had a Hotmail account for years, and today I went to sign into it to retrieve and old e-mail address and was met with:

Hotmail Account Closed

Which is interesting in an of itself, you would think that rather than having a link to ANOTHER form, they would have just put the form at the bottom of the page, or better yet have a challenge or a captcha (that’s better than the obviously insufficient one that let the spammers create the account in the first place) to let me reinstate my account after proving I’m a human.  So instead they send me off to yet another page:

Another Account Closed Message

Hmm, interesting, the same as the first page, except now they let me know that I probably didn’t violate their TOS (actually I’m sure I have doing something, not that they’re actually noticed).  Additionally, there isn’t a form to fill out here, in fact there’s barely even a contact e-mail at the bottom of the page – but alas, I can’t use my e-mail account!!! Somebody fails here, as they’ve suspended my e-mail account.  So now what I would have to do is sign up for e-mail with somebody else! Great move, drive customers to OTHER service providers so they can send you an e-mail begging for their account back.

I was eventually able to figure out that my account had been sending spam messages, so either the password was too weak and dictionary attack got it, I logged into this account through a bad access point and someone pulled it from the traffic, or I was on a computer with a keylogger/malware that pulled it.  I rarely use the account except for MSN/Live Mesh, when I log into Hotmail I go directly to the page from a browser so I really doubt I got hit by someone phishing with a fake site.

Moral of the story: use strong passwords and change them often, other moral is if you’re designing a web interface make sure you have a logical system set up for your users, in this case likely there are many programmers at M-soft and somebody never checked the links.