Using forfiles.exe to delete old files…

So I setup a PC DVR unit to handle some security cameras for a client of mine.  As a result, the *.avi files would start to eat up a lot of space after a month or so of recording.  So I elected to use the forfiles.exe program to take care of the problem.  Note this is a windows platform and if you are using anything pre-W2k3 (like XP), you’ll need to download the program from MS (link is for x86!).

For simplicity, I just saved it in c:\windows.  Next you’ll need to figure out the proper syntax to use for your needs.  Mine was to delete any .AVI file that was older than 7 days, located in a particular pathway, such as c:\dvr-video.  Below is what I am using…

FORFILES -pc:\dvr-video-s -m*.avi -d-7 -c”CMD /c del /q @FILE”

I would suggest you test this prior to blasting away your files.  The line below will echo all the files that would normally be deleted if you ran the command above.

FORFILES -pc:\dvr-video -s -m*.avi -d-7 -c”CMD /c ECHO @FILE”

I would also suggest you take a look at the FORFILES syntax flags. Here is a link to the CMD syntax flags too, if you are new to the command.  Once you have it all worked out, save it in a notepad file with a .bat extension.  Location doesn’t matter, just somewhere you can find it for the next step.

The final step is to fire up your Task Scheduler and configure it to run this batch file however often you need it to run.  Since my batch file deletes files older than 7 days, I run it once a week on Saturday, at 4AM.

Overall, it is a pretty simple setup.

2 things to note…

1. If your files have spaces in them, this won’t work.  The only workaround I know offhand is to use underscore or hyphens in your files names.

2. If there are spaces in your pathway, you’ll need to put it in quotes, like FORFILES -p”c:\my pathway\has spaces\to my\files”

Took the KTM on a 120+ mile desert ride…

I finally got to complete the full loop of The Great Western Trail to Bloody Basin to Sheep Bridge to Horseshoe Lake Dam. I fell off once and tipped over twice. If you are going to ride this loop, be careful of the two concrete water crossings in the 7 Springs Recreation area. They can be as slick as ice with all the damn algae buildup. I’ve crossed them half a dozen times with no problem, but I slipped on the second crossing and fell off in the middle of the concrete. Not hurt, but busted off a mirror 🙁

The most challenging areas though, was the going down the rocky incline on the East side of Sheep Bridge and getting up the West side of the path down to the crossing under the dam. I tipped over on both those spots. Thankfully, I had a riding buddy there to help me get the bike up. It is a lot of work to do this loop in 100F weather. Other than a little heat exhaustion that set in once I got home (headache and throwing up), it was a decent ride.

Using ncftpget for automated FTP backups…

So I like to use Mikrotik routers for moving bits around my networks and the Internet. In an effort to ensure I always have an off-host backup available, I’ve setup a backup process using ncftpget. I won’t cover how to setup cron jobs, hopefully you already know how to set one up. That said, this is a pretty simple setup.

I have my backups process nightly, at midnight. Here is a sample command syntax for my 750G called Gatekeeper:

cd /home/mikrotik/Gatekeeper_RB750G && /usr/local/bin/ncftpget -f ../.netrc_gatekeeper ./ /*.backup

The first part of the command drops you into your storage directory. The second part tells ncftpget to use the server and login information contained within the file .netrc_gatekeeper and to download any files matching the *.backup wildcard. You can change this to suit your needs.

Here is an example of how your .netrc file should look like:

machine 'IP/hostname'
user your_ftp_username
pass your_ftp_password

Note: You’ll need to create a separate .netrc file for each host you want to backup. Hence, my naming scheme of .netrc_hostname.

Here is a second command syntax example for my 493AH called Keymaster:

cd /home/mikrotik/Keymaster_RB493AH && /usr/local/bin/ncftpget -f ../.netrc_keymaster ./ /*.backup

The US Navy is retarded…

My evidence…

Back in the day, they used to name ships after heroes who accomplished great things. Now they are naming them after victims.

That says everything you need to know about America under BHO.

Let’s just start with WWII…I can think of 400,000+ that are more worthy to have a ship named after them than a Congressional Rep.

BackupPC is magic…

Well, I’ve been using BackupPC for about half a year now. I’m pretty happy with it. For an open source application, it is pretty polished. At the several businesses where I’ve been asked to pitch a backup application for LAMP server farms, I’ve had great success with this software. I love open source. It is definitely a way to to knock out backups for your LAMP server with minimal cost. Providing a company or individual has the in-house talent to set it up (it ain’t rocket science!), your cost for a robust, enterprise capable backup application, is limited to your hardware costs.

Now, recently I ran into a problem with BackupPC, running on CentOS 5.7. After a yum update, when trying to process a backup job, BackupPC would error out with a Compress::Zlib error. After much google-fu, I came across this guy’s solution. Doing a force install on CPAN solved my problem. Hope this helps someone else.

Demo weekend…

Ride Now had a cool weekend demo ride event this past weekend. I got to ride a BMW GT1600 and a Can-am Spider. The BMW was actually pretty cool. I’d really like to rent it for the weekend and do a Jerome/Sedona/Flagstaff trip on it. It had heated grips and seats, XM/Sirius radio, and a whole slew of other cool shit. I got to meet a cool chick named Moira, who was the BMW lead demo sales person (and forum member. The Can-am 3-wheeler was fun to ride, but I’d never buy one, I need my motorcycle to “lean” with me.

Made it up to the 7 Springs area again…

This time I camped out, just off the trail of NF-41. Nothing super exciting, but it was nice to get out of the city and away from everything. The 7 Springs Campground was PACKED, so I kept on riding past it and went up to NF-41 and went West. There weren’t too many good spots to camp and there were tons of people out there just blasting their guns for fun or hunting white tail deer. Anyhow, I found a spot and enjoyed the peace and quiet once the sun set.