Utilizing your ActionScript knowledge to Script Windows (and backing up your sites while you're at it!)
As part of reviving the What Is Flash Wiki, I restarted the scheduled automatic daily backups of the database from the web server to my local backup machine and thought it would be nice to share with you how I achieve this as it involves JScript for scripting Windows and JScript is a close cousin of ActionScript (they are both based on the latest ECMAScript specs.)
Update: If you're looking to do the same thing on OS X, Mike Chambers has a great post on Shell Scripting on OS X with ECMA / JavaScript
On a hugely dynamic site such as a Wiki or forum, it is very important to have constant backups of the database to protect against data loss. On a busy site with lots of updates, losing even a day of data is not good but it's worse if that becomes two or three days or a week! The way the What Is Flash server is set up, you can hit a certain URL (with proper authorization) to download backups of the site or of the various databases that it uses. What is needed is a script file that hits these URLs and does so on a daily basis, archiving the backups on the local machine. Enter the Scheduled Tasks scheduler and Windows Scripting.
If you're on Windows, there's very little you cannot automate using the Scheduled Tasks scheduler and Windows Scripting Host WSH).
Here are three of the best references I could find on them:- WSH: MSDN Windows Script Host Reference
- JScript: JScript Language Reference
- More info on JScript objects (includes FileSystemObject, etc., which I couldn't find in MSDN's reference.)
If you save the script as some_script.js, you can run it from the command line using wscript some_script.js
. If you now add this to the Scheduled Tasks (Start->Programs->Accesories->System Tools->Scheduled Tasks and then double-click to launch the Add Scheduled Task Wizard) you can have it execute automatically at a specified time interval (eg. every day.)
Comments