Switching Servers

October 27th, 2004

Just a quick not to all million of my visitors, I’m in the process of switching servers so there will be some down time of parts of this site. From now on it will be mainly the gallery and the older stuff that is not available.
Thanks for your patience.

More Backing up via VBScript

October 14th, 2004

A few days late, and perhaps not in it’s most efficient form (well not perhaps . . .) Here is the script that copies a directory from one place to another. Slight enhancements enable it to keep the previous two backups and to keep a relatively well formed log detailing start and finish. Enjoy!

I use it to copy my ‘My Documents’ folder to a networked drive. I make no guarantees that it will work for you, in fact, I can almost guarantee that it will often fail, since it does so on a relatively regular basis for me, most likely because my wireless connection which it uses to do the copying is a bit spotty on service at times.

‘A quick script by Elliot Anders to backup a folder to another drive.
‘This script will keep 2 copies of the backed up folder.
‘It deletes the old copy, renames the more recent copy as the old one and copies
‘the current source folder to become the new backup.

‘”'’Configure the folders here:
sourceFolder = “C:\Documents and Settings\USERNAME\My Documents”
previousBackup = “K:\Previous My Documents”
currentBackup = “K:\Current My Documents”

logFile = “K:\backupTheStore.log” ‘This should probably be located on
the drive with the backups but not in the backup folder

‘”'’Do not make changes below this line”””’

Dim FSO, logFileStream, tempFileStream
Dim strSrcDir
Set logFSO = CreateObject(”Scripting.FileSystemObject”)
Set tempFSO = CreateObject(”Scripting.FileSystemObject”)
Set backupFSO = CreateObject(”Scripting.FileSystemObject”)

‘”'’Make a log file if this is the first time

if logFSO.FileExists(logFile) = false Then
       logFSO.CreateTextFile logFile, True
       Set initialize = logFSO.openTextFile(logFile, 2)
       firstText = “Log Created at ” & Now
       initialize.writeLine firstText
       initialize.close
End If

‘”'’Tell the log that we are starting

beginningText = “Backup of ” & sourceFolder & ” began at: ” & Now

‘”’Error here
tmp = “C:\temp\tmp.txt”
if tempFSO.FileExists(tmp) = false Then
       tempFSO.CreateTextFile tmp, True
End if

Set tempFileStream = tempFSO.OpenTextFile( tmp, 2)
tempFileStream.WriteLine beginningText
tempFileStream.close

Dim tmp, logFile
‘Create FileSystemObject
Set appendFSO = CreateObject(”Scripting.FileSystemObject”)
‘Open file for appending, don’t create
Set ftop = appendFSO.OpenTextFile( tmp, 8, false)
‘Open for reading
Set fbot = appendFSO.OpenTextFile( logFile, 1, true)
‘Append the contents of second file to first
ftop.Write fbot.ReadAll
fbot.close
ftop.close
appendFSO.DeleteFile(logFile)
appendFSO.CopyFile tmp, logFile

‘”'’Delete the old backup

If backupFSO.FolderExists(previousBackup) Then
       backupFSO.DeleteFolder previousBackup, true
End If

‘”'’Move the new to be the new old

If backupFSO.FolderExists(currentBackup) Then
       backupFSO.MoveFolder currentBackup, previousBackup
       Set f = backupFSO.CreateFolder(currentBackup)

End If

‘”'’Copy the source folder to the backup location

backupFSO.CopyFolder sourceFolder, currentBackup

‘”'’Tell the log we are done

endText = “Backup of ” & sourceFolder & ” was Successfully Completed at: ” & Now
Set tempFileStream = tempFSO.OpenTextFile( tmp, 2)
tempFileStream.WriteLine endText
tempFileStream.close

‘Open file for appending, don’t create
Set ftop = appendFSO.OpenTextFile( tmp, 8, false)
‘Open for reading
Set fbot = appendFSO.OpenTextFile( logFile, 1, true)
‘Append the contents of second file to first
ftop.Write fbot.ReadAll
fbot.close
ftop.close
appendFSO.DeleteFile(logFile)
appendFSO.MoveFile tmp, logFile

Windows Script Host VBscripting

October 1st, 2004

Before I begin, if anyone is interested, I start my new part-time job today working at an elementary school for The Mohawk Regional School District.

Lately I’ve been diving deeper into the world of Windows, I generally stick to my comfortable, stable, and virus free OS X, but once in a while (much more than before since my new job will be 99% windows work) I delve into the inner workings of a Windows machine. Lately it has been Windows Script Host, or WSH.

I’ve been working on a project that never seems to go away. Not that I didn’t finish the project, but it involves backing up a computer. Something I should do way more diligently and often. So the basic idea here was that the computer was usually backed up every evening onto a CD. Only 200 MB of data needed to be saved at any given time, but that’s some 313 CD’s a year (no Sunday backup.) And really only the past day or two needed t be saved. So along I come, and thinking there must be an equivalent to AppleScript for PC, I thought this would be an easy job. To tell the truth, copying the data wasn’t really that hard, writing the log got messy.

Network issues aside (this was a wireless connection to get the data out of the building) the basic concept was to use Windows Explorer and Scheduled Tasks to move the data to another machine each morning at 2:00 AM. After dinking around for a while with the Backup Utility I decided to go with WSH as it would give me a usable backup. With the backup utility everything is placed in one archive file and can’t be used unless it is restored.

WSH can mount a file server, but I thought it might be nicer to pass this job off to XP, so I mapped a drive and had it re-connect at login (Windows calls it Logon?) Then I simply copied the contents of the folder to be backed up over to this new drive. Voila! It worked, sort-of . . . as long as the network was up. So back to fixing the network. . . And then, the great idea that took 2 or 3 times as long to implement. A log file. To cut to the chase, I wanted the log file written in reverse chronological order so the newest information would be at the top. This requires more work than it should. It seems to me Perl can do this in it’s sleep (correct me if I’m wrong.) Any way, after lots of grammar errors and a temp file I got it all working, and wish to share the fruits of my labor with all of you. Except you’ll have to wait, because I left the final version of the other computer and haven’t backed it up yet. Ooops.

One final comment, then hopefully later today I’ll post that script, though I better preface it with this note:

Use the script at your own risk, the code is not pretty . . . yet, but I’ll work on it eventually (or not.) It works for me, if it erases all of your files, they are gone.

Oh yeah, it keeps two backups of whatever directory you send it, so that if it stops in the middle of a backup you still have the previous.

So now onto my current Beef with Windows file sharing. . . .
Can someone explain to me why I can connect to an XP share with OS X without a password . . . OR USERNAME?!!!??! Hello security risk! With XP to XP it behaves okay, though both machines have the same user account so I guess I don’t really know if it is using a password scheme. But with my Mac I’m in like Flynn! I just don’t get it, commmon Redmond, lets get this thing locked down tight.

Okay, enough already, and this should be long enough to push my previous post so that it doesn’t run into my navigation. If anyone knows a quick and dirty fix for removing Safari’s cache permanently (that doesn’t involve installing an application, I’d love to hear it, because last I checked that wasn’t sticking out the right side of the middle section.