Monday, November 08, 2010 at 12:04 AM.

system.verbs.builtins.radio.backup.threadScript

<<Changes
	<<11/13/02; 4:56:23 PM by DW
		<<Created

radio.backup.init ();
if user.radio.backup.prefs.flEnabled {
	local (flBackup = false);
	local (day, month, year, hour, minute, second);
	date.get (clock.now (), @day, @month, @year, @hour, @minute, @second);
	if (hour == user.radio.backup.prefs.hourToBackUp) and (minute == user.radio.backup.prefs.minuteToBackUp) {
		local (lastday, lastmonth, lastyear, lasthour, lastminute, lastsecond);
		date.get (user.radio.backup.stats.whenLastBackup, @lastday, @lastmonth, @lastyear, @lasthour, @lastminute, @lastsecond);
		if lastday != day { //only do the updates once per day
			flBackup = true}}
	else { //check to see if it's been more than 24 hours since the last backup
		if date.yesterday (clock.now ()) > user.radio.backup.stats.whenLastBackup {
			flBackup = true}};
	if flBackup { //it's time to do a complete backup/verify
		user.radio.backup.stats.whenLastBackup = clock.now ();
		local (flError = false, startticks = clock.ticks ());
		on errorCallback (errormsg) { //log an error in the events page, and email the error message to the user
			radio.log.add ("Nightly Backup", errormsg, startticks);
			local (mailtext);
			on add (s) {
				mailtext = mailtext + (s + "\r\n");};
			add ("Radio UserLand's nightly backup failed because there was an error verifying the backup:");
			add ("");
			add (errormsg);
			tcp.sendMail (user.prefs.mailAddress, "Radio UserLand nightly backup error", mailtext);
			return (false)};
		radio.backup.backupAndVerify (@errorCallback);
		if not flError { //log backup/verification success
			radio.log.add ("Nightly Backup", "Nightly backup and verification of weblog posts, templates, stories, preferences and aggregator subscriptions completed successfully.", startticks)}}}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.