Cloud Database Backup

Posted May 25th, 2011 (Updated 29 Oct 2011) in Database, Linux

Update 2011-10-12: More storage options! Google Storage, Local HDD, FTP, experimental unlimited Google Docs conversion

Have you ever wanted to ensure that even if your server dies in the most spectacular of ways, your DB is safe? Meet Cloud Database Backup. Cloud Database Backup is a little script I’ve written that allows you to quickly and easily back up your MySQL DBs to the cloud.

Currently you can back your database up to:

  • Amazon S3
  • FTP
  • Google Docs
  • Google Storage
  • Local HDD

Download the script here.

Requirements:

  • MySQL with access to INFORMATION_SCHEMA database
  • php, php5-cli (for S3 backups)
  • python2, python-gdata (for Google Docs backups)

This is an updated version of my old Automatic MySQL Database Backup script that adds support for Google Docs (which now allows uploads of any file type for non-enterprise users), the recently opened Google Storage, as well as local HDD and FTP servers. It does a MySQL dump of each DB separately, zips them all and uploads the zip to your cloud service of choice.

I’ve also added in an experimental ‘db chunker’ which uses this script to split SQL dumps into convertible sizes for Google Docs, allowing you to upload unlimited backups for free; owever due to a reproducible bug in Google Docs, I wouldn’t recommend its use (and it’s disabled by default).

To get started simply update your details in the appropriate places at the top of backup.sh and type ./backup.sh. Presto!

I’ve also included a crontab example to allow automation of backups.

Read More »

Updating Samsung F4 EcoGreen Firmware Without a Floppy Drive

Posted May 10th, 2011 (Updated 29 Oct 2011) in Uncategorized

A while back Samsung released a line of relatively cheap “EcoGreen” 2TB hard drives. Being the storage hungry IT nerd that I am, I picked up 2 of the things before finding out their firmware contains a known data write bug requiring a firmware patch best summed up with the following:

“It [the drive] will “forget” to write out its buffer if certan SMART commands are sent to the drive. This is the very definition of silent data corruption.”
- source

Samsung has released a patch but it requires booting into DOS which is incredibly difficult to do on todays floppyless PCs. After a bit of googling I came across the following two solutions to get the job done:

Bootable ISO image

This is the easier solution of the two but it is also the one that didn’t work for me. Michael has created a FreeDOS image with the patch merged in. For the download and installation details, see this post.

Bootable USB image

After trying and failing the above, I settled for a bootable USB image instead. User ZDOS has written up a handy tutorial here which I’ve detailed a bit more in depth below:

  • Download the Windows 98 system files (at the top) and HP USB Disk Storage Format Tool from here and F4EG.exe from here.
  • Install the HP Format Tool and run it with administrator privileges (right click – Run as Administrator).
  • Extract the Windows 98 system files.
  • With the HP Format Tool, format your USB drive (quick format should be enough) as Fat32 making sure you use the Windows 98 system files where it offers.
  • Once done, copy F4EG.exe to your USB drive.
  • Shutdown and unplug all HDDs besides your unpatched Samsung drive
  • Boot your PC and enter the BIOS by pressing Delete during startup. Ensure that your HDDs are set to run in AHCI mode.
  • Reboot either ensuring USB-HDD is selected as your top boot device or press F12 during startup to visit the One Time Boot Device page (results may vary – check your motherboard documentation).
  • You should see a Windows 98 logo flash on the screen for a split second and then a command prompt. In the prompt type F4EG and press enter. Your drive should flash itself.

For plenty more useful information on this issue, I found this forum thread very helpful.

Read More »

How To Allow Applications Back Into The The Notification Area In Ubuntu 11.04

Posted May 7th, 2011 (Updated 29 Oct 2011) in Linux

One of my last niggling issues with Ubuntu 11.04 is, as you’d expect, another remnant of Unity carried over to the Ubuntu Classic desktop. This remnant is the notification area (or ‘Systray’ to you Windows converts) not allowing all applications access to it. Below is the line you’ll need for bringing Ubuntu back to the 21st century:

gsettings set com.canonical.Unity.Panel systray-whitelist "['all']"

Thanks to the good fellows at Web UDP8 for this little piece of magic.

PS. It appears the VLC icon STILL does not always appear. There’s a question posted on the VLC forums about this issue and it looks as though it’s due to an incompatibility between QT4 and Gnome. Stay tuned for further developments on this issue.

Read More »

Save Firefox 4 Tabs on Close

Posted May 7th, 2011 (Updated 29 Oct 2011) in Uncategorized

It seems firefox 4 has stupidly removed the option to save tabs on exit however there’s a way to get this very useful functionality back. Here’s how:

  1. Type about:config in the URL/Location/Address bar and press the Enter key
  2. Accept the warning message (promise to be careful)
  3. The preferences page/list will open
  4. Filter = browser.tabs.warnOnClose
  5. If its value is set to false, double-click on it (in the lower panel) to toggle its value to true
  6. Repeat steps 4 and 5 for these following 3 preferences also:
    • browser.warnOnQuit
    • browser.warnOnRestart
    • browser.showQuitWarn

Taken from mozilla support. A big thank you to user Helper7677 for this solution!

Read More »

Why I Hate Unity

Posted April 30th, 2011 (Updated 30 Jan 2015) in Linux

Note: Also see the followup to this post: How to Make Ubuntu 11.10 More Usable

So my previous post How to Move App Menus Back Into Their Windows in Ubuntu turned out a little more bitter than even I had first intended. As a result I think it’s only fair I give a few more reasons as to why I have such a strong dislike towards Unity.

Let me preface this post by saying that I was actually quite looking forward to Unity. It looked relatively promising (although I was slightly worried about reports it wasn’t as customizable as Gnome) and after I ended up liking icons on the left when thinking I wouldn’t, I was determined to give Unity a fair go. I would also like to say that many of these issues will probably be sorted out in later bug fixes and updates – but that does not help me right here right now on my shiny new Ubuntu install a few days after release.

So here it is: a ‘by no means complete’ list of reasons using Unity is not a good idea at this point in time.

Read More »

Use .htaccess to Block Pages Based on IP

Posted April 29th, 2011 (Updated 29 Oct 2011) in Uncategorized

Due to the antics of some douchebag (IP address 109.120.34.16) I’ve had to look into blocking pages based on IP address with .htaccess files. This may come in handy to others out there so I figured I’d write up my findings.

To block everyone except specific IPs here’s what you’ll need (more info):

order deny,allow
deny from all
allow from <ip address>

To apply this restriction only to specific files, wrap the above code in the <File> tag:

<Files wp-login.php>
	order deny,allow
	deny from all
	allow from <ip address>
</Files>

Thanks to user NuclearMeltdown on the #httpd channel on Freenode for his assistance.

Read More »

How to Move App Menus Back Into Their Windows in Ubuntu

Posted April 28th, 2011 (Updated 29 Oct 2011) in Linux

You’ve recently upgraded to Ubuntu Natty and discovered that Unity is crap. Don’t worry – you’re in the vast majority. One of the many issues with this disastrous attempt at a shell is that it moves application menus into a global menu in the top panel. This may be useful for small screens – but for the other 99% of the market it’s just downright frustrating.

After a bit of searching I came across this post describing how to banish the global menu back to the warped hell from whence it came. You want to remove the indicator-appmenu package.

This is but one of a great many great challenge you’ll face if you decide to continue on with Unity. Good luck…and may God have mercy on your soul should you choose to stick with it.

Read More »

Fix Firefox Language for Google.com on Ubuntu

Posted April 28th, 2011 (Updated 29 Oct 2011) in Linux

OK so this is an issue I’ve had for a very long time now (since Firefox 4 beta) whereby Google keeps defaulting to a strange language and seemingly completely ignoring my preference for English:

Incorrect language on google.com in Firefox 4

 

The reason for this is a bad language string in Firefox’s settings. You can fix it by doing the following:

Edit - Preferences 
Content - 
Choose... (under Languages)

You’ll see the following language:

chrome://global/locale/intl.properties

Delete it. It’s wrong and it’s causing you problems. Once deleted, time to add your language of choice:

Select Language to add... -
<pick your desired language>

You should now be greeted with a much easier to read google index page!

Here’s hoping this post will make it out in time to save the flood of Ubuntu Natty users on their shiney new Firefox 4 installs :)

Read More »

How to Download Gmail Emails in a Given Label

Posted April 20th, 2011 (Updated 7 Mar 2012) in PHP

EDIT Aug 6 2011: If you’re having trouble connecting to
{imap.gmail.com:993/imap/ssl}
try
{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}
If you get a ‘Too many incorrect logins’ error, you can unlock your account again here.

I’m a big fan of the Android platform and have been using an application called SMS Backup to send all SMS’s to Gmail for archiving (now replaced by SMS Backup+). To cut a long story short, I needed to download those SMS’s with a PHP script. SMS Backup had uploaded them all under the creatively named SMS label and so I needed a way to download all emails with a specified label. It turned out to be a relatively thing to do once you know what you’re looking for.

A quick Google search (I’m such a fanboy) will lead you to this page where a script is provided to download all email from Gmail using the IMAP protocol:

<?php
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'your username here';
$password = 'your password here';
 
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
 
/* grab emails */
$emails = imap_search($inbox,'ALL');
 
/* if emails are returned, cycle through each... */
if($emails) {
 
	/* begin output var */
	$output = '';
 
	/* put the newest emails on top */
	rsort($emails);
 
	/* for every email... */
	foreach($emails as $email_number) {
		/* get information specific to this email */
		$overview = imap_fetch_overview($inbox,$email_number,0);
		$message = imap_fetchbody($inbox,$email_number,2);
 
		/* output the email header information */
		$output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
		$output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
		$output.= '<span class="from">'.$overview[0]->from.'</span>';
		$output.= '<span class="date">on '.$overview[0]->date.'</span>';
		$output.= '</div>';
 
		/* output the email body */
		$output.= '<div class="body">'.$message.'</div>';
	}
 
	echo $output;
}
 
/* close the connection */
imap_close($inbox);

This gets us half way there. Now – to filter by label. As it turns out, this is ridiculously simple. Change the $hostname variable to this:

$hostname = '{imap.gmail.com:993/imap/ssl}SMS';

And with that, ladies and gentlemen, we have a completed script!

…but what if you want to retrieve only your Spam mail (not that you would), your starred mail or your deleted mail? This is also quite possible. After much more Googling I came across this blog post detailing what you need to put in your $hostname. In the instance above, it’d be

$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/Trash';

Read More »

Fixing Perl Locale Errors in a Clean Ubuntu Install

Posted April 6th, 2011 (Updated 29 Oct 2011) in Linux

When performing various actions on a clean install of Ubuntu 10.10 on my web server, I kept being presented with the following message:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US:en",
	LC_ALL = (unset),
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

After some googling, many people (in this thread http://ubuntuforums.org/showthread.php?t=138022) suggested:

sudo locale-gen
sudo dpkg-reconfigure locales

however the solution that worked for me was:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

You might need to reset your machine before changes take effect:

sudo shutdown -r now

Read More »

Page 10 of 15« First...89101112...Last »