home *** CD-ROM | disk | FTP | other *** search
- /*
- * Daily - do daily dumps of it's arguments.
- *
- * For each argument dev (with no ':'), find all files on dev: that
- * are newer than dev:last-backup, and copy them (complete with directory
- * structure) to daily:dev.
- *
- * See build_exclusion for tailoring the list of files to be excluded from
- * backing up. Note that the loop in main also does some filtering.
- *
- * Future enhancement: compress file to ram:, then copy it to daily:
- *
- * Copyright (C) 1989 Mike Meyer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 1, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
- parse arg devices
-
- logfile = 'logs:daily.backup'
-
- if ~exists(logfile) then 'copy nil: to' logfile
- signal on error
- options failat 1
-
- /* Build the exclusion list, and put it in clip space */
- call build_exclusions
-
- do args = 1 to words(devices)
- /* Verify we have a valid file system to backup up */
- dev = word(devices, args)
- if index(dev, ':') ~= 0 then do
- call log "Don't specify ':' in device name" dev
- iterate args
- end
- if ~exists(dev':last-backup') then do
- call log dev':last-backup does not exist'
- iterate args
- end
-
- /* Ok, we're gonna do it, so tell the user about it */
- call log "starting backup of" dev'.' dailysize() 'blocks free on daily:'
-
- /* Let treewalk run daily.ftw on real files, and do the real work */
- 'treewalk dir' dev': filter "file && date > 'dev':last-backup.date && daily && false"'
-
- /* Log that we're done with it all */
- call log 'Backup of' dev 'done,' dailysize() 'blocks free on daily:'
- end
-
- exit
-
- /*
- * build_exclusions - returns a treewalk filter expression to test
- * names in the file against the exclusion list.
- */
- build_exclusions: procedure expose logfile
-
- 'execio read s:mrbackup.xcld stem excludes.'
- out = "name !* 'fish.mff'" /* Bloody big file... */
- do i = 1 to excludes.0
- if left(excludes.i, 1) = '#' then iterate i
- if verify(excludes.i, ":/", 'Match') = 0 then
- out = out "&& filename !* '"excludes.i"'"
- else out = out "&& name !* '"excludes.i"'"
- end
- call setclip "daily.backup", out
- return
-
- /*
- * Returns the # of free blocks on the daily backup disk.
- */
- dailysize: procedure expose logfile
-
- 'info | execio locate daily for 1 var dailyline'
- return word(dailyline, 4)
-
-
- /*
- * Catch command errors, and diagnose them for the user.
- */
- error:
-
- if syntax = 2 then do
- call log "Interrupted; backup incomplete." dailysize() "blocks free."
- exit
- end
-
- call log 'line' sigl 'failed; backup incomplete.'
- call log dailysize() "blocks free on daily:"
- exit
-
- /*
- * Log - log the message we've been given.
- */
- log: procedure expose logfile
- parse arg message
-
- if ~open(file, logfile, 'Append') then do
- say "Can't open" logfile', exiting!'
- exit
- end
- call writeln file, date() time() || ':' message
- call close file
- return
-