Categories
Geek / Technical

Snapback2 How-To

Not too long ago I created my own automated backup script. Shortly afterwards, helpful people sent me links to other, more robust scripts that have been written. One of those was called Snapback2.

Snapback2 is a backup script based on rsync and hard-links. I could explain what that means, but why reinvent an already well invented wheel? Again?

My original script was alright, but it worked by making an exact copy of everything each time it ran. For my 4 GB home directory, backing it up weekly over the course of a month would result in a backup directory that is 16-20 GB in size! That’s a lot of wasted space, especially when some files don’t change at all.

Snapback2 uses hard links and only stores changes between one backup to the next, which means that if I only changed files that were 30MB in size, then the next backup will be 30MB as well. If no changes were made, then no space is wasted at all. Clearly this method is superior to what I have written.

Setting up Snapback2 is supposed to be very simple, but I found that the documentation assumes you know what you’re doing. The following is my Snapback2 How-To:

You can download Snapback2 at http://search.cpan.org/~mikeh/Snapback2-0.5/ for the latest version as of this writing. Technically you should be able to use Perl to download it from CPAN, but I didn’t. Most of the prerequisites should be on your Linux-based system already. According to the documentation, you’ll need:

Gnu toolset, including cp, rm, and mv
rsync 2.5.7 or higher
ssh
Perl 5.8 or higher
Perl module Config::ApacheFormat

On my Debian Sarge system, I have rsync 2.6.4, so your distribution will likely have at least 2.5.7. Similarly, I have Perl 5.8.4. The one thing that you need to do is get and install Config::ApacheFormat. To do so, make sure you have root privileges and run:

# perl -MCPAN -e 'install Config::ApacheFormat'

If it is the first time you’ve used CPAN through Perl, you will be prompted to configure it. If you aren’t sure, you can simply cancel the configuration step and it apparently grabs some defaults just fine. Any and all dependencies will also be installed.

Once you have all of the prerequisites, you can install Snapback2. Again, you could probably do the same thing above to grab it from CPAN, and it will probably grab Config::ApacheFormat for you, but as I didn’t do that, I won’t cover it here.

If you grabbed the tar.gz file from the link I provided above, you should run the following:

# tar xzf Snapback2-0.5.tar.gz

It will create a directory called Snapback2-0.5. The README tells you what to do, but for completeness, here are the next steps:

# cd Snapback2-0.5
# perl Makefile.PL
# make
# make test
# make install

Snapback2 should now be installed on your system. If it isn’t, you should double-check that you have all the prerequisites. The fourth line in the previous list runs tests before installing. If something failed, you should know why from the test results. Even if you did install it successfully, it isn’t going to do anything yet. You now need to make a configuration file.

You can read the documentation setting up the configuration file in the man page for snapback2, but you can also view it online.

Here is my file, snapback.conf:

Hourlies 4
Dailies 7
Weeklies 4
Monthlies 12
AutoTime Yes

AdminEmail gberardi

LogFile /var/log/snapback.log
ChargeFile /var/log/snapback.charges

Exclude core.*

SnapbackRoot /etc/snapback

DestinationList /home/gberardi/LauraGB

<Backup 192.168.2.41>
Directory /home
</Backup>

I didn’t change it much from what was in Snapback2-0.5/examples. I installed Snapback2 on the machine called MariaGB. MariaGB will connect to 192.168.2.41, which is the IP address of my main machine called LauraGB. This is why the DestinationList refers to LauraGB. If I wanted to backup another system, say BobGB, I would keep those backups separate in their own directory called BobGB. Normally, the ssh/rsync request would ask for a password. When I setup the backups to run automatically, it won’t be useful to me if I need to be present to login. You can do the following to create a secure public/private key pair:

$ ssh-keygen -t rsa

The above line will create keys based on RSA encryption, although you could alternatively use DSA. You will be prompted for a passphrase, which is optional. Still, a good passphrase is much better than no phrase at all. Using the defaults, you should now have two files in your .ssh directory: id_rsa and id_rsa.pub. The first one is your private key. DO NOT give it to anyone. The second one is your public key, which you could give to anyone. When setting up key-based authentication, you will append the contents of this file to the server’s .ssh/authorized_keys file. Next time you login, instead of being prompted for a password, you will find yourself at a prompt, ready to work. For more detailed information, read this document about using key-based authentication with SSH.

So now, if I run the following command on MariaGB:

# snapback2

It will backup any changes from LauraGB’s /home directory to MariaGB. If, however, it hasn’t been an hour since the last backup, it won’t do anything.

Still, manually running this command isn’t very useful, and while I could install a cron job to run snapback2, I will instead make sure that snapback_loop is running. It acts as a daemon, checking to see if a file gets created in /tmp/backups. Now I can create the following entry in my crontab:

# Create file for snapback_loop to run
0,30 * * * * touch /tmp/backups/snapback

So now, every 30 minutes, I create the file /tmp/backups/snapback, which snapback_loop will take as its cue to delete that file and run snapback2. Then snapback2 will make a backup if there has been enough time since the last backup was made.

Now, I have automated backups that run regularly. Some caveats:

  • Verify that snapback2 is in /usr/local/bin. On my system, snapback2 would run manually, but snapback_loop would output errors to /tmp/backups/errors that weren’t too clear. I had to create a symlink to /usr/bin/snapback2 in /usr/local/bin in order to get it to run.
  • Make sure snapback_loop is running with root privileges. It has to call snapback2, which will need access to files in /var/log and other directories which will have restricted access. If you run it as a regular user, you may get errors. You could also change the location of the log file, but /var/log is a standard spot to keep such output.
  • Because you are running it with root privileges, you’ll need to make sure root is the one with the public key in authorized keys rather than your user account. Otherwise, you’ll get errors like “permission denied” when rsync tries to connect to the other machine.

If you don’t use a second computer, you can always use a second hard drive instead. Either way, you now have an effortless system for automating your backups!

Categories
General

Learning Kyra: Tiles and Z-Ordering

Another entry in the Learning Kyra series. The series to date:

  1. Learning Kyra
  2. Learning More Kyra
  3. Learning Kyra: Attack of the Clones

The first three entries in the series documented my attempts at learning about the engine. I had a goal to become more familiar with the engine by the end of the month, so those articles were more focused. While that month has since passed, I am still learning plenty about the engine.

Recently I learned how to create tiles. Originally I was creating sprites, and they are sufficient for making games. However, I can also use tiles, but the documentation warns:

A Tile — in contrast to a sprite — is always square (width == height.) It can be rotated and flipped, however. You should always use Sprites unless you need to rotate and flip the image.

Making sprite images and making tile images are similar activities. When I use the Kyra Sprite Editor, I need to specify tile instead of sprite. Tiles are simpler since I do not need to mark hotspots and verify that they are aligned correctly. I was able to get three tiles very quickly, and saving created the .xml file to use. Then I used the Kyra Encoder and created the appropriate .dat and .h files. I copied those over to my source code directory.

The code to load a tile is different from the code to load a sprite, and the tutorial doesn’t cover it. I had to look at the Bug-Eyed Monster (BEM) demo code to find an example that I could use. To load a sprite, you have to do a few steps:

  1. Load the .dat file
  2. Get the KrSpriteResource as specified in the header file you created
  3. Create the KrSprite from the KrSpriteResource

Loading a tile is a little more complex:

  1. Load the .dat file
  2. Get the KrResource
  3. Get the KrTileResource by using KrResource::ToTileResource()
  4. Create the KrSprite from the KrTileResource

Ok, so there is only one more step, but it took me some time to find how to retrieve a KrTileResource. For instance, to get the KrSpriteResource, there is a function: GetSpriteResource(name_of_resource). To get a KrTileResource, however, you first need a generic resource by using GetResource(ALLCAPS_TAG, name_of_resource), and I couldn’t find the documentation on what that tag should be. It turned out that they were defined in kyraresource.h, and the one I needed was KYRATAG_TILE. Again, it was not in the tutorial so it took some work for me to learn what was needed. Here is the relevant code, keeping in mind that when I used the encoder, I prefaced everything with Tiles2_ (I already had a previous attempt with Tiles_) :

KrResource* res = engine->Vault()->GetResource( KYRATAG_TILE, Tiles2_tile2 );
GLASSERT( res );
KrTileResource* tileRes = res->ToTileResource();
GLASSERT( tileRes );
KrTile* tile = new KrTile( tileRes );
GLASSERT( tile );

tile->SetPos( 130, 98 );
tile->SetRotation(1);
engine->Tree()->AddNode(0, tile);

Anyway, I imagined that the tiles I created would be pretty cool to work with since they have alpha transparency. I could make clouds or chain-link fences, for instance. As I moved a sprite to the tile, I expected that the sprite would show through the tile’s transparent spots; however, when adding an image to the engine’s tree, the order matters. Since I added the sprite after the tile, the sprite image overlapped the tile image. I switched the order in the code, and it worked perfectly fine.

But then I was concerned. In a game, elements will get added dynamically. I wouldn’t want to find that a new enemy can walk over tunnels, or that the hero walks under floor tiles! Then I learned how the BEM demo handled Z-Ordering.

Everything that can be in the engine’s tree inherents from the base class KrImNode. KrSprite and KrTile are both KrImage classes, and KrImage is a KrImNode. KrImNode isn’t an abstract class, and it is the key to handling Z-Ordering.

Usually when I add a sprite or tile to the engine, I use the following code:

engine->Tree()->AddNode(0, tile);

AddNode()’s first parameter in this case is 0, which means that in the tree, it is a child of the root. If I add a second child, it will be drawn over the first child when the following code gets run:

engine->Draw()

BEM handles Z-Ordering by creating subtrees. Background images should be added to the backgroundTree while foreground images should be added to the foregroundTree. You create those trees in the following way:

KrImNode* backgroundTree = new KrImNode;
KrImNode* foregroundTree = new KrImNode;

engine->Tree()->AddNode(0, backgroundTree);
engine->Tree()->AddNode(0, foregroundTree);

Now, when I create a tile that goes in the background, I use AddNode(backgroundTree, tile1). Naturally I would have a separate subtree or two for entities I want to always be between the background and the foreground. If I need to create tiles for the foreground, I can add them to the foregroundTree:

engine->Tree()->AddNode(foregroundTree, tile2);

And tile2 will always be drawn on top of any images that are siblings to tile1, even if I add an image to backgroundTree after adding tile2.

Now that tiles and the Z-Ordering methods are added to my toolbox, I’m becoming much more dangerous with the Kyra Sprite Engine. Using just what I know now, I can probably make a fairly simple game without struggling with an unfamiliar library. There are still a few features to learn, however, including:

  • Fonts
  • Alpha blending and color transformations
  • Scaling
  • Canvases
  • Sub-window views

I may tackle one or two of these in the next Learning Kyra post.

Categories
General

Reading in 2005

Earlier this year, I noticed some developers are making book lists on their blogs. Sillytech and Joost Ronkes Agerbeek’s lists are two of them. I have been keeping a private list of books I am reading and have read, but I think it will be useful to post the list online as well.

I plan on having a sidebar similar to what is on Games From Within. In the meantime, you can see a listing in this blog post.

Books I Am Currently Reading

  • On Writing by Stephen King

Books I Have Read in 2005

  • 100 Ways to Motivate Yourself by Steve Chandler (Audio Book)
  • Alice’s Adventures in Wonderland by Lewis Carroll (ebook)
  • C++ Coding Standards by Herb Sutter
  • The Curious Incident of the Dog in the Night-Time by Mark Haddon
  • First Things First by Stephen Covey
  • Getting Things Done by David Allen
  • Live Without a Net by Lou Anders (Editor)
  • The Object-Oriented Thought Process by Matt Weisfeld
  • Ready for Anything by David Allen
  • The Seven Habits of Effective People by Stephen Covey
  • Through the Looking Glass by Lewis Carroll (ebook)

Some people try to read at least one book a week. It’s the 18th week or so for the year, so I am about six books behind. I never actually set such a goal, of course, but I should. I’ve found that I can have much more intelligent conversations and tell much funnier jokes (at least to me) since I’ve started reading regularly. I have learned so much more than I would have if I had neglected the literature, and some of it, such as Getting Things Done, has changed my life in amazing ways.

I’ve found that I’ve been focusing on personal productivity a bit too much, so I’ve tried to add works of fiction to the mix. Besides science fiction, I’m interested in mystery novels as well, but I am not familiar with what is good outside of Sherlock Holmes and Hercules Poirot. Anyone have any suggestions?

Categories
Game Development Personal Development

Goals and Habits: Program for 5 hrs/week

Since I think coding practice should be a higher priority in my life, I’ve scheduled two days out of the week to program. Monday and Tuesday evenings after work, I will spend at least two hours programming. Four hours of the week can easily be accounted for there, and I could always do more on those days and others.

Previously I assumed I could squeeze time out of my week to program, but since I didn’t have any hard rules about it, I never did it. The thinking was that I could always program “tomorrow”, and of course tomorrow always had its own excuses.

Eventually procrastination became a habit. If I did have time in front of my computer, I ended up checking email or configuring something that I didn’t need to configure at that moment. Even now I catch myself getting distracted too easily during my programming time. I find myself trying to check my email or reading blog entries and have to force myself to continue programming.

Breaking old habits is hard, as everyone knows. I recently bought Steve Chandler’s 100 Ways to Motivate Yourself audio book. I listen to it in the car and am amazed at how much education you can get in a 30 minute drive. One of the things he talks about is breaking bad habits. He says we can’t simply drop bad habits. We must replace them with better habits. In my situation, I simply need to get my mind to think that it is time to program whenever I am in front of my computer instead of having it think that it is time for recreational web browsing. He also talks about will power and the need to exercise it. The more we practice control, the stronger our will becomes. The two tips go hand in hand.

Each time I refuse to check my email during my designated programming times, I get that much closer to replacing habitual time wasters like useless email and web browsing with habitual productive activities. Building will power in this way applies elsewhere. For instance, each time I make myself check my calendar before making a committment, the more useful and powerful my calendar becomes. Each time I check my lists when I am deciding on my next action, the more important my lists become to me, which means I’ll use them more.

Creating good habits and getting rid of old ones is great for accomplishing goals. If I make a regular habit of programming each day, I simply have to hit my goal for the week, and therefore I can’t NOT hit my goals for the month. As Chandler says, “It’s mathematical.”

Categories
Game Development

Chicago Indie Gamer Meeting for April

Today was the Chicago Indie Gamer Club meeting for April. I was not able to accomplish my goals for this month before the meeting.

As bad as I may feel for failing, I’m really glad this meeting exists. In the past, I’ve had spurts of game development between periods when I didn’t do anything. Without the deadline this meeting imposes on me each month, I may not even notice that I’ve spent a week or two not working on my projects. I probably would coast into May without realizing how much time has gone by since I last coded.

I know I had setbacks at the beginning of this month. The hardware failures and reinstallation of my main computer required that I take some time to recover to get to the point where the system was usable again. I had a couple of games to review. I was updating my resume. I wrote some scripts to help with automating backups.

But even with those excuses, I clearly failed. I never made programming the priority that it should be. I should not be trying to squeeze in some coding time around the rest of my schedule. Instead, I should dedicate blocks of time to coding and have everything else fall around them. For example, I just reinstalled Kyra on my system this past week. My computer has been operational since the beginning of the month. So why the delay? I wasn’t programming, so I wasn’t using the library. I didn’t need Kyra installed if I wasn’t using it, so I never noticed that it was not installed until recently. So when I was ready to code the other day, I had to spend some time installing a library that should have already been ready to use. I spent the little time I had spared just getting the system ready, and it resulted in lost practice time.

I plan to rectify these issues with the goals I set for next month. Even though I never mentioned them at the meeting, I’ll list them here:

  • Block out time for regularly scheduled programming
  • Continue to practice programming for 5 hours per week
  • Make a simple game by the end of the month
  • Setup an automated build system by the end of the month
  • Setup a cross-complier on my system by the end of the month

The first goal is kind of a metagoal. It is primarily to help me accomplish the next goal. If I have regularly scheduled programming practice, I can’t possibly miss my goal of programming so many hours per week. The third goal is likely going to be worked upon during my practice times. While I could work on anything to satisfy the second goal, I can also be efficient and kill two birds with one stone.

The last two goals are important. The automated build system will make the process of building the project from scratch incredibly easy. I don’t manually compile my code at the moment since I use GNU Make, but I have to manually invoke make each time I want to use it. That option is nice to have, but I can easily miss something in the full build. I don’t want to create a demo download that won’t actually install on a potential customer’s computer because it was missing a file. Automating the builds will help by removing the concern to do testing and builds from my mind. I can discover the results and work from there rather than worry about the correct steps to carry out.

The cross-compiler will make it possible for me to use a single code base on a single system and build for multiple platforms. I can currently compile for Linux-based systems, but I would like to compile my projects as Windows applications as well. Rather than copy the code to a Windows machine and run a Windows-based compiler, I can use a cross-compiler on my Debian machine and make it compile a Win32 binary. I will need to test it to verify that it works obviously, but I would be testing the native binaries as well.

I don’t believe my goals are overly difficult or ambitious, but even if I don’t accomplish everything, I know I can accomplish at least some of them. By the end of May, I hope to have great, tangible results.

Categories
Game Development Personal Development

What Happened to my Productivity?!?

It’s April 19th. The Chicago Indie Game Developer meeting is in less than six days. My goals for this month were to continue programming for 5 hours per week and to complete a simple game. While the month isn’t over yet, I haven’t accomplished these goals at all.

Last month was great. I programmed. I learned how to use Kyra. I learned a lot.

This month, I hit a stumbling block right away when my video card needed to be replaced. I also spent some time updating my resume to look for a full-time job. I have a couple of game reviews to do for Game Tunnel. Still, if I claim that all of these things prevented me from accomplishing my goals, I’d be lying to myself. My computer was back up and running within a few days of the problem. I didn’t spend more than a few hours total over a week on my resume. And I haven’t been playing the games too much either.

So where did my time go? Actually, the more accurate question is, “How did I squander my time?” How did I let an hour or two go by without at least doing something for a few minutes that is related to my goals? Even if it was an overwhelming amount to do, which is certainly not the case, at least ONE thing could get completed, right?

This past week I’ve been in a funk because I feel like I haven’t accomplished anything at all. My game review is overdue, my job search hasn’t really started yet, and I haven’t coded anything since I reinstalled. It doesn’t help at all that I may be getting sick as well. I’m feeling stressed and worried, which wastes my energy, which only serves to make me feel more stressed and worried.

So April is a bust.

Or is it?

While I can’t do anything about the delays at the beginning of the month, I’m allowed to reset my goals. Clearly I failed in programming for the past three weeks, but nothing prevents me from doing so for this week. I haven’t created the game, but nothing prevents me from trying to make a simple game in less than a week. It’s been done before, and I’ve already mentioned my intent to participate in my own Game in a Day. Perhaps I won’t finish the game. But attempting to do so puts me in a better position than where I am currently, so that’s reason enough for me.

Nothing prevents me from accomplishing my goals. Except me.

Look at that. My stress is gone. It’s been replaced with resolve. Fancy that.

Categories
General

The Courage to Take a Seat

Last night I went to a seminar hosted by my university’s Alumni Association. It was called Four Under Forty, a play off of Crain’s Chicago Business’ annual Forty Under Forty. Four members of the list were on the panel at the seminar, including this past year’s David Marco and Mike Domek, as well as last year’s Thad Wong and Noreen Abbasi. The panel members were asked a series of questions, and it was an interesting event.

Among a few themese I noticed was the idea of courage. Thad Wong simply exuded confidence and made the claim that he believes he could do anything anyone else has done. Nothing should be impossible for him if someone else can do it. But even then, believing in himeself was key to his success. David Marco made similar comments.

I was thinking about courage when I went home afterwards. I was reading Stephen Covey’s book First Things First and specifically his treatment on the need for courage. And with this topic on my mind, I saw something happen on the train that seemed appropriate.

There was a woman sitting with a bag sitting next to her. The train was getting quite crowded, and I saw some people walking towards the seat, only to turn away once they saw her bag there. Maybe three or four people acted similarly, turning away as if turned away from a fountain. Then one person got on the train, walked up to the seat, and simply asked the woman if she could move her bag. The woman complied. This new person won her seat on the train because she wasn’t afraid of what might happen if she asked. She simply did it.

And if that isn’t an oversimplifed metaphor for what courage can do for your business, I don’t know what is. You can’t win unless you play. Whether it’s just getting a seat on the crowded train or starting your own business, if you don’t attempt to do it, you force yourself to stand and watch as someone else does.

Categories
Geek / Technical

Automating Backups: I Reinvented the Wheel

I already knew that I had reinvented the wheel when it came to writing my automated backup solution. I spent some time researching this topic, and I found a number of resources.

Of course, as soon as I posted my results on the LUNI mailing list, I got email from helpful people pointing out that there are other projects that are out there and have been tested. Way better than what I had, and much more optimized. My solution was making multiple copies of my data, resulting in multiples of gigabytes of storage, whereas some of these solutions are clever and use much less space.

So in true blog fashion, here are some links:

Categories
Geek / Technical

Automating Backups for Fun and Profit

At the end of last month, I mentioned that I had bought a new hard drive for the purposes of backing up my data. I just now installed it in my second computer. Was getting the backup system in place important? Yes, absolutely! I don’t think that a hard drive might fail. I know it WILL fail.

While I could just simply copy files from one drive to the other manually, it depends on me to do so regularly. I’m only human, and I can forget or get sick, resulting in potentially lost data. Computers are meant to do repetitive tasks really well, so why not automate the backup process? My presence won’t be necessary, so backups can take place even if I go on vacation for a few weeks or months. The backups can be scheduled to run when I won’t be using the computer. Copying lots of data while trying to write code, check email, and listen to music at the same time can be annoyingly slow, but if it happens while I am sleeping, it won’t affect my productivity at all. Also, while the computer can faithfully run the same steps each time successfully, I might mess up if I run the steps manually and in the wrong order. So with an automated system, my backups can be regularly recurring, convenient, and reliable. Much better than what I could do on my own week after week. I decided to make those concerns into my three goals for this system.

I’ll go over my plan, but first I’ll provide some background information.

Some Background Information
LauraGB is my main Debian GNU/Linux machine. MariaGB is currently my Windows machine. The reason for the female names is because I am more a computer enthusiast than a car enthusiast. People name their cars after women, so I thought it was appropriate to name my computers similarly. For the record, my car’s name is Caroline, but she doesn’t get nearly the same care as Laura or Maria. My initials make up the suffix, GB. I guess I am not very creative, as my blog, my old QBasic game review site, and my future shareware company will all have GB. Names can change of course, but now I see I am on a tangent, so let’s get back to the backup plan.

LauraGB has two hard drives. She can run on the 40GB drive, as it has the entire filesystem on it, but the 120GB drive acts as a huge repository for data that I would like to keep. Files like my reviews for Game Tunnel, the game downloads, my music collection, funny videos I’ve found online, etc. It’s a huge drive.

For the most part, I’ve simply had backup copies of data from the 40GB drive to the 120GB drive. I also had data from an old laptop on there. Then I started collecting files there, but they don’t have a second copy anywhere. If I lose that 120GB drive, I could recover some of the files, but there is no recovery for a LOT of data. Losing that drive spells doom.

At this point, MariaGB can become much more useful than its current role as my Games OS. With the new 160GB drive, I can now have at least two copies of any data I own.

The Backup System
I spent the past few weeks or months looking up information on automating backups. I wanted something simple and non-proprietary, and so I decided to go with standard tools like tar and cron. I found information on sites like About.com, IBM, and others. I’m also interested in automating builds for projects, and so I got a lot of ideas from the Creatures 3 project.

On Unix-based systems, there is a program called cron which allows you to automate certain programs to run at specific times. Each user on the system can create his/her own crontab file, and cron will check it and run the appropriate commands when specified. For example, here is a portion of my crontab file on LauraGB:

# Backup /home/gberardi every Monday, 5:30 AM
30 5 * * 1 /home/gberardi/Scripts/BackupLaura.sh

The first line is a comment, signified by the # at the beginning, which means that cron will ignore it. The second line is what cron reads. The first part tells cron when to run, and the second part tells cron what to run. The first part, according to the man page for crontab, is divided as follows:

field allowed values
—– ————–
minute 0-59
hour 0-23
day of month 1-31
month 1-12
day of week 0-7

So as you can see, I have told cron that my job will run at 5:30 AM on Mondays (30 5 * * 1). The asterisks basically tell cron that those entries do not matter.

The second part tells cron to run a Bash script I called BackupLaura.sh, which is where most of the work gets done.

Essentially, it gets the day of the month (1-31) and figures out which week of the month it is (1-5). There are five because it is possible to have five Mondays in a single month. Once it figures out which week it is, it then goes to my 120GB drive and removes the contents of the appropriate backup directory. I called them week1, week2, etc. It then copies all of the files from my home directory to the weekX directory using the rsync utility. I use rsync because using a standard copy utility would change the file data, resulting in files that look like they were all accessed at once. Rsync keeps the same permissions and date access times as they were before the backup.

So tomorrow at 5:30 AM, this script will run. As it will find that the date is 11 (April 11th), it knows that it is in the second week. So the directory week2 will be emptied, and then all files will be copied from my home directory to week2.

That’s all well and good, but you have probably noted that every week, the weekly backup erases the same week’s backup from the month before. When this script runs on May 9th, week2 will be erased, losing all of April’s 2nd week backup data! I’m ok with that.

Here’s why: every 1st Monday of the month, the script will make the week1 backup, but it will ALSO make a monthly backup. It takes week1 and runs another utility on it called tar. Multiple files can be combined into one giant file by using tar. The resulting file can also be compressed. Most people on Windows will create .zip files using similar utilities, but tar fits the Unix programming philosophy: a robust tool that does one thing really well.

Usually tar is used with utilities like gzip or bzip2, but sometimes compression is avoided for stability reasons in corporate environments. Compressing might save you a lot of space, but on the off chance that something goes wrong, you can lose data. And if that data is important enough, the risk isn’t worth the space savings.

In my case, I decided to use bzip2 since it compresses much better than gzip or LZW (what .zip files are compressed with). If I corrupt something, it isn’t the end of the world, since bzip2 has the ability to recover from such problems. So the script will take the directory week1 and compress it into a file with the date embedded in the name. The appropriate line in the script is:

tar -cvvjf $BACKUP_DIR_ROOT/monthly/LauraGBHomeBackup-$(date +%F).tar.bz2 $BACKUPDIR

The $BACKUPSOMETHING are variables in the Bash script that I had defined earlier, but they basically tell the script where to go in my filesystem. The file created is “LauraGBHomeBackup- “+ the date in YYYY-MM-DD format + .tar.bz2. The script runs date +%F and inserts the result in the filename. The file is placed in the directory called monthly. I can manually clean that directory out as necessary, and since the dates will all be unique, none of the monthly backups will get erased and overwritten like the weekly backups.

Conclusion
And so now the need to do backups has been automated. Every week, a copy of my home directory is synced to a second hard drive. Every month, a copy of the data will be compressed into a single file named by date to make it easy for me to search for older data. What’s more, cron will send me an email to let me know that the job ran and also tell me what the output was. If I forgot to mount the second hard drive for some reason and the script couldn’t copy files over, I’ll know about it Monday morning when I wake up.

Once MariaGB is up and running, I can configure the two systems to work together regarding the monthly backups. After the .tar.bz2 file is created, I can then copy it from LauraGB’s monthly directory over to MariaGB in a directory to be determined later. Of course, normally when I copy a file from one machine to another, I would need to manually enter the username and password. I can get around this by letting the two systems consider each other “trusted”, meaning that the connection between the two can be automated, which is consistent with one of the goals of this system. I’m very proud about what I have created, and I am also excited about what I can do in the future.

Currently LauraGB’s home directory has images, code, homework files, game downloads, and other files taking up 4GB of space, which clearly won’t fit on a CDROM uncompressed. To improve my backup system, I will need to purchases a DVD burner. I can place a blank CD in the drive and have the computer automatically burn the monthly backup when it occurs, giving me another copy of my data, one that I can then bring anywhere. Ideally, remote backups would complete my system, but I think I will use those only for specific data, such as my programming projects and business data when I get some. Losing my music files and pictures in a house fire aren’t going to be as big of a conern as the fire itself, but losing sales info, game code, and the customer database, essentially THE BUSINESS, would be something that I probably won’t easily recover from.

For now, I am mitigating the disaster of a failing hard drive, which is my main concern. If you do not have your own backup system in place, either something homemade like my setup or through some commercial product, you’re walking on thin ice. Remember, hard drive failure isn’t just a potential event. It’s a certainty. It WILL fail. Prepare accordingly.

Categories
Games Politics/Government

Senior Advisor to Governor Responds to My Concerns

Awhile back I had sent a letter to Illinois Governor Rod Blagojevich. I received a generic form letter that didn’t address any of my concerns. I sent a second email to Safe Games Illinois asking someone to answer my questions. I figured I would receive a response from someone other than the Governor, but not the Senior Advisor!

Anyway, here’s the content of the letter (misspellings or other typos are likely mine):

Mr. Berardi:

Thank you for your two letters concerning the Governor’s Safe Games Illinois initiative. Although this administration may disagree with many of the arguments in your letters, we appreciate your interest in the issue.

You outline four broad concerns in your letter and I will try to address them one at a time.

Your first question deals with existing laws that limit minors’ access to materials such as books or movies with violent or sexually explicit content. Illinois law already restricts minors’ access to certain harmful material, as dictated by the state’s Harmful Material Statute (720 ILCS 5/11-21). This law prohibits minors from buying a broad range of sexually explicit material – materials such as pornographic books or magazines. So laws do in fact exist that prohibit children’s access to media other than video games.

Your second concern questions why the Blagojevich administration is singling out violent and sexually explicit material in video games and not in other media that may be potentially harmful to children. It has become painfully apparent that video game retailers are not self-regulating and that they continue to sell adult-rated video games to minors. In October of 2003 the Federal Trade Commission released a study which found that underage teens were able to purchase M-Rated games 69% of the times they tried. A press release for this study is available on the web http://www.ftc.gov/opa/2003/10/shopper.htm. Last January State Representative Paul Froehlich (R-Shaumburg) sent a 15-year-old boy to 15 retail stores in the Northwest Suburbs and found that this boy was able to purchase M-rated games at 11 stores. Whether such inappropriate purchases are part of a widespread problem or not, this administration thinks that no child should be able to purchase these types of video games without his or her parents’ supervision.

Your third concern is regarding the administration’s efforts to educate parents about inappropriate video game content. One of the critical components of the Safe Games Illinois initiative is to educate parents about the harmful effects that violent of sexually explicit video games have on children. A large portion of the Safe Games Illinois website is dedicated to providing parents with information on particularly violent or sexually explicit video games as well as with links to organizations that consistently monitor and rate the various video games that are arriving on the market. Here are three Safe Games links that you might find useful:

Also, one of the mandates of the Safe Games Illinois Task Force, a body comprised of many individuals who are parents, is to educate parents on the harmful effects that violent or sexually explicit video games have on children. It is the opinion of this administration that if parents are educated about the dangers of these video games and their children cannot legally buy these games without parental permission, then violent video games are less likely to be played by an inappropriate audience.

Your final concern dealt with the wording of the propose Safe Games Illinois legislation and the legislation’s definition of violent. The legislation’s current definition of “violent” video games include those games with:

Depictions of or simulations of human-on-human violence in which the player kills, seriously injures, or otherwise causes serious physical harm to another human, including but not limited to depictions of death, dismemberment, amputation, decapitation, maiming, disfigurement, mutilation of body parts, or rape.

I don’t think any reasonable interpreation of this definition would exclude children from purchasing age-appropriate games – such as Super Mario Bros or Donkey Kong.

If you have further questions about the bill, I strongly encourage you to take a look at the web site for House Bill 4023, maintained by the Illinois Legislature:

http://www.ilga.gov/legislation/billstatus.asp?DocNum=4023&GAID=8&GA=94&DocTypeID=HB&LegID=20889&SessionID=50

Thank you again for your letter.

Sincerely,
Sheila Nix
Senior Advisor to the Governor
State of Illinois

I’ll admit that I am ignorant of the laws regarding materials deemed harmful for children. According to Sheila, this law prohibits children from being sold pornographic books or magazines. So, where’s the analogous violent content law that does the same, which is what I was mainly concerned about?

The statistics they were using were presented in a way to insinuate that children are buying violent video games in droves or that it is an epidemic. For example, in this letter “underage teens were able to purchase M-Rated games 69% of the times they tried”. Ok, but how about commenting on studies that say that it isn’t happening that often in real life? That children DO tend to get their parents’ permission or have their parents present when they buy these games?

Another choice quote: “Whether such inappropriate purchases are part of a widespread problem or not, this administration thinks that no child should be able to purchase these types of video games without his or her parents’ supervision.” Ok, and because the motion picture industry is so effective at self-regulation, we won’t pass a similar law to stop the one or two instances when a child CAN get into an R-rated movie? I mean, even if it isn’t part of a widespread problem, doesn’t this administration think that no child should be able to view such movies? Perhaps I’m being petty, but I think the example is analogous.

And regarding the wording of the law in question, I’ve played games where the main character dies as a result of non-human characters or where the main character isn’t human. Are those allowed to depict death or dismemberment without falling under this law?

Someone in the ASP games newsgroup pointed out that if a law like this is passed, who pays for the rating system? How much would it cost to get a rating on a game to sell it in Illinois? How long will it take to get the rating? A mainstream game might have a million dollar budget and so the publisher might consider the cost to be a drop in the bucket, but an indie title does not usually have the means. Whatever the cost is, it will be significant to the indie. In any case, such a requirement would be harmful to the industry while having only dubious arguments to support it at the most.

Looks like I have another letter to write.