Building a Home Media Server with Raspbmc: Part One

When the Raspberry Pi first came to market, I suffered through quite a few conversations with my geeky, gadget-loving, early-adopter friends who thought it was the greatest thing since Coke Zero. To them, it was a cheap and powerful device with potential limited only by their imaginations. To me, it was just another gadget. It looked interesting. And I was sure it was a lot of fun to hack around on. But I was also sure it was one more thing that would compete for my time and that it would ultimately lose, finding itself gathering dust on my shelf of sad, forgotten gadgets.

It was only recently that I came across the Raspbmc project and my attitude towards the Raspberry Pi changed. For years I’ve intended to build an HTPC. I’ve always wanted a device that could serve as a one-stop media center for my music, photos, television shows, movies, and video podcasts. I’d grown quite tired of the constant chore of hooking up my laptop to the television just so I could watch Hulu Plus or Netflix on a big screen. And truth be told, I really had my heart set on a MythTV box. But every time I sat down to spec out a machine, I always found a more practical project to throw money at. When I learned about Raspbmc, I realized I could still end up with a device that solved all of my media center needs, but without the cost of building a full-blown HTPC.

In this series of articles, I’m going to talk about my adventures with Raspbmc. But before I do, I’m sure there’s one or two of you out there who are completely new to the whole Raspberry Pi scene. So in this first article, I’m just going to briefly discuss what the Raspberry Pi and Raspbmc is all about. In the next few articles, we’ll get into the meat and potatoes of my Raspbmc project.

“What is a Raspberry Pi exactly?” Well, it’s a very small computer – about the size of a credit card. Model B Rev 2.0, which is the latest revision as of the time of this writing, features 512 MB of RAM, a 700Mhz ARM 11 processor, a GPU, 2 USB ports, both an HDMI port and an RCA video port, an Ethernet port, an SD card slot, and a variety of GPIO pins for the hardware experimenters out there. Considering you can get all of this for around $35 + shipping, that’s quite an offering. I’ve read that this device is comparable to an iPhone 3G, although the GPU supposedly outperforms the iPhone 4S by a factor of 2. It’s quite impressive, especially considering these things were meant as educational devices.

There are a few things lacking from the Raspberry Pi worth taking note of. First, there is no storage. No storage means no preloaded operating system. You supply the storage by way of an SD card. This means you also have to download an OS appropriate for your project’s needs and flash it to the SD card. Second, there’s no case. When you buy a Raspberry Pi, you’re purchasing a bare board. It comes in an anti-static bag inside a mostly plain white box. How you mount it, encase it, or display it is entirely up to you. Unless you need easy access to the GPIO pins, I highly recommend you invest in a cheap case. Otherwise, you risk damaging it. Third, it doesn’t come with a power adapter. Power is supplied to the Raspberry Pi through a Micro USB port. But you’ll need a Micro USB power source capable for delivering at least 700mA. When I went rifling through my collection of cell phone and tablet chargers, none of them were capable of delivering that amperage. So I had to purchase a new one from Amazon. One other thing worth noting is that the regular USB ports on the Pi are limited in how much current they can supply. If you need to use a device that requires anything more than 100mA (e.g., an unpowered external hard drive), you’ll need to use a powered USB hub. Otherwise you risk damaging your Pi.

Now, what is all this Raspbmc business? Raspbmc is a port of XBMC (formerly Xbox Media Center) for the Raspberry Pi. It’s a media center platform, similar in concept to MythTV, Windows Media Center, SageTV, etc. But out of the box is lacks PVR functionality. It’s open source and has a fairly extensive feature set, including support for playing video, music, photos, and provides facilities for extending the platform’s capabilities through plugins (accessing stream services, web browsing, screensavers, etc). Controlling the device can be accomplished using a mouse and keyboard, a web based interface, your tablet or phone, or even an IR remote control. And because Raspbmc is based off of Linux, you have the ability to easily remotely administrator the device. It’s quite flexible and whole lot of fun for those who like to tinker.

Excited? Great. Now for some discouraging words. I’m not not sure I’d recommend Raspbmc for someone who doesn’t have a whole lot of patience. Nor would I recommend it for technologically challenged folks who are just looking for a cheap alternative to the Roku or Apple TV. It’s somewhat easy to setup, but it’s not perfect. It does require some persistence to get it working optimally. It took me a month before I reached a configuration I was happy with. We’ll talk about some of the issues I faced when configuring the Pi in a later article. So just consider this a warning.

In the next article, I’ll talk briefly about hardware, including cases, power supplies, hubs, and memory. In part three, I’ll go over the software installation, mention a few of the things that caught me by surprise, and in part four I’ll mention a few tricks that made the Pi work best for me.

Improving the SodaStream

Last Christmas, Leora gave me a SodaStream. Before then, I hadn’t even heard of the thing. And for someone with my level of soda addiction, it seemed like the greatest, most magical gift in the world.

If you’ve never used a SodaStream before, the idea is pretty simple. You attach a CO2 tank to your SodaStream, fill up a liter sized bottle of water, attach the bottle to the SodaStream, press a button a few times, and BAM! – you have soda. “What about flavorings?” you ask. SodaStream sells some fantastic soda mixes that are remarkably close to their major brand counterparts. And I do mean remarkably. SodaStream’s Fountain Mist (or, as I call it, Mountain Fist) and Orange mixes are two of my favorites. I often have a hard time telling them apart from their major label counterparts.

The SodaStream devices vary in price, but they’re not terribly expensive. I think mine cost around $80 or so. The mixes are also pretty cheap – usually around $4.99 for a 12 liter supply depending on where you buy them. The most painful thing about the SodaStream is the CO2. The 14.5 oz. CO2 tanks are small – I get about 3-4 weeks of use out of one. And because the tanks use a proprietary fitting, you can’t just take them to just any ole place to have them refilled. You either have to either buy a brand new tank for around $35 or exchange your old tank for a new one at around $15. Doing the math for a year, that’d put me at around $195 on CO2 alone.

There is a cheaper way to deal with the whole CO2 issue I’ve discovered. Not long after I exchanged the first CO2 tank, I spent a little time learning about gas, tank fittings, and a bit about home brewing, which has a few things in common with home soda making. I decided to take the plunge and “augment” my SodaStream. I purchased a 10 lb. aluminum tank and a special fitting for hooking the thing up. I made a small modification to the SodaStream so that I could hook up the new tank. I also had the 10 lb. tank filled with CO2 for less than $20. I suspect it’ll be a while before I need to worry about running out of CO2.

If you’re thinking about doing the same with your SodaStream, here are some things to keep in mind.

Tanks – You’ll want to make sure you purchase a beverage grade CO2 tank with a CGA 320 fitting.

I came across a lot of conflicting information online concerning what qualifies as a beverage grade tank and whether or not it even matters. It does matter. Beverage grade tanks are made from aluminum. Tanks made from any other material may introduce contaminates and, in the case of lead-lined tanks, may even pose health risks. Beverage grade aluminum tanks aren’t hard to find. I found mine on Amazon for around $80.

The CGA 320 fitting is a very commonly used fitting found on CO2 tanks. Home brewing places like to deal with kegerator-style CO2 tanks, which also use this type of fitting. There’s nothing preventing you from using another type of connector. But it may be harder to find someone who can fill up your tank. It may be even harder to find the right adapter for connecting the tank to the SodaStream.

Connectors – I don’t have much to say about this except that a quick Google search will turn up a number of vendors that sell CGA-320-to-SodaStream connectors. I bought the Freedom One model from CO2Doctor. My experience with these folks was pretty awesome. They were quick to answer my questions and help me troubleshoot my hookup issues. I had my tank hooked up and working in no time.

  

CO2 – Finding a local place to fill my tank took a little bit of work, but not much. I started out calling the restaurant supply places and beverage distribution companies, all of which turned out to be dead ends. I then talked to a couple of shops that specialize in home brewing supplies. They were able supply me with CO2, but only if I agreed to exchange my empty tank for a full one and they wanted to charge me $30 to do it. In the end, I found a local welding supply company who agreed to fill the tank for $18. That’s a lot of CO2 for cheap.

Hooking It All Up – Because my SodaStream didn’t provide a good place for me to run the hose through, I had to drill out a tiny hole in the base so that the machine could sit right on top of the hose. The SodaStream fitting can be hand tightened, but it’s very important that you tighten the fitting connecting to the CO2 tank with a wrench. Otherwise, you’ll leak gas all over the place. Hand-tight isn’t enough.

  

  

Once everything is hooked up and ready to go, you’ll find that you’ll need to experiment a little bit to find the right number of presses to get the carbonation you’re accustomed to. The pressure coming into the SodaStream from the new tank will be different than from the original SodaStream tank. So the recommended formula of three farty sounds probably won’t result in something you’ll be happy with. For my setup, I usually pump it until I get the three sounds, lift the bottle to release the pressure, and pump it again for three more sounds. Also, be careful when you add the mix. If you go carbonation crazy like me, you’ll find adding in some of those mixes quickly can result in a soda volcano.

Have fun and good luck!

Rolling Your Own NAS with FreeNAS: Part Three

Part one of this series was devoted to a high level discussion of network storage. I talked about the types of options available, some of their pros/cons, and I outlined some of the things I wanted in a storage solution for myself. In the end, the whole article turned out to be one long-winded argument for a roll-your-own NAS solution.

Part two of the series was devoted to hardware. I actually built a FreeNAS device for myself. And I listed all of the components I selected for use in my own machine and touched upon some of the reasons I chose them.

And now we’ve made it to part three, the final installment of the series. Here we’re finally going to dig in to the meat and potatoes of this project – FreeNAS itself. I’m going to tell you where to get it, how to install it, and what you need to do to make it work. This is where things start to get fun.

FreeNAS First Steps

The obvious first step here is obtaining FreeNAS. As the name suggests, FreeNAS is free. You just need to download and install it. If you visit www.freenas.org, you’ll see download links on the right-hand side of the page. There are a number of options available to you, including 64-bit versions, 32-bit versions, upgrades, plugins, etc. For new installs, you can safely ignore everything other than the 64-bit or 32-bit downloads.

The choice of 64-bit vs. 32-bit really comes down to hardware compatibility. If you intend to use over 4 GB of RAM and all of your hardware has 64-bit driver support under FreeBSD, you’ll want to download the 64-bit version of FreeNAS. Otherwise, you’ll want to opt for the 32-bit version. Note, however, that if you do use the 32-bit version, the OS won’t be able to use more than 4 GB of RAM. This isn’t a FreeNAS limitation. It’s a 32-bit OS limitation. Other operating systems suffer from it too.

Once you’ve decided on the bit-ness of your OS, you’ll want to decide on how to install/run FreeNAS. The main page of the FreeNAS website only lists download links for ISOs. But there’s another option – the compressed disk image.

An ISO image is just a CD-ROM image, which in this case just so happens to be bootable. If you intend to install FreeNAS to a hard drive, this is what you’ll want to use. Just use your favorite CD burning software to burn it as an image and not a file. After you burn the CD and boot from it, you’ll be walked through the FreeNAS installation process. The process is fairly straightforward. It really just amounts to selecting which drive or partition you want to install the software to.

The IMG file, which is what I opted for, is a disk image of the operating system that you essentially “blast” onto a drive. It’s built for users who want to run the OS from a USB stick or a CF device. But why would you want to do such a thing? I did it to make my RAID configuration simpler.

If you want to use a software RAID, then you must install FreeNAS into a non-RAIDed drive. This means you’ll need separate storage for both your OS and RAID. Think about that for a minute. If you want to use FreeNAS’s RAID support, FreeNAS needs to be able to start up. But it can’t start up if it’s on a RAIDed drive. It’s the classic chicken vs. egg problem.

The flipside of that is if you choose to use a hardware RAID, you can install the OS wherever you want. But you’ll sacrifice available public storage since the OS will be included as part of the RAID. It’s a tradeoff.

To obtain the compressed disk image, you’ll need to visit the FreeNAS SourceForge site (http://sourceforge.net/projects/freenas/) and browse through their files until you find what you want. The compressed image files have the extension “img.gz”. When I built my machine, the latest version of FreeNAS was 8.0.4 P1, so the file I downloaded was FreeNAS-8.0.4-RELEASE-p1-x86.img.xz.

After you download the IMG file, you’ll need to write it to a USB key or a CF device. The recommended way to do this is by using a tool called Win32DiskImager (https://launchpad.net/win32-image-writer). The user interface for this application is fairly straightforward. But one word of caution: be mindful of the drive you’re selecting for writing. I’ve read a few stories of folks accidentally writing images to their PC boot drive and totally ruining their day. Double and triple check your target drive before hitting that “Write” button.

Booting It Up

The first time you boot FreeNAS the following boot menu will appear on your screen, but only briefly. If you wait a few seconds, FreeNAS will start booting up in its normal default mode.

After the boot menu has its chance to vie for your attention, all sorts of stuff will start flowing down the screen. This is normal. But you may have to sit through this for a few minutes in order for FreeNAS to completely boot. A lot of stuff is happening here – hardware detection, system configuration, the starting of services, etc. Assuming no errors occur during the boot process, you’ll eventually be presented with a screen that looks like the following.

There are a couple of things worth noting in this screenshot. The first is that from here you have some basic control over network configuration, you can obtain a root shell if needed, and you can also reboot or shutdown the machine. However, you’ll notice that there’s no mechanism here for configuring RAID arrays, advanced network settings, services, user accounts, etc. Well, as it turns out, this isn’t the primary interface for managing your FreeNAS server. We’ll get to that in a moment, however.

Just above the “Enter an option…” line, you’ll notice a URL. If FreeNAS was able to acquire an IP address using DHCP, then this URL points to the FreeNAS machine. This URL allows you to access the FreeNAS device from a web browser on another machine. What you’ll see in your browser is what I like to think of as the “business-end” of FreeNAS. This is where the real configuration happens.

Note that because of differences in network configuration, your URL will most certainly be different than the one shown above.

FreeNAS Configuration

When you first point your web browser to your FreeNAS machine, you’ll see something that looks like the following.

Down the left hand side of the page are categories of options. The main area to the right displays the settings for the currently selected configuration options. And near the top is a toolbar-like interface for quick access to commonly used option pages as well as things like “Help” or “Alerts”.

Notice the state of the “Alerts” button. When all is well with your system, this button is green. But if something bad happens, or if something needs your attention, the button will turn red as shown in the screen shot. In this instance if we click on this button, we learn that no admin password has been set for the machine. Whoops! We can remedy this by clicking on the “Account” button, selecting the “Change Password” tab, and setting a password for the admin user. Once you do this, the button should turn green.

From here, I’m only going to cover the configurations applicable to my own FreeNAS project. FreeNAS has a lot of excellent documentation and there have been entire books written on the platform. So instead of going down the proverbial rabbit hole, I’m going to show you what my setup looks like. Don’t let my approach be the last word. Read the FreeNAS documentation. If you have a needs different from my own, that’s where you’ll learn how to make FreeNAS cater to them.

Network

Once you change the admin password, the next thing you’ll want to do is visit your network settings. By default, FreeNAS uses DHCP to acquire an IP address, DNS info, gateway info, etc. And since you probably don’t want the IP address of your server changing all the time, you need to set it to something more stable.

Beneath the “Network” category on the left, you’ll see a subcategory entitled “Interfaces”. A fresh install will have no interfaces listed here. This might seem odd because FreeNAS obviously knows there’s a network interface. After all, you’re connected to the machine over HTTP from another machine. But, alas, you’re going to need to explicitly add the network interface here in order to configure it.

Just as a side note, most DHCP servers (consumer grade routers fall into this category) have the ability to designate a particular IP address for a particular MAC address and/or mark an IP address as being unassignable to machines using DHCP. You’d be wise to add your FreeBSD machine’s IP address to the list so the DHCP server doesn’t try to assign it to another machine. Otherwise, you might start noticing weird network behavior.

Storage

If you expand the “Storage” category and the “Volumes” subcategory beneath that, you’ll see a number of options for managing your storage. Since this is a fresh install of FreeNAS, there won’t be any volumes listed. So we’ll need to create a new one. Click on “Create Volume” and a popup will appear that gives us a number of options for creating a storage volume.

The pop up allows us to name the volume, select which hard disks are participating, pick a file system type, and, if you’ve selected multiple hard disks, what type of RAID to use. The storage name can be anything.

In our example system, I’ve given our volume the uninspired name, “storage”. I have two hard disks that are 53.7 GB each. I selected them both and opted for a mirror configuration, which is equivalent to RAID1. I also selected UFS as the file system.

A word about file systems. UFS (Unix File System) is the default file system on FreeNAS. It’s a slower performer than ZFS. But it works well on machines with limited resources. ZFS is a high performance file system, but it requires a lot of resources to use. The FreeNAS documentation describes the pros and cons of using one vs. the other. But the gist of it is if you’re not using a 64-bit machine and you’ve not much RAM to work with, forget about using ZFS.

Once you click on OK, the volume will be created and you’ll see it appear under the “Volumes” category. This doesn’t automatically make it available to other computers, though. We’ve got a little bit more work to do. Specifically, we need to enable and configure the appropriate network file system service.

For my purposes, I need the storage to be available to an assortment of devices – Windows, OSX, Ubuntu, and Android devices. This means using a network file protocol all of them can understand. And with Windows machines in the mix, the choice is simple – CIFS (formerly SMB). CIFS is the Windows share protocol. And it still being a Microsoft world, most other operating systems offer CIFS support. OSX supports CIFS out of the box, just about all Linux distros know how to mount a CIFS share, and Android devices can connect to CIFS shares with the appropriate app (e.g. ES File Explorer). So CIFS it is.

CIFS isn’t on by default. So it’ll need to be configured and enabled. Beneath the “Services” category you’ll see the “CIFS” subcategory. Clicking on that will open the CIFS configuration dialog.

There are a lot of options, most of which you can ignore for the time being. The primary ones of interest for my purposes were “Authentication Model”, “NetBIOS Name”, “Workgroup”, “Allow Guest Access”.

“Authentication Model” allows you specify how you want clients to authenticate against the CIFS service. Selecting “Local User” forces the client to provide a username and password which corresponds to a user account on the FreeNAS device. By selecting “Anonymous”, you’re telling FreeNAS not to force users to provide credentials. Because I want all machines in our home to access the server without having to provide credentials, I set “Authentication Model” to “Anonymous”.

“NetBIOS Name” is how your FreeNAS device will appear to Windows machines on your local network. It’s also the name you can use as shorthand when trying to access your FreeNAS device. So instead of having to type in something like “\\192.168.0.50\storage” on a Windows machine, you can use something a bit more user-friendly like “\\freenas\storage”.

“Workgroup” should match whatever Workgroup your Windows machines belong to. If this isn’t set correctly, you won’t be able to browse to your FreeNAS device from a Windows computer.

“Allow Guest Access” allows whatever user ID you’ve associated with “guest” access to use the storage without having to authenticate.

Once CIFS is configured, the service needs to be turned on. To turn it on, all you need to do is click on the “Control Services” subcategory under the “Services” category. In “Control Services”, you’ll see a list of all of the services supports by FreeNAS. They’re all off by default. Clicking the appropriate on/off button will turn the CIFS service on.

Next, the storage actually needs to be exposed as a CIFS Share. If you expand the “Sharing” category, you’ll see a number of subcategories including one for “CIFS Shares”. Expanding “CIFS Shares” exposes an option for adding a new CIFS share. Add a new share, give it a name, and point it to your volume. Most of the default values will be inherited from the CIFS configuration. Be sure to enable “Allow Guest Access”.

At this point, client machines should be able to access the share and read from it. But you’ll quickly notice that you can’t create or modify files. This is because the permissions aren’t set correctly and changing them is the final thing we need to do. Click on “Change Permissions” beneath your volume listing. From here, you can simply enable Read/Write/Execute on for everybody.

Click “OK” and restart CIFS just to be safe. Client machines should now have free reign of the storage space. Woohoo!

UPS

There’s one more service that I wanted to get working before I felt the device was complete – the UPS service.

FreeNAS has the ability to communicate with an assortment of power supplies over USB. It uses NUTS (Network UPS Tools) to do this. By configuring the UPS service, we tell FreeNAS what to do in the event of a power outage or low battery. If the power goes out, your FreeNAS device is able to power down itself in a clean and orderly way, giving your file system a fighting chance against corruption.

In my environment, which suffers from frequent, but brief power outages, I need FreeNAS to wait 10 seconds after a power outage occurs before deciding whether or not to shutdown. Power usually comes back on within a few seconds. But in the event it doesn’t after 10 seconds, I want the device to shutdown cleanly. It’ll be up to me to power it back on.

Open the UPS service configuration and choose the appropriate driver. If your UPS is listed, select it. If it’s not, all is not lost. Most of the drivers listed are generic and will work with multiple devices. It’ll just take some experimentation. Many of the choices listed are in fact the same driver. Don’t be surprised if you select one, save it, and come back later only to discover that a different option is selected. No harm done. FreeNAS doesn’t store your UPS selection, only your driver selection. So when you reenter the configuration page, FreeNAS autoselects the first device that uses the driver you had previously selected.

“Port” selection can be tricky. If you’ve only got one option to choose from, great. But if you’ve got more than one, you’ll need to figure out which port your UPS is on. The easiest way to do this, and the way suggested by the documentation, is to take a look at your console messages. To do this, click on the “System” category, click on the “Settings” subcategory, click on the “Advanced” tab, and turn on “Show console messages in the footer”. When this is enabled, you’ll see a terminal-like box appear at the bottom of the browser window. By unplugging and plugging in the UPS’s USB cable, you should see “/dev/ugenX.X” related messages appear in that window. If you see them, the port listed is the port you want to use for your UPS configuration.

For shutdown mode, you have two options – “UPS reaches low battery” and “UPS goes on battery”. They are what they sound like. If “UPS reaches low battery” is selected, your FreeNAS device will begin shutting down when the battery gets low. If “UPS goes on battery” is selected, FreeNAS will begin shutting down whenever power is lost. I selected “UPS goes on battery”.

The shutdown timer is specified in seconds and tells FreeNAS how much time should elapse between the shutdown condition being satisfied and the actual shutdown of FreeNAS. If the condition becomes unsatisfied during the time interval, FreeNAS was abort the shutdown. In my project, for example, I’ve set the shutdown timer to 10 seconds and the shutdown mode to “UPS goes on battery.” If the power goes out, FreeNAS will wait 10 seconds before shutting down. If the power comes back on before then, FreeNAS will abort the shutdown and continue on as if nothing ever happened.

IMPORTANT: One thing I’d like to point out is that the version of FreeNAS I installed has a bug that prevents the UPS service from working correctly. And the bug appears to have stayed around for at least 3 subsequent releases. You should test your configuration by simulating a power outage before trusting it to work correctly.

There exists a patch to the OS to fix the problem. But patching isn’t always straightforward. The problem in my particular version of FreeNAS was that the “uucp” user wasn’t a member of the “operator” group. And FreeNAS has a little database that “uucp” needs to read from, but can’t because it’s only accessible to root and the operator group.

/data/freenas-v1.db

You can do one of two things – make “uucp” a member of the “operator” group through the web configuration tool (for some reason, doing it through the shell doesn’t allow the changes to survive a reboot) or chmod the database, which is what I did. It’s not pretty and it’s wrought with security implications. But it is what it is.

chmod 666 /data/freenas-v1.db

End of the Road

And that’s it! If everything went ok, you should be able to access the FreeNAS storage like any other Windows share. If the Workgroup was set correctly in your CIFS configuration, you’ll be able to see the FreeNAS device from Windows machines just by browsing your network. Accessing the storage from other devices might require a bit more work. On OSX, I often have to use Finder->Connect To Server and specify the server using smb://ipaddress/storagename. On Ubuntu, I mount the storage as needed.

It might seem anticlimactic in the end. After all, we’re just talking about the ability to read and write files. In truth, a FreeNAS device is a dedicated file server capable of providing a multitude of services for you. There are a lot of possibilities. For instance, we’ve already discussed using a FreeNAS device as a dedicated backup server. I’ve also toyed with the idea of using it as a repository for video/images captured using IP security cameras. Basically, wherever you need shared or always-on storage, FreeNAS is a very capable solution.

BONUS: Automated Backups

My primary motivation for building a FreeNAS device was for performing automated backups. I’m going to leave you with a short how-to on how I made this work for our Windows PCs.

The first thing I did was to create a folder on FreeNAS for backups to be placed in. Being the creative type, I called it “backups”. Next I went to each Windows machine and configured them like so.

  • I first installed a copy of RoboCopy and made sure its location was in the PATH environment variable. RoboCopy is a neat little command line utility that’s been bundled as part of the Windows Resource Kit since NT 4.0. It has a lot of neat features, the most important for me being its ability to perform folder mirroring. You can download the Windows Resource Kit free from Microsoft.
  • I then created a one-line batch file that invoked RoboCopy.
    robocopy c:\User\Shane \\192.168.56.101\backups\Shanes_PC /MIR /R:3

    What this does is mirror my Windows account folder on the local machine to a folder on the FreeNAS device called “backups\Shanes_PC”. Note that the destination folder is different for each machine that’s performing backups.

    The /MIR option says “mirror”. If a file is created or changed locally, it’s copied to the FreeNAS device. If a file is deleted locally, the file is deleted from the FreeNAS device. That last point is important to note. If you accidentally deleted a file 3 days ago and this script executes daily, that file is gone.

    The /R:3 option means “retry 3 times”. If the FreeNAS device is unavailable, I don’t want the script to keep trying forever.

  • I then configured the batch file to execute every time the user log’s off. You can do this by using the Group Policy Editor snap-in. Click Start->Run and type “gpedit.msc” and hit enter. Beneath “User Configuration->Windows Settings”, you’ll see an item labeled “Scripts (Logon/Logoff)”. Click on that and add the batch file path to the “Logoff” option.

    You might be tempted to instead to use Window’s “Shutdown” script configuration option. I too started down this road. The problem is the network connections are closed before these scripts execute and you won’t actually be able to connect to your FreeNAS device.

That’s all there is to it. Whenever I logoff or shutdown, the batch file gets executed, and everything in my account folder gets synced to the FreeNAS machine. This includes “My Documents”, “My Music”, “My Pictures”, the desktop, etc.

Anyway, I hope this gives you some ideas on how you might create your own automated backup solution. For more information, visit FreeNAS.org. Good luck!