I'm a programmer, and when doing local development I often set up local domains that loop back to my development machine. This is primarily for testing purposes. On Windows the domains are stored in a hosts file. The windows hosts file is located at "C:\Windows\System32\drivers\etc" and has no extension.

It acts as your own local DSN and contains a bunch of domain names and IP addresses you want to point them to--for me this is almost always 127.0.01 back to localhost.

Although, this is not important, in the worst case scenario it would suck to have to set this back p from scratch. I would prefer not to lose this config.

However, BackBlaze does not back it up. I reached out to support and they told me that the Windows directory is restricted and will not be backed up. There was no way to backup this file. So I started looking into alternate solutions.

I decide to create a scheduled tasks to copy the hosts files from the windows directory to some place that Backblaze would back up. This can be done all inside windows.

The first step is to create your config file. I created a file named copyFiles.ps1. It contains a powershell script:

view plain print about
1Copy-Item -Path C:\Windows\System32\drivers\etc -Destination C:\BackupConfig\hosts -Recurse -Force

This uses a copy item command. The path is the source--the windows specific directory, and the destination is the place you want to copy the files to. The recurse flag tells the command to copy all files inside the directory, and the force command tells you to overwrite all files in the destination. You can tweak this script at your will.

The next step is to create a the scheduled task. From your windows start menu select the task scheduler:

Click the Create Task button in the right menu:

I gave it a name: CopyConfigForBackup. and added in some description of what the task does. (I'm also copying my Apache configs from the program files directory as you can see from the description)

Click to triggers and click new:

I selected on a schedule, and chose daily at 8am. In most cases I'm up and my computer is already on at that point. Click OK and you should see the trigger in your list:

Click the actions tab, and then click new to create a new action. This is where the magic starts to happen.

I select start a program. The program I want to start is powershell, which should be located here:

view plain print about

Add a bunch of arguments:

view plain print about
1-NonInteractive -NoLogo -NoProfile -File "C:\scripts\CopyFiles.ps1"

The first argument sets the powershell window to not be interactive. It will do its thing w/o user intervention. Perfect for a scheduled tasks. The second window says not to display the powershell logo. This is not needed when loading things up, or down. The NoProfile tells powershell to load in the deafult profile, not something we customized. The file argument tells powershell which script to run. This is the same script I shared earlier.

I left the Conditions and settings tabs, relatively untouched.

Click okay, and your task should be created and show up in your list.

Now every day at 8am powershell blinks for a fraction of a second, and copies the files for back blaze to back up.

It's been working well for me.