Part of the Samples Website. 8/16/97.

samples.basicStuff.nightlyBackup

«this is how I do my big backups
«I have a Syquest 270MB removable drive, create a folder on it called Archives
«Create a folder on my internal drive called backups
«Put an alias to the Archives folder in the backups folder
«Create a folder in the backups folder called Aliases
«Put aliases to all the files I want to back up regularly in the Aliases folder
«Run this script frequently
«If my system dies, I have current copies of everything
«Requires StuffIt 3.5 or greater
«DW 4/4/96
local (homefolder = "Macintosh HD:Desktop Folder:backups:")
local (aliasesfolder = homefolder + "Aliases:")
local (archivesfolder = toys.resolveFolder (homefolder + "Archives:"))
local (f)
fileloop (f in aliasesfolder)
if not file.isAlias (f)
scriptError ("All files in Aliases folder must actually be an alias. \"" + file.filefrompath (f) + "" is not an alias.")
if not file.exists (file.followAlias (f))
scriptError (file.filefrompath (f) + " is an alias, but it points at a file that doesn't exist.")
f = file.followAlias (f)
local (fname = file.filefrompath (f))
local (archivefile, archivename)
bundle
archivename = fname - ":"
if sizeof (archivename) >= 27
archivename = string.mid (archivename, 1, 27)
archivename = archivename + ".sit"
archivefile = archivesfolder + archivename
local (needsbackup = true)
bundle
if file.exists (archivefile)
local (lastdate = file.modified (f)) «mod date of the thing the alias points to
if file.modified (archivefile) == lastdate
if file.isfolder (f)
on checkfolder (folder)
local (f)
fileloop (f in folder, infinity)
if file.modified (f) > lastdate
return
msg ("Checking all files in \"" + file.filefrompath (f) + "" folder")
checkfolder (f)
needsbackup = false
else
needsbackup = false
else
file.delete (archivefile)
if not needsbackup
«msg ("Skipping \"" + fname + """)
continue
log.add (f, "Nightly Backup Log")
msg ("Backing up \"" + fname + """)
stuff.createArchive (archivefile, {f}, false)
file.setmodified (archivefile, file.modified (f))
target.clear ()


This page was last built on Sat, Aug 16, 1997 at 6:38:29 PM. You can download the current set of sample scripts from our FTP site. Dave