From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 30-MAR-1989 13:31
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Backing up to a remote tape drive


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu, 30 MAR 89 09:32:18 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Thu, 30 Mar 89 09:15:29 PST
Received: by ucbvax.Berkeley.EDU (5.61/1.36)
	id AA27929; Thu, 30 Mar 89 08:03:44 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 30 Mar 89 02:04:49 GMT
From: snjsn1!bach!bob@uunet.uu.net  (Bob Firestine)
Organization: Schlumberger ATE, San Jose, CA
Subject: Backing up to a remote tape drive
Message-Id: <794@snjsn1.SJ.ATE.SLB.COM>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

I wrote a command procedure which backs up a disk to a save set on a remote
tape drive.  It was inspired by some articles I read, including the one in
Pageswapper.  I don't have them with me so cannot list them.  Unfortunately,
I have no procedure for restoring over DECnet.  Has anyone written one
(is it even possible?)?
---------------------------------------------------------------------------
$ set noon
$!
$!		This command procedure writes a full image or an incremental
$!		backup of a disk volume to a tape drive on a remote system. 
$!		There is no verify pass.  No other file or DECnet object is
$!		needed - this command procedure creates the necessary command
$!		procedure on the remote node.
$!
$!		You may need to specify a large value for the OUTGOING TIMER
$!		for the EXECUTOR on the node where you execute this.
$!
$!		You might also need to adjust the system parameter RMS_DFNBC
$!		to handle large blocks - the default (8) allows 4096 byte
$!		blocks to be transferred.
$!		
$!
$!		You may pass parameters to this procedure:
$!
$!			p1:	disk to be backed up
$!			p2:	tape drive name
$!			p3:	F[ull] or I[ncremental] - the type of backup
$!
$!		You must modify the following to suit your site:
$!
$ create_listing = "true"
$ default_density = "6250"
$ local_priority = "4"
$ default_remote_node = "sjs"
$ default_tape_drive = "hsc007$mua16"
$ default_username = "firestine"
$ initialize_tape = "True"
$ prompt_for_node = "True"
$ remote_priority = "5"
$ use_proxy_account = "False"
$!
$!		Initialization
$!
$!! block_size = f$getsyi("RMS_DFNBC") * 512
$ block_size = 8192
$ current_priority = f$getjpi("","pri")
$ file_created = "false"
$ i_mounted_the_disk = "false"
$!
$ on control_y then $ goto ctrl_y_abort
$!
$!		Prompt for node if symbol prompt_for_node is true
$!
$ if prompt_for_node then -
	$ inquire /nopunctuation node -
	"Node with tape drive? [''default_remote_node'] "
$ if prompt_for_node then $ if node .eqs. "" then $ node = default_remote_node
$ if .not. prompt_for_node then $ node = default_remote_node
$ node = node - "::"
$!
$!		Get username and password (not echoed) if there is no proxy
$!
$ if use_proxy_account then $ goto use_proxy_account
$ inquire /nopunctuation username "Username? [''default_username'] "
$ if username .eqs. "" then $ username = default_username
$!
$ set terminal /noecho
$ open /read term tt:
$ read term password /prompt="Password? "
$ set terminal /echo
$use_proxy_account:
$!
$!		Get disk name if not passed as a parameter
$!
$get_drive_name:
$ if p1 .eqs. "" then $ inquire /nopunctuation p1 "Disk drive? "
$ if p1 .eqs. "" then $ exit
$!
$!		Verify that the input device exists and is mounted
$!
$ if .not. f$getdvi(p1,"exists") then $ goto disk_problem
$ disk_mounted = f$getdvi(p1,"mnt")
$ if .not. disk_mounted then $ mount /override=identification 'p1'
$ if .not. $status then $ goto disk_problem
$ if .not. disk_mounted then $ i_mounted_the_disk = "true"
$ disk_label = f$getdvi(p1,"volnam")
$ save_set_name = disk_label
$ tape_label = f$extract(0,6,disk_label)
$!
$!		Get tape drive name if not passed as a parameter
$!
$ if p2 .eqs. "" then -
	$ inquire /nopunctuation p2 "Tape drive? [''default_tape_drive'] "
$ if p2 .eqs. "" then $ p2 = default_tape_drive
$!
$!		Get density
$!
$ inquire /nopunctuation density "Tape drive density? [''default_density'] "
$ if density .eqs. "" then $ density = default_density
$!
$ full_or_inc = p3
$get_full_or_inc:
$ If full_or_inc .eqs. "" then -
	$ Inquire /nopunctuation full_or_inc "Full or incremental? "
$ If full_or_inc .eqs. "" then $ Exit
$ full_or_inc := 'f$extract(0,1,full_or_inc)'
$ if full_or_inc .eqs. "F" .or. full_or_inc .eqs. "I" then $ goto full_or_inc_ok
$ full_or_inc = ""
$ goto get_full_or_inc
$full_or_inc_ok:
$!
$ disk_drive = p1 - ":" + ":"
$ tape_drive = p2 - ":" + ":"
$!
$!		Write command procedure to target system
$!
$ close /nolog out
$ pid = f$getjpi("","PID")
$ com_file = pid + ".tmp"
$ verify = f$verify(0)
$ if .not. use_proxy_account then -
	$ open /write out 'node'"''username' ''password'"::'com_file'
$ if       use_proxy_account then $ open /write out 'node'::'com_file'
$ if verify then $ set verify
$ if .not. $status then $ goto cannot_write_com_file
$ file_created = "T"
$ write out "$ set verify"
$ write out "$ set noon"
$ write out "$ set process /privilege=volpro"
$ write out "$ set process /priority=''remote_priority'"
$ write out "$ allocate ''tape_drive'"
$ write out "$ if .not. $status then $ exit"
$ if initialize_tape then $ write out "$ initialize /density=''density' -"
$!		VMS bug - must abbreviate owner_identification
$ if initialize_tape then -
	$ write out "	/over=(accessibility,expiration,owner_ident) -"
$ if initialize_tape then $ write out "	''tape_drive' ''tape_label'"
$ write out -
	"$ mount /block=''block_size' /override=identification ''tape_drive'"
$ write out "$ convert sys$net /fdl=sys$input ''tape_drive'''save_set_name'"
$ write out "file"
$ write out "	organization		sequential"
$ write out "record"
$ write out "	carriage_control	none"
$ write out "	format			fixed"
$ write out "	size			''block_size'"
$ write out "$ dismount /nounload ''tape_drive'"
$ write out "$ deallocate ''tape_drive'"
$ write out "$ exit"
$ close out
$ verify = f$verify(0)
$!
$!		Determine BACKUP command qualifiers
$!
$ qualifiers = "/fast /ignore=interlock"
$ if create_listing then -
	$ qualifiers = qualifiers + "/list=sys$login:''save_set_name'.list"
$ if full_or_inc .eqs. "I" then $ qualifiers = qualifiers + "/since=backup"
$ if full_or_inc .eqs. "F" then $ qualifiers = qualifiers + "/image/record"
$ if full_or_inc .eqs. "I" then file_spec = "[*...]*.*;"
$ if full_or_inc .eqs. "F" then $ file_spec = ""
$ set process /priority='local_priority'
$ if .not. use_proxy_account then -
	$ backup 'qualifiers' 'disk_drive''file_spec' -
	'node'"''username' ''password'"::"task=''com_file'" /save -
	/block='block_size'
$ if       use_proxy_account then $ backup 'qualifiers' 'disk_drive''file_spec' -
	'node'::"task=''com_file'" /save /block='block_size'
$ if verify then $ set verify
$ goto done
$!
$!
$disk_problem:
$ write sys$output "Unable to access the disk drive"
$ p1 = ""
$ goto get_drive_name
$ exit
$!
$!
$cannot_write_com_file:
$ write sys$output "Cannot create command procedure on target system - exiting"
$ goto done
$!
$!
$ctrl_y_abort:
$ goto done
$!
$!
$done:
$!
$!		Cleanup/restore everything I changed/created
$!
$ set process /priority='current_priority'
$ set terminal /echo
$ close /nolog out
$ if i_mounted_the_disk then $ dismount /nounload 'disk_drive'
$ verify = f$verify(0)
$ if file_created then $ if .not. use_proxy_account then $ delete /log -
	'node'"''username' ''password'"::'com_file';
$ if file_created then $ if       use_proxy_account then $ delete /log -
	'node'::'com_file';
$ if verify then $ set verify

-------------------------------------------------------------------------------

Bob Firestine
Schlumberger Technologies	DOMAIN: bob@sj.ate.slb.com
1601 Technology Drive           UUCP:   {amdahl,decwrl,uunet}!sjsca4!bob
San Jose, CA 95115
408-437-5216		

