(Updated 2022 Mar 02)
tar
the 4mm Tape Achiver
I excerpted parts of the manual page for tar below. If you want the full version type man tar. There is probably 10-20 times more stuff than I have pasted here.
NOTE: You need to be logged into Shiva (be it physically or remotely) in order to use the tape drive.
An example of a backing something up would be tar vr blah*.bla As I will explain below, you may not want to use a wildcard. (The flag 'v' stands for verbose, and I generally use it in tar.)
You use tar vc <stuff> if you're starting a new tape. I don't know what'll happen if you try tar vr <stuff> with a new tape. If you accidentally use tar vc <stuff> on an old tape you'll overwrite the old files. That would suck.
To retrieve a file from tape, you would type tar vx bla001.bla
I don't think that one can use wildcards in tar, so extracting a bunch of files individually would be a pain. The way to get around this that I can think of is to back up the whole directory: tar vr BACKUP_DIR . The caveat is that when you extract from tape (tar vx BACKUP_DIR) tar will write the files to the directory BACKUP_DIR, and will create BACKUP_DIR if it doesn't exist. Thus, the files will be written to BACKUP_DIR/{file1,file2,etc.} There are tricks on the (full) man page about overwriting and not overwriting stuff already on disk.
One can write a table of contents to a file with tar vt > FILENAME
One can archive a bunch of files into a single archive file. This is useful, for example, when packaging a lump of files for transfer. The usage is tar cvf ARCHIVE.tar blah*.bla. Make sure that the target archive file is listed before the input file list; otherwise you will overwrite the first file in your list with the archive file.
You can also use tar to copy files. One example where this is useful is when you want to preserve the directory structure, such as if you had a file called run1/Iter_4/Iter_4_filtered_reconstruction.vol that you wanted to keep in a subdirectory run1/Iter_4/. The syntax, adapted from O'Reilly Media, is:
tar cf - * | (cd /work/bkup/zing && tar xBf -)
One can eject the tape by typing mt unload . There is a whole family of 'mt' commands. Type man mt if you're interested. The other mt command I use frequently is mt status which just tells you if the tape drive is ready or (thinks it) is doing something.
You can create a script that contains the commands as if you were entering them interactively. (I made a link to an example here.) You need to make the script executable by typing chmod +x SCRIPTNAME . You then submit the script by typing SCRIPTNAME & .The ampersand ('&') puts the job in the background, meaning you can use the window for other things and even log out without killing the job.
tar works a bit differently on the Alphas than on an SGI. What's written below should work, but there are additional useful features as well, e.g. the ability to read multiple archived files at a time.
tar can also be used to copy remote files. The syntax, adapted from nixCraft, is:
ssh zing@domain "cd /home/zing/ && tar -czf - file_pattern | tar xzfv -"
To upload using tar (adapted from StackExchange) would be:
tar -czf - file_pattern | ssh zing@domain "(cd /home/zing/ && tar -xzfv - )"
NAME
tar - tape archiver
SYNOPSIS
tar key [directory] [tapefile] [blocksize] [ name ... ]
KEYS
r Append the named files at the end of the archive. On tape, named
files are appended at the end of the last archive on tape. See the
NOTES section below, for drives that support this operation, and
other limitations.
x Extract the named files from the tape. If a named file matches a
directory whose contents had been written onto the tape, this
directory is (recursively) extracted. The owner, modification
time, and mode are restored, subject to umask(2). If no file
argument is given, the entire content of the tape is extracted.
Note that if multiple entries specifying the same file are on the
tape, the last entry overwrites all earlier entries.
t List the names of the specified files each time they occur on the
tape. If no file argument is given, list all of the names on the
tape.
c Create a new tape; writing starts at the beginning of the tape
instead of after the last file. This option assumes that you are
at the beginning of the tape.
v Normally tar does its work silently. The v (verbose) option make
tar print the name of each file it treats preceded by the function
letter. With the t function, the verbose option gives more
information about the tape entries than just their names.
This page is Lynx-enhanced.