Fix savesets transferred by FTP

OpenVMS savesets have special file characteristics and the backup utility depends on them. Unfortunately when transferring a saveset using tools like FTP these file characteristics are lost as FTP moves the contents of a file not the attributes of a file. The DCL command copy/ftp knows about this and sets up a peer-to-peer connection and also copies the file attributes, if both client and server are OpenVMS.

Using normal FTP tools such as WinSCP or WSftp or Windows built-in FTP results in unusable file attributes. The biggest issue is the record length attribute because that may vary depending on how the saveset was created.

An undocumented characteristic of a saveset is that the expected record length is included in the saveset header. This can be used to correct the saveset attributes and make it usable.

Included below is a procedure which, I believe, we obtained from OpenVMS Engineering at some point. There are other versions floating around the Internet. We use the following.  Just copy it and paste it into your favorite VMS editor.

-----------------Begin Snip-------------------------------------
$! P1 is the specification of the BACKUP saveset
$! This procedure resets the record format and record
$! length attributes of a BACKUP saveset -- savesets
$! can get "broken" during certain sorts of file
$! transfers -- such as FTP. This procedure reads the
$! (undocumented) saveset record attributes directly
$! out of the target file.
$! First render the saveset readable, and implicitly
$! check that the file exists.
$ Set File /Attributes=(RFM:FIX,MRS:512,LRL=512,ORG=SEQ,RAT=NONE) 'p1'
$ Open/Error=whoops/Read BckSaveset 'p1'
$ Read/Error=whoops/End=whoops BckSaveset Record
$ Close/Nolog BckSaveset
$! Find the blocksize from within the record...
$ BlockSize = 0
$ BBH_L_BLOCKSIZE = %x28*8
$ BlockSize = F$CVUI(BBH_L_BLOCKSIZE, 32, Record)
$ If BlockSize .lt. 2048 .or. BlockSize .gt. 65535
$ Then
$      Write sys$output "Unexpected block size"
$      Goto whoops
$ Else
$      Set File /Attributes=(RFM:FIX,LRL='BlockSize',       -
                             MRS='BlockSize',RAT=none) 'p1'
$ endif
$ exit
$WHOOPS: $ Write sys$output "Error"
$ exit
-----------------------end snip-----------------------