Archive for January, 2008
I have several websites that I administer. As any good site admin will tell you, making consistent backups is vital. I have a script that I originally got from this site that I use to back my sites up automatically, using cron. Here’s how I do it, and how I have modified the script slightly for my own purposes.
First off, create a php text file. I named mine site_backup.php. You will need to modify this with your site and email info. This script will create a archive file with the name backup.<day>.tar.gz, where <day> is the number of the current day of the month. Every day of the month the number will change, thereby leaving you with a month’s worth of backups in your /home directory, that will be overwritten the next time the day of the month is the same.
<?php $emailaddress = "yourname@emailaddress.com"; $target = "/home/".get_current_user()."/backup.".date(d).".tar.gz"; if (file_exists($target)) unlink($target); system("tar create preserve gzip file=”.$target.” –exclude-from=/public_html ~/mail”,$result); $size = filesize($target); switch ($size) { case ($size>=1048576): $size = round($size/1048576) . ” MB”; break; case ($size>=1024); $size = round($size/1024) . ” KB”; break; default: $size = $size . ” bytes”; break; } $message = “The <yoursitename> website backup has been run.\n\n”; $message .= “The return code was: ” . $result . “\n\n”; $message .= “The file path is: ” . $target . “\n\n”; $message .= “Size of the backup: ” . $size . “\n\n”; $message .= “Server time of the backup: ” . date(” F d h:ia”) . “\n\n”; mail($emailaddress, “<yoursitename> backup message” , $message, “From: Website <>”); ?>
One of my sites has a few directories that are loaded with graphics, all of which I have backed up elsewhere. I wanted to exclude those directories from the tar archive. If you have used tar by itself, you know this is an easy thing to do, but I had not done so in a script before. Fortunately, you do it the exact same way you would usually do it from the command line. Since we are using the “system” call in PHP, all we need to do is make sure our syntax is correct for tar.
After a quick look at the GNU tar man page to confirm how to use
--exclude
I noticed that I didn’t need to put all the directories directly in the script. This was news to me, and so I was happy I had read through the man page, discovering the
--exclude-from
option.
I created a text file, which I’ll call backupexclude, and included it in my /home directory. In it I listed each directory I wanted to exclude, one directory per line. Here’s an example
~/foldertoexclude1 ~/directory/subdirectorytoexclude1 ~/skipthis
Simple, huh?
To run it from the command line, you just type “php ~/site_backup.php” without the quotes. This way you can backup your website and email folders any time you want.
To call up the script using cron, add a line like this to the cron file (or added in whatever way your web host has configured cron jobs to be added by you).
# run at 2:15am every day of the month 15 2 * * * php ~/site_backup.php
January 30th, 2008
If you are like me, you have a ton of passwords you have to remember. I have different login names and passwords for bank accounts, forums, blogs, email, and other stuff. How do you deal with it all? How can a person possibly remember them all, especially the ones that only get used once every month or two, or just a couple of times in a year?
One option, that I rejected years ago, is to use the same login and password everywhere. If a person were to choose a good, strong password, this would be secure, but only until any one of the several sites was compromised and the password data stolen. Is that likely? Maybe not, but this seems like an unnecessary and foolish risk to take.
So what to do? I use the same login on a few sites, but some sites have a login specific only to that site. Every site gets a different password. Some people like to use a basic, strong password as a framework, and add to it a suffix or prefix for each site. I just choose something completely different everywhere. This leaves me with the unenviable task of trying to remember all of them…actually, that task is not only unenviable, it is impossible.
Thankfully, I found a cool program called Revelation Password Manager. Revelation is a graphic-based password management program that uses AES encryption for data storage. It is easy to use, intuitive, and aims to be HIG compliant. There is a cool feature where at the click of a mouse Revelation will generate a strong password for you, and I also like the fact that one may copy the data file from one computer to another, or store it on a usb key, and it can be opened on any computer that has Revelation installed.
There are lots of great ways to do this. You could use gpg and encrypt a text file, leaving you able to open it anywhere you had access to gpg. There are other quality programs out there that do the same thing as well. I especially like TrueCrypt for encrypting data. However, every other solution I have used takes me longer and doesn’t have as nice of a feel to me as Revelation. If you are in the market for something like this, check it out and see if it will be a good fit for you as well.
The Revelation website has a series of screenshots for those interested and the program is available in the Ubuntu repositories, so installation is a piece of cake for Ubuntu users. Just install the “revelation” package using apt-get, aptitude, Synaptic, or whatever your favorite method is, and then look in the Applications->Accessories menu (if you are using Gnome as your desktop) for the Revelation Password Manager entry. Simple.
January 22nd, 2008
This week I noticed several new mentions of Humor and Moroccan Culture scattered around the web. These are two of my favorites. Take a look! You might find these interesting. I did. Thanks to the site admins and authors.
As of today, HAMC is #78 on the AOL list of top products in humor. That’s really cool and encouraging!
Someone at squareONE made a comic strip based on a joke from HAMC.
January 19th, 2008
I currently live in North Africa, Morocco to be specific. For the most part, I am very pleased with my internet service provider (Maroc Telecom). Up/download speeds are consistently good, and I almost never have downtime. There have been very occasional service issues, but those could be just as easily attributed to my language skills as to the company.
I do have a major complaint, though. The big thing is that there are some services and content being blocked here. Here is my list, at least the things I know of and can recall right now.
Google Earth, Google Maps, OpenDNS, LiveJournal, anonymizer.com, multiproxy.org, and on occasion You Tube.
I realize this could be thwarted using a proxy like JAP or by using TOR, but I don’t need any of these enough to do that, and it isn’t the main point of my little rant.
All I’m doing today is drawing some attention to the issue. If you are interested in reading further, please take a look at the Global Voices advocacy site and MoTIC (French).
January 15th, 2008
Just a silly post today to welcome in the new year.
I am honored to have the respect of my friends. I am also amused at the times where people come to me for advice on things that I would never consider within my areas of expertise. Today I received two amusing phone calls of this type.
One of my friends is in the process of building a professional recording studio. He has chosen some great equipment and is in the process of getting the rooms tuned perfectly. He called me this morning to come over and help him with something. I arrived, and he led me into the control room to show me a brown wall. It didn’t look very good. He then asked me to look at the colors in the studio, the natural pine and the red, padded baffling that were already in place, and then choose a good complementary color for around the window on the wall between the studio control room and the vocal isolation booth. I chose something similar to #ECC75F.
Just two minutes ago I had another friend call me to ask me my advice on the best way to cook a chicken. Since the guy is single and not known for cooking at all, I figured telling him to fill a bowl with some flour, a bit of pepper, a pinch of salt, and some crushed corn flakes, then dipping the cut chicken pieces in milk and rolling them in the flour until lightly coated and dropping them in a pot with a quarter inch of hot oil in it, leaving them there until cooked all the way through, would be a good place to start.
Apparently my friends are convinced I have talents that I have never claimed. It’s an honor, but one that made my wife a bit jealous as she listened to me give a recipe over the phone. I freely and publicly confess she is by far a better cook than I will ever be. She’s probably a better decorator as well.
Oh, and a very Happy New Year to everyone!!
January 1st, 2008