Friday, February 15, 2008
Robocopy for Mirroring Directory(ies) to a Backup Disk
I did quite a bit of looking around for a way to backup my documents and music and other files on my new Vista PC. I have a second disk in my system and wanted to mirror my important data to that second disk. There's a backup utility built in to Vista, but it doesn't have a way to exclude directories (!) and I have some directories with large, static data that I already have backed up elsewhere and don't want to include on the backup disk.
I found a bunch of mirroring tools, and none seemed very good. I don't need it to run unattended, because I remember to do it often enough and also I don't leave my PC on overnight usually.
I settled on Robocopy.exe, a command-line tool that isn't in Vista by default but I was able to get it by installing the Windows 2003 Resource Kit. Robocopy is working great for me. It took some effort to figure out the command-line switches, but now I have a batch file that I can run once in awhile to mirror my important data to my backup disk. It's been reliable, synchronizes directories by deleting files in the destination that have been deleted in the source, and is very fast by not copying files that are already sync'd.
Here's the command I'm using to mirror my user folder on the backup disk:
robocopy "c:\Users\Ryan" "e:\Sync Folder\Ryan" /MIR /XJ /R:1 /ZB /S /W:1 /XD "AppData" /XF "ntuser.*"
I found a bunch of mirroring tools, and none seemed very good. I don't need it to run unattended, because I remember to do it often enough and also I don't leave my PC on overnight usually.
I settled on Robocopy.exe, a command-line tool that isn't in Vista by default but I was able to get it by installing the Windows 2003 Resource Kit. Robocopy is working great for me. It took some effort to figure out the command-line switches, but now I have a batch file that I can run once in awhile to mirror my important data to my backup disk. It's been reliable, synchronizes directories by deleting files in the destination that have been deleted in the source, and is very fast by not copying files that are already sync'd.
Here's the command I'm using to mirror my user folder on the backup disk:
robocopy "c:\Users\Ryan" "e:\Sync Folder\Ryan" /MIR /XJ /R:1 /ZB /S /W:1 /XD "AppData" /XF "ntuser.*"
- /MIR means make the output directory just like the source directory, including deleting files
- /XJ means exclude junction points
- /R:1 means only retry failed copies once, I look at the output for errors anyway, and don't expect any on internal disk to internal disk copy
- /ZB use restartable mode
- /S copy subdirectories too, but not empty ones
- /W:1 wait only 1 second between retries, I did this for the same reasons as /R:1
- /XD "AppData" Exclude the AppData subdirectory which has a bunch of temporary files I don't need backed up
- /XF "ntuser.*" Exclude ntuser.* log files, don't need them backed up and they're usually in use
Monday, February 14, 2005
Inno Setup
I just tried Inno Setup, a free install-builder by Jordan Russel. I can't believe how quickly I got the features I wanted (desktop shortcut, start program at end of install, quick-launch option). From first seeing the Inno Setup web site to having my install built and working took about 6 minutes. Unbelievable. I wasted multiple days trying to get VS.Net's built-in install builder to do everything I wanted. I wish I'd found Inno Setup sooner.
Tuesday, January 18, 2005
Deleting Files By Regular Expression with Agent Ransack
I just found a good way to delete a bunch of programming tool temporary files (like .obj and .pdb files). I have a directory under which I have hundreds of development projects in different languages, and to back it up I either have to select the files I specifically want to backup or delete the files I don't want to backup first. So far I'd been using a script, but due to my discontent with the excruciating awkwardness of JScript, I'm switching to using Agent Ransack....
I've been using Mythicsoft's Agent Ransack disk search utility because it searches so much faster than Windows' search capability. You can also use it to delete files by regular expression, and save the search expression to a file so you don't have to enter it each time you want to do the clean. That's great because it makes the clean I want to do fast and easy. I had a couple minor issues with it:
1) The Save Search Criteria dialog makes it sound like you're saving a Search Result, but it's okay, it's actually saving the search criteria.
2) The saved search criteria file (.srf) isn't associated with Agent Ransack by the installer, so you have to do that once yourself using right-click -> Open with... -> Choose program).
Update: Since this post I've started using Jeff Atwood's Clean Sources Plus, (created from Omar Shahine's original Clean Sources). Clean Sources Plus adds a context menu item to Windows Explorer, so it is very handy. It deletes files based on regex's stored in a .config file, so it makes preparing source directories for backup a snap.
I've been using Mythicsoft's Agent Ransack disk search utility because it searches so much faster than Windows' search capability. You can also use it to delete files by regular expression, and save the search expression to a file so you don't have to enter it each time you want to do the clean. That's great because it makes the clean I want to do fast and easy. I had a couple minor issues with it:
1) The Save Search Criteria dialog makes it sound like you're saving a Search Result, but it's okay, it's actually saving the search criteria.
2) The saved search criteria file (.srf) isn't associated with Agent Ransack by the installer, so you have to do that once yourself using right-click -> Open with... -> Choose program).
Update: Since this post I've started using Jeff Atwood's Clean Sources Plus, (created from Omar Shahine's original Clean Sources). Clean Sources Plus adds a context menu item to Windows Explorer, so it is very handy. It deletes files based on regex's stored in a .config file, so it makes preparing source directories for backup a snap.
Friday, January 07, 2005
Blogger.com Template Show/Hide Setup
I spent quite a bit of time getting my blogger.com Template set up to have a Show/Hide capability a little better than that provided in the Blogger Hacks instructions for a show/hide link. ...
I wanted a summary section shown on the main page, not just the title. Looks like I've gotten it working pretty well now.
I ended up with some JavaScript doing DOM navigation to change the class of the show/hide nodes. It isn't quite perfect, what I'd really rather do is simply change the style of the span classes, but I've spent enough time already, and it's pretty much working. I just have to change the bodies of my posts (like this text right here) to put it in a span tag with class set to hidden.
I can also have an ellipsis showing that there's more text. The only drawback so far is that the ellipsis is always shown on the Item page, but that's not too big a deal.
I wanted a summary section shown on the main page, not just the title. Looks like I've gotten it working pretty well now.
I ended up with some JavaScript doing DOM navigation to change the class of the show/hide nodes. It isn't quite perfect, what I'd really rather do is simply change the style of the span classes, but I've spent enough time already, and it's pretty much working. I just have to change the bodies of my posts (like this text right here) to put it in a span tag with class set to hidden.
I can also have an ellipsis showing that there's more text. The only drawback so far is that the ellipsis is always shown on the Item page, but that's not too big a deal.
Thursday, January 06, 2005
C#/.Net Logging
I went looking for a good C#/.Net logging (Logger) library to use on a home project. I found two main ...options, Apache’s log4net and one on Sourceforge called NLog. Both looked pretty well developed. I also noticed Microsoft’s Logging Application Block, but it’s apparently heavyweight in the extreme, requiring Microsoft Enterprise Instrumentation Framework. I don’t know much about it, and decided the odds I’d use it are so low as to make it not worthwhile to learn about it.
I took a look at log4net next and didn’t like some things:
1. Version 1.2.0 has been in beta for 2 years. That’s not a good sign for its speed of development. Logging is such that once you pick a package, it’s potentially really painful to change later. I want to pick a winner right from the start.
2. It doesn’t have an interface like log.Info(string format, params object[] args). I really can’t understand that, and find it very irritating. I understand that it’s common to log exceptions, but I bet 99% of the log statements I’ve written in the past do not have exceptions to pass. It’s frustrating that people have put so much effort into the development and there’s a deal-killing issue like that in it for me.
3. Looks like it can’t do run-time programmatic configuration easily, which is important to me.
My use pattern in the past has required modifying the verbosity at runtime. The two scenarios that come to mind are:
1. a command-line program that has arguments to determine verbosity
2. a service that has diagnostic client that can connect and set the verbosity.
On the other hand log4net looks like the largest and most fully developed library available.
I got NLog and wrote a test program. It took about an hour to get going for various reasons (I don’t list these to be critical, I list these to be helpful to other people):
1. The version I downloaded (0.2 beta 1) had a bug with appender list "console,file" where it only sent output to the file. It took a few minutes to find out I should get the latest snapshot and where to get it.
2. The snapshot I downloaded (20050104) had InternalLogger.LogToConsole = true regardless of the config file value. That took a few minutes to figure out.
3. No default config. If you just create a Logger and try to use it you get no output because there isn’t a usable starting configuration. So this produces no output:
Logger log = LogManager.GetLogger("MyLogger");
log.Error("This is an Error statement.");
It’d be a little faster to get going if it did. You have to get an App.config or explicitly load a log file to get a configuration that displays this output.
But after getting a .nlog and then an App.config going it worked well.
Now I’ve got these issues with NLog:
1. I realized that due to the structure, where rules point to appenders, it won’t be easy to modify verbosity threshold programmatically at runtime.
2. Verbosity apparently isn’t handled as a threshold, which is different from what I’m used to. I would normally expect a single threshold value. Instead NLog takes the more flexible (and therefore necessarily more complicated) approach of allowing you to turn off Warn messages while seeing Debug, Info, and Error messages. I don’t think this complexity/flexibility tradeoff is a good call.
3. No log file rolling appender yet.
Arrrrrghhhh… I’m going to use my way-too-simple RTools.Util.Logger class, and probably have to enhance it gradually as I need more capability. Painful. Fortunately my Logger API is similar to NLog’s, so maybe I’ll be able to switch to NLog later fairly easily.
I took a look at log4net next and didn’t like some things:
1. Version 1.2.0 has been in beta for 2 years. That’s not a good sign for its speed of development. Logging is such that once you pick a package, it’s potentially really painful to change later. I want to pick a winner right from the start.
2. It doesn’t have an interface like log.Info(string format, params object[] args). I really can’t understand that, and find it very irritating. I understand that it’s common to log exceptions, but I bet 99% of the log statements I’ve written in the past do not have exceptions to pass. It’s frustrating that people have put so much effort into the development and there’s a deal-killing issue like that in it for me.
3. Looks like it can’t do run-time programmatic configuration easily, which is important to me.
My use pattern in the past has required modifying the verbosity at runtime. The two scenarios that come to mind are:
1. a command-line program that has arguments to determine verbosity
2. a service that has diagnostic client that can connect and set the verbosity.
On the other hand log4net looks like the largest and most fully developed library available.
I got NLog and wrote a test program. It took about an hour to get going for various reasons (I don’t list these to be critical, I list these to be helpful to other people):
1. The version I downloaded (0.2 beta 1) had a bug with appender list "console,file" where it only sent output to the file. It took a few minutes to find out I should get the latest snapshot and where to get it.
2. The snapshot I downloaded (20050104) had InternalLogger.LogToConsole = true regardless of the config file value. That took a few minutes to figure out.
3. No default config. If you just create a Logger and try to use it you get no output because there isn’t a usable starting configuration. So this produces no output:
Logger log = LogManager.GetLogger("MyLogger");
log.Error("This is an Error statement.");
It’d be a little faster to get going if it did. You have to get an App.config or explicitly load a log file to get a configuration that displays this output.
But after getting a .nlog and then an App.config going it worked well.
Now I’ve got these issues with NLog:
1. I realized that due to the structure, where rules point to appenders, it won’t be easy to modify verbosity threshold programmatically at runtime.
2. Verbosity apparently isn’t handled as a threshold, which is different from what I’m used to. I would normally expect a single threshold value. Instead NLog takes the more flexible (and therefore necessarily more complicated) approach of allowing you to turn off Warn messages while seeing Debug, Info, and Error messages. I don’t think this complexity/flexibility tradeoff is a good call.
3. No log file rolling appender yet.
Arrrrrghhhh… I’m going to use my way-too-simple RTools.Util.Logger class, and probably have to enhance it gradually as I need more capability. Painful. Fortunately my Logger API is similar to NLog’s, so maybe I’ll be able to switch to NLog later fairly easily.
Subscribe to Posts [Atom]