[comp.sys.amiga] SDBackup Part 1 of 2

drew@decwrl.UUCP (09/28/87)

I'm sending this here for speed, also it's not too big. I'll be sending
Shell 2.07M to .sources,binaries later this week and if I get a chance
to tidy up the code I'll send the source for SDBackup there too.
But for now heres the Doc file, and UUE file.

I wrote this backup program about a month ago when I got my Supra 20 meg
drive. It is CLI oriented, and is invoked in one command line. At the present
it does not support wild cards, but you can select a single directory
or single file. I have quite a few people who have backed up and restored
their entire drives using SDBackup with no problems.

It seems that the availability of PD backup programs is getting much better
MRBackup seems very good also, Mark obviously put alot of time into his
backup program and I don't mean to compete with anyone. I just have'nt seen
a PD backup program arround yet that uses the 1.2 archive bits. And it sure
is nice not to have to remember the last time you did a backup.

Some Features:  (SDBackup Version 1.1).
--------------

- Is generic to any drives, eg. you can backup floppies to floppies.
  You can even backup (compress) 3 1/2 to 5 1/4 disks.
- Uses LZ Compression.
- It does support 1.2 Archive bits and any file when backup up gets it's
  archive bit set, thus you can do incrementals via date/time or by
  using the archive bit. (-s LAST)
  Shell 2.07M (sending out later this week) will show you the Archive
  bits under a dir command, in the protection field.
- Has a built in maintenance mode for checking/marking/clearing archive
  bits on files. Any big files or directories you don't wont backed up
  you can then just set the archive bit on and use the -s LAST mode.
- Error recovery is easy since all the files are marked as you go,
  restarting the backup half way through will continue at the file you
  left off at.
- Having preformated your disks with labels XXXX_nn: (eg. Backup_1:)
  you can stick a disk in df0: and df1: and walk away.
- Or you can have SDBackup format them for you on the fly.
- Can have SDBackup just show you the files that would be backed up
  without doing anything by using the -V switch.


#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	sdbackup.doc
# This archive created: Mon Sep 28 09:49:41 1987
echo shar: extracting sdbackup.doc
cat << \SHAR_EOF > sdbackup.doc

	Documentation For version 1.1  
        =============================


	SDBackup	Version 1.1	
	By Steve Drew 	Sep '87


        Please direct all comments to:	

    	ENET:    CGFSV1::DREW
    	ARPA:    drew%cfgsv1.dec.com@decwrl.dec.com
    	USENET:  {decvax!decwrl}!cgfsv1.dec.com!drew    

	or any donations to:

	52 Castledale Cres. N.E.
	Calgary, Alberta
	Canada
	T3J 1X4


	Contents:
	=========

	I.   Purpose
	II.  Command Format
	III. Prerequisites
	IV.  Error Handling
	V.   Limitations
	VI.  Examples
	VII. Future Enhancements



   I.   Purpose: 
	--------

	Intended to backup and restore a selected source volume
	(hard drive) to a multi volume destination (floppies) using
	LZ compression retaining file dates and directory structures.
	The compression is done via Modified Lempel-Ziv method. Which 
	has been sped up using manx 16 bit ints.

   II.  Command Format
	--------------

	There are three modes that SDBackup can be used in
	Backup, Restore and Maintenance mode.


	BACKUP:
	
	    SDBackup [options] from Label_n:[dir]
	    
	    from
		is the file or device specification of the device to
	    	be backed up. This maybe a device (eg. dh0:) a directory
		(eg. dh0:tools) or a file (eg. dh0:tools/shell).

	    Label_n:
		This is the spec for the first volume to start the backup
		to. Eg. Back_1:. In this case you should of preformatted
	        enough floppies with labels Back_1 to Back_n where Back_n
		would probably be about 15 for a 20 meg (full) drive assuming
		about 35% compression. 
                ** If you did not format enough floppies when you click 
		cancel to the mount request you will then be given the 
		option to have a floppy automatically formatted as the
		next volume and continue.

	    Options  (applicable to backup)
		-q 	
			Quiet mode, files are not printed to stdout as copied.
		
		-l	
			Log a list of files backed up to RAM:Backup.log
			this can later be used to determine which volume
			a particular file is on via:
				search backup.log filespec

		-i
			Don't use compression. Just do an image copy.

		-s DD-MMM-YY[:HH:MM] | LAST

			Include either a date and optional time or 'LAST'
			keyword. LAST indicates to backup all files that
			have not been backed up before. This makes use
			of the AmigaDos 1.2 Archive bit in the file
			protection mask. 
		        Both these methods are intended to provide effective
			incremental backups.
			eg. A complete backup of dh0: was done a week ago
			so this was you can backup only files changed since
			then via specifying that date or by using the LAST
			key word.     You should do  incrementals to 
			separate disks. (Don't try to overite full Backups
			disks, start a new incremental set). If full backup 
			is Back_n to Back_13 then start this one at Back_14.
			Then when needing to restore dh0: first restore
			Back_n to Back_13 then Back_14 to Back_nn.
			(Actually since you started numerically one higher
			than the ending set of the full backup. It will
			ask for Back_14 automatically. This is because
			when restoring a full top level root (eg. Back_1:
			to dh0:) we don't know when to stop asking for
			next volume. We rely on the user clicking on
			cancel to determine that we are done.)

		-n 
			Use the root specified on the from device
			as the starting root rather than concatenating
			it to the source specified root.

			eg. SDBackup -n dh0:Tools Back_1:OldTools
				will backup the files and directories under
				dh0:tools into Back_1:OldTools 
			     *  This will also create sub directories 
				under dh0:Tools into sub directories 
				under Back_1:OldTools

			( Without the -n switch this would move the files
			from dh0:Tools to Back_1:OldTools/Tools...      )

		-f   
			Files only switch. Same as -n switch except all
			files from every level are placed only in the
			destination directory. (Does not create sub dirs).

			Note: -f and -n cannot both be selected.

	    Notes on Backing up:

		o All files that are compressed during backup have a ".Z"
		  tacked on to the end of the file spec. This is then removed
		  during the restore procedure.
		o Any .arc , .ARC or .Z extension files are not compressed 
		  during backup. This is because compressing a compressed 
		  file results in a bigger output file.
		o When quiet mode is not selected the following messages
		  will be seen:

           dev:dir../file.ext ==> Label_n:dir../file.ext.Z [Compressed n.n%]
           	  or if no compression used:
	   dev:dir../file.ext ==> Label_n:dir../file.ext   [Copied]



	RESTORE:
	
	    SDBackup -r [options] Label_n:[dir][file] ToDIR
	    
	    Label_n:
		This is the spec for the first volume to start the restore
		from. Eg. Back_1:
		If you are restoring a file or directory and you have 
		determined which label it starts on, then enter that 
		label name to start with. Or enter the first volume and
		be prompted for the following volumes until that directory
		or file is found.

	    ToDir
		Where to put the files. Must ALWAYS be a directory.
		Usually this would be the from spec you had entered when 
		you did the Backup. (eg. Dh0:) But it could be a different
		root or to be put under another directory (See -n switch).

	    Options (applicable to restoring)
	
	        -r
		    This denotes that we are doing a restore rather than a 
		    backup. In this case it is the source that is a multi-
		    volume set. And we do decompression of any .Z files.

	        -q
		    Don't print files as there are restored, to stdout.

	        -s 
		    Not really needed for restore operations although
		    it will work. The -s LAST keyword will not work with
		    restoring. See above.

	        -i  
		    Don't decompress, just an image copy.

	        -n  
		    Same function as -n on backup. See above.

	        -f 
		    Same function as -f on backup. See above.

	    
	   Notes on restoring:

	      o If compression was used on backup, files will have 
		a .Z appended  and you will have to include this into
		the file spec if selecting just a single file to restore.

	      o When restoring from a top level directory eg. Back_1:
		we are unable to determine when we have finished the
		restore and will keep asking for the next volume. You
		must then click cancel,  after the last volume has
		be restored. (This is because every volume has a top
		level directory)
		When restoring a selected file or directory we can
		determine when to stop asking for the next volume.


	MAINTENANCE MODE:

	    SDBackup [-s last] -V [-M | -C]  path
	
	    Maintenance mode allows for viewing of files that would be
	    backed up according to your file spec and -s qualifiers or
	    to mark or clear the archive bit on any selected files.
	    
	       - s last
		    select only files with archive bit set.

	       -V  
		    View mode, enables file listing of files that will
		    be chosen for backup. If included with -D or -C
		    will display files as their Archive bit is set
		    or cleared.

	       -M
		    Mark file as Backed up. (Set archive bit).

	       -C
		    Clear archive bit.

		note: all other switches are ignored when in maint mode.

		Examples of maintenance mode commands:
		
		SDBackup -C dh0: 	 ! clear archive bit on all files

		SDBackup -M dh0:TMPdir   ! set archive bit on all files/dir
					   under tmpdir.

		SDBackup -s last -V dh0: ! show all files that have not
					   been backed up. (archive clear).

		SDbackup -V -M dh0:	 ! mark archive bit, show files as
					   we do it.
			

   III. Prerequisites
	------------

	o Any file system device.
	  It is not device dependent so you may backup/restore to from
	  any file system device.
	o Format program.
	  Since the format program is optionally called, it must be found
	  via the AmigaDos Pathing from the current CLI.
	  The format command is usually found in SYS:System/. So do a
	  path SYS:system add if necessary.

   IV.  Error Handling
	--------------

	Possible Errors:		    What is done:
        ---------------			    -------------
	Read error on source.               skip file, continue on.
       *Write error to destination.	    skip file, continue on.
	Can't find next volume on Backup    Allow formatting a new disk, cont.
	Error creating directory	    Skip entire directory, continue.

	*write err's (if detected may cause unable to handle conditions, 
	 if dos decides the disk is corrupt ). Also if you were
	 doing an incremental backup, those files that did make it
	 on the disk before it went bad, will be marked as backed up.

	Recovering from a serious error/crash. If you were backing up
	and the system crashed or there was some reason that the backup
	aborted. You can restart at the very file you left off at by
	always using the -s LAST switch, this would then skip all the
	files you had already done since the archive bit would be set.
	If you are doing a full backup (all files) it would be a good
	idea to first use the maintenace mode and clear the archive
	bit on all the files. That way if you should have to restart
	the files, will be correctly marked.


   V.	Limitations
	-----------

	As per this version SDBackup can only be run from the CLI.


   VI.  Examples
	--------

	1. Full Backup of dh0: to Floppies starting with label Backup_1: ,
	   making a log file (ram:Backup.log) of all copied files.

		SDBackup -l dh0: Backup_1:

	   Restoring above:
	
		SDBackup -r Backup_1: dh0:

	2. Incremental Backup of dh0: since 25-Aug-87:17:00

	        SDBackup -s 25-aug-87:17:00 dh0: Backup_incr_1:

	   Restoring dh0: (assuming dh0: now empty):
		
		SDBackup -r Backup_1: dh0:
	   then SDBackup -r Backup_incr_1: dh0:

	3. Backup only file dh0:source/FooBar.c to directory Back_9:OLD with
	   no compression

		SDBackup -fi dh0:source/FooBar.c Back_9:OLD

	   Restoring above file to dh0:source

		SDBackup -f -r Back_9:OLD/FooBar.c dh0:source

	4. Backup root dh0:Sonix starting at Back_1:Music/Sonix_V1

		SDBackup -n dh0:Sonix Back_1:Music/Sonix_V1

	   Restoring above to dh0:Music/Sonix_V1

		SDBackup -r Back_1:Music/Sonix_V1 dh0:
			
	5. Backup file dh0:Tools/ls to Back_11:Tools directory
	       
		SDBackup -f dh0:tools/ls Back_11:Tools

	   Restoring above 
		
		SDBackup -rf Back_11:Tools/ls.Z dh0:



	
   VII. Future Enhancements
        -------------------

	o Add -o switch to force overiding an existing file when restoring
	  else only restore if Backup file is newer than destination.

	o As per suggestions.
	
SHAR_EOF
if test 10464 -ne "`wc -c sdbackup.doc`"
then
echo shar: error transmitting sdbackup.doc '(should have been 10464 characters)'
fi
#	End of shell archive
exit 0