File versioning and deleting on OpenVMS with DELETE and PURGE

15-04-2018 | Remy van Elst


Table of Contents


openvms

(You can read all my OpenVMS articles by clicking the picture above)

I'm now a few weeks into my OpenVMS adventure and my home folder on the DECUS system is quite cluttered with files. More specifically, with different versions of files, since OpenVMS by default has file versioning built in. This means that when you edit a file, or copy a file over an existing file, the old file is not overwritten but a new file with a new version is written. The old file still is there. This is one of the best things in my humble opinion so far on OpenVMS, but it does require maintenance to not have the disk get filled up fast. This article goes into the PURGE and DELETE commands which help you deal with file versioning and removal.

If you like this article, consider sponsoring me by trying out a Digital Ocean VPS. With this link you'll get a $5 VPS for 2 months free (as in, you get $10 credit). (referral link)

DIR flags

My home folder DECUS is getting filled up with test files and other titbits.

   $ DIR /SIZE /OWNER /DATE /PROTECTION

Look at those fancy new flags I found to get more information out of DIR:

Directory DSA3:[DECUSERVE_USER.EXAMPLE]

$MAIN.TPU$JOURNAL;1
                              1  28-MAR-2018 07:42:31.09  [EXAMPLE]                           (RWED,RWED,,)
.VIMINFO;1                   10  15-APR-2018 08:39:53.81  [EXAMPLE]                           (RWED,RWED,,)
A.;1                          1   8-APR-2018 05:30:44.16  [EXAMPLE]                           (RWED,RWED,,)
ICREATEDAFOLDERYAY.DIR;1
                              1  28-MAR-2018 08:22:18.41  [EXAMPLE]                           (RWE,RWE,,)
LOGIN.COM;2                   2   8-APR-2018 06:02:12.72  [EXAMPLE]                           (RWED,RWED,,)
LOGIN.COM;1                   2   1-MAR-2018 10:10:32.12  [EXAMPLE]                           (RWED,RWED,,)
LOGIN_COM.TPU$JOURNAL;1
                              1   8-APR-2018 06:00:38.04  [EXAMPLE]                           (RWED,RWED,,)
MAIL.DIR;1                    1   8-APR-2018 16:28:23.24  [EXAMPLE]                           (RWE,RWE,,)
NOTES$NOTEBOOK.NOTE;1
                             51   1-MAR-2018 09:56:04.63  [DECUSERVE]                      (RWE,RWE,,)
RAYMII.DIR;1                  1  31-MAR-2018 14:29:02.15  [EXAMPLE]                           (RWE,RWE,,)
REMY.DAT;8                    1  15-APR-2018 08:39:53.79  [EXAMPLE]                           (RWED,RWED,,)
REMY.DAT;7                    1  15-APR-2018 08:39:47.90  [EXAMPLE]                           (RWED,RWED,,)
REMY.DAT;6                    1  15-APR-2018 08:39:12.75  [EXAMPLE]                           (RWED,RWED,,)
REMY.DAT;5                    1  15-APR-2018 08:39:05.02  [EXAMPLE]                           (RWED,RWED,,)
REMY.DAT;4                    1  15-APR-2018 08:38:44.90  [EXAMPLE]                           (RWED,RWED,,)
REMY.DAT;3                    1  31-MAR-2018 14:44:31.08  [EXAMPLE]                           (RWED,RWED,,)
REMY.DAT;2                    1  28-MAR-2018 07:52:19.04  [EXAMPLE]                           (RWED,RWED,,)
REMY.DAT;1                    1  28-MAR-2018 07:48:21.66  [EXAMPLE]                           (RWED,RWED,,)
SSH.DIR;1                     1   3-APR-2018 15:27:07.45  [EXAMPLE]                           (RWE,RWE,,)
SSH2.DIR;1                    1   3-APR-2018 13:16:46.97  [EXAMPLE]                           (RWE,RWE,,)
SSH3.DIR;1                    1   5-APR-2018 13:10:06.94  [EXAMPLE]                           (RWE,RWE,,)
WWW.DIR;1                     1  28-MAR-2018 07:43:47.18  [EXAMPLE]                           (RWE,RWE,,RE)

Total of 22 files, 83 blocks.

Lets focus on the REMY.DAT file, that has 8 versions and all the old ones can be removed.

Look at the files with TYPE

Using the TYPE command we can look at a file. Specify the full filename and a specific version number, otherwise if you omit the version you will see the last version:

 $ TYPE REMY.DAT;1
Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.
hello

Version 4:

 $ TYPE REMY.DAT;4
Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.

Beware the Jabberwock, my son!
The jaws that bite, the claws that catch!
Beware the Jubjub bird, and shun
The frumious Bandersnatch!

The last version:

 $ TYPE REMY.DAT;8

Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.

Beware the Jabberwock, my son!
The jaws that bite, the claws that catch!
Beware the Jubjub bird, and shun
The frumious Bandersnatch!

He took his vorpal sword in hand:
Long time the manxome foe he sought-
So rested he by the Tumtum tree,
And stood awhile in thought.

And as in uffish thought he stood,
The Jabberwock, with eyes of flame,
Came whiffling through the tulgey wood,
And burbled as it came!

One, two! One, two! And through and through
The vorpal blade went snicker-snack!
He left it dead, and with its head
He went galumphing back.

And hast thou slain the Jabberwock?
Come to my arms, my beamish boy!
O frabjous day! Callooh! Callay!
He chortled in his joy.

Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.

(For those who do not get the reference).

As you can see, the poem is finished in the last versions and the earlier versions are working copies that can be removed now that this poem is done.

PURGE

The PURGE command removes all but the highest version of a file. The DELETE command, which we will cover in the next section, only removes specific files and it requires you to specify a version number as well.

The PURGE command is therefore usefull to clean up old versions of a file. There are a few usefull flags, for example the /SINCE flag. It removes only the versions from after the specified time. Lets say I worked on a file the whole week but all versions that were created yesterday and today only contain formatting fixes, I would specify the PURGE /SINCE=YESTERDAY $FILE. The versions of earlier in the week which do contain changes I want to keep, will be saved that way.

The opposite of that flags is /BEFORE flag. It removes all versions of a file before the given time. If I wanted to save all versions that I created yesterday and today, but remove all earlier versions, the command would be PURGE /BEFORE=YESTERDAY $FILE.

If you do want to keep some versions, the /KEEP flag allows you to specify a number of versions to keep. To keep the 5 last versions, specify /KEEP=5.

The /LOG flag shows you the result, thus which files were removed. By default no output is logged.

So for my poem, to remove all versions but the last:

 $ PURGE /LOG REMY.DAT
%PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;7 deleted (3 blocks)
%PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;6 deleted (3 blocks)
%PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;5 deleted (3 blocks)
%PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;4 deleted (3 blocks)
%PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;3 deleted (3 blocks)
%PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;2 deleted (3 blocks)
%PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE]REMY.DAT;1 deleted (3 blocks)
%PURGE-I-TOTAL, 7 files deleted (21 blocks)

Create a directory with version limits

Using the /VERSION_LIMIT flag when creating a folder limits the amount of versions that will be kept. By default it is unlimited. To create a folder named THREE where at max 3 versions are kept, use the following command:

 $ CREATE /DIRECTORY /VERSION_LIMIT=3 [.THREE]
 $ SET DEF [.THREE] 

I have edited my REMY.DAT file three times:

 $ DIR
Directory DSA3:[DECUSERVE_USER.EXAMPLE.THREE]

REMY.DAT;3          REMY.DAT;2          REMY.DAT;1

Now after a new edit, version 1 of the file will be gone:

 $ DIR

Directory DSA3:[DECUSERVE_USER.EXAMPLE.THREE]

REMY.DAT;4          REMY.DAT;3          REMY.DAT;2

Total of 3 files.

To create a folder without versioning, specify /VERSION_LIMIT=1.

Combining that with the previous section, if I wanted to keep the two last versions, I would use the following command:

 $ PURGE /LOG /KEEP=2 REMY.DAT
%PURGE-I-FILPURG, DSA3:[DECUSERVE_USER.EXAMPLE.THREE]REMY.DAT;2 deleted (3 blocks)

Let's check if versions 3 and 4 are still there:

 $ DIR

Directory DSA3:[DECUSERVE_USER.EXAMPLE.THREE]

REMY.DAT;4          REMY.DAT;3

Total of 2 files.

DELETE

You can read most of my delete adventures here when I tried to remove a folder.

Reading the documentation on DELETE, the same usefull flags like /BEFORE and /SINCE can be used. However, they will not remove previous versions, but all previous files and must be used with wildcards:

/BEFORE[=time]
Selects only those files dated prior to the specified time. You can specify time as absolute time, as a combination of absolute and delta times, or as one of the following keywords: BOOT, LOGIN, TODAY (default), TOMORROW, or YESTERDAY.

Even back then they were already not actually removing a file, but just marking the location as usable again. The /ERASE flag also overwrites the files with something so that the data actually is not on the disk and not recoverable anymore:

/ERASE
/NOERASE (default)
When you delete a file, the area in which the file was stored is returned to the system for future use. The data that was stored in that location still exists in the system until new data is written over it. When you specify the /ERASE qualifier, the storage location is overwritten with a system specified pattern so that the data no longer exists.  

The rm -rf alternative for OpenVMS seems to be the /TREE flag:

/TREE
Recursively deletes all files and sub directories excluding the parent directory.

As said, DELETE requires a version number. Just trying to delete my REMY.DAT file will fail:

 $ DELETE REMY.DAT
%DELETE-E-DELVER, explicit version number or wild card required

When a version is specified it does work:

 $ DELETE /LOG REMY.DAT;4
%DELETE-I-FILDEL, DSA3:[DECUSERVE_USER.EXAMPLE.THREE]REMY.DAT;4 deleted (3 blocks)

Conclusion

In this article we covered the different ways to cleanup versions of files, in the other article we covered the removal of directories.

We also know now how to create a folder with limits on the amount of versions that are kept.


Tags: alpha,dec,decus,itanium,openvms,pdp,simh,vax,vms,