BAR(1) — USER COMMANDS
NAME
bar − create tape archives, and add or extract files
SYNOPSIS
bar [−]c|r|R|x|t|u [ function_modifiers [ arguments ] ] filename ... [ −C dir filename ] ...
AVAILABILITY
Sun386i systems only.
DESCRIPTION
bar archives and extracts multiple files onto a single file archive, called a barfile. It is quite similar to tar(1), but it has additional function modifiers, and can read and write multiple volumes of tapes or formatted diskettes (see fdformat(1)). It reads and writes a format that is incompatible with tar (see bar(5)).
bar’s actions are controlled by the first argument on the command line, a string of characters containing exactly one function letter, or key, from the set crxtuR, and one or more of the optional function modifiers listed below. Some function modifiers take arguments. The arguments must appear one after the other after all the function modifiers, in the same order their corresponding function modifiers appear on the command line. For example, in the string tfvD, t is a key, f is the barfile function modifier, v is the verbose function modifier, and D is the date function modifier. f and D require arguments. On the command line, the arguments must be in the order barfile, then date. The barfile argument is usually a quarter-inch SCSI magnetic tape drive or a 3.5-inch floppy disk drive, but it can be any file or supported device.
Other arguments to bar, indicated by filename ... in the SYNOPSIS, are file or directory names that specify which files to archive or extract. In all cases, the appearance of a directory name refers recursively to the files and subdirectories of that directory.
FUNCTION LETTERS (keys)
c Create a new barfile and write the named files onto it.
r Write the named files on the end of the barfile. Note: this key does not work with quarter-inch archive tapes.
R Read the volume header of the bar archive and print the information to standard output. Only the f function modifier works with this key.
x Extract named files from the barfile. If a named file matches a directory with contents written onto the tape, this directory is (recursively) extracted. The owner, modification time, and mode are restored (if possible). If no filename arguments are given, all files in the archive are extracted. Note: if multiple entries specifying the same file are on the tape, the one physically last in the archive overwrites all earlier versions, unless the T function modifier is used.
t List the table of contents of the barfile.
u Add the named files to the barfile if they are not there or if they have been modified since they were last archived. Note: this key does not work with quarter-inch archive tapes.
FUNCTION MODIFIERS
014578
Select an alternate drive on which the tape is mounted. The numbers 2, 3, 6, and 9 do not specify valid drives. The default drive is /dev/rmt8.
A filesystem_type
Limit bar to only back up files from filesystems with the type specified in filesystem_type (see fstab(5)). This is often used to stop bar from backing up network files (with the filesystem type specified as 4.2).
b blocksize
Use the next argument as the blocking factor for records. The default blocking factor is 20 blocks. The block size is determined automatically when reading tapes (key letters x and t). This determination of the blocking factor may be fooled when reading from a pipe or a socket (see the B function modifier below). The maximum blocking factor is determined only by the amount of memory available to bar when it is run. Larger blocking factors result in better throughput, longer blocks on nine-track tapes, and better media utilization. Note: the blocking factor on tapes is forced to 126 and the blocking factor on diskettes is forced to 18. These are the optimal blocking factors for these devices and are necessary in reading and writing multi-volume archives.
B Force bar to perform multiple reads (if necessary) so as to read exactly enough bytes to fill a block. This modifier exists so that bar can work with pipes and across the Ethernet, since pipes and sockets return partial blocks even when more data are coming.
d output_filename
Use the next argument as a second output for the bar archive. This output must be an ordinary file, not a device such as a tape or diskette, because bar does not do necessary error checking for multiple output volumes on this file.
D date
Use the next argument (in the form ’yymmddhhmm’, where ’yy’ is a year, ’mm’ is a month from 01-12, ’dd’ is a day from 01-31, ’hh’ is an hour from 01-24, and ’mm’ is a minute from 00-59) as the date in the volume header, instead of the current date. This function modifier is only useful with the c function letter.
f barfile
Use the next argument as the name of the barfile. If f is omitted, bar uses /dev/rmt8 by default. If barfile is given as ‘−’, bar writes to the standard output or reads from the standard input, whichever is appropriate. Thus, bar can be used as the head or tail of a filter chain. bar can also be used to copy hierarchies with the command:
example% cd fromdir; bar cf − . | (cd todir; bar xfBp −)
F With one F function modifier specified, exclude all directories named SCCS from barfile. With two modifiers, FF, exclude all directories named SCCS, all files with .o as their suffix, and all files named errs, core, and a.out.
G group_id
Use the next argument as the group ID in the volume header, or as the group ID to be used with the s function modifier.
h Follow symbolic links as if they were normal files or directories. Normally, bar does not follow symbolic links. Note: symbolic links followed in this way are not archived as symbolic links. They are archived as directories or files. When these directories and files are restored, they are not restored as symbolic links, but as directories and files.
H volume_header
A string of up to 128 characters is to be used as a volume header ID. A null volume header ID is written in each volume header of the archive when this function modifier is not specified. See bar(5) for the volume header’s format. This modifier is only useful with the c key letter.
i Ignore directory checksum errors.
I include_file
Use the next argument as a file containing a list of file names, one per line, to be included in the bar archive. The file names in the include file must be followed by a semicolon and newline character. If excluded files (see the X flag) also exist, excluded files take precedence over all included files. So, if a file is specified in both the include and exclude files (or on the command line), it will be excluded.
K If a file specified on the command line or in an include file (see the I flag) is a symbolic link to a directory, follow that symbolic link as with the L flag. Do not follow any other symbolic links.
l Display error messages if all links to archived files cannot be resolved. If l is not used, no error messages are printed.
L Normally, directories that are symbolic links are archived and restored as symbolic links. With the L function modifier, bar follows directory symbolic links as if they were normal directories. If there is a symbolic link to a directory with files or other symbolic links to directories, the archive will include the contents of these directories or files.
M date
Incremental backup. Only files which have changed since date are archived. date is in the form of seconds since 00:00:00 hours GMT, January 1, 1970.
m Do not extract modification times of extracted files. The modification time will be the time of extraction.
N Do not overwrite bar archives with the c function letter if the user ID in the volume header of the archive does not match that of the user creating the archive.
o Suppress information specifying owner and modes of directories which bar normally places in the archive. Such information makes former versions of bar generate an error message like:
filename: cannot create
when they encounter it.
O When extracting files with the x function letter, do not extract any files and issue an error message if the user ID in the volume header of the bar archive does not match that of the user extracting the files.
p Restore the named files to their original modes, ignoring the present umask. Setuid and sticky bit information (see chmod(1V)) are also extracted if you are the super-user. This modifier is only useful with the x key letter.
P prompt
Use the next argument as the prompt for media change conditions. If this argument, which is a string, contains a printf(3S) conversion specification in the form of ’%d’, then that conversion specification will be replaced with the current volume number.
s Force the ownership of extracted files to match the user’s effective user ID and group ID, or to match a user ID specified with the U function modifier and a group ID specified with the G function modifier.
S from_directory to_directory
Requires two arguments: the ’from’ directory and the ’to’ directory. If the path name of any extracted file begins with ’from’ directory, then bar replaces ’from’ directory with ’to’ directory. This function is only useful with the x function letter and is useful in restoring files and directories to a different location.
T When using the x or t function letters, terminate the search of the barfile after all the files specified are extracted (for x) or listed (for t).
U user_id
Use the next argument as the user ID in the volume header, or as the user ID to be used with the s function modifier.
v Normally bar does its work silently. The v (verbose) modifier displays the name of each file bar handles, preceded by the function letter. When used with the t key, v displays the barfile entries in a form similar to ‘ls −l’. Each entry displayed is followed by the date the bar archive was created and the volume number on which the entry can be found.
V volume_number
Use the next argument as the starting volume number in the prompt for media changes. This function modifier is useful in situations where some volumes in a sequence are not written in bar format.
w Wait for user confirmation before taking the specified action. If you use w, bar displays the action to be taken followed by the file name, and then waits for a y response to proceed. No action is taken on the named file if you type anything other than a line beginning with y.
X exclude_file
Use the next argument as a file containing a list of named files (or directories) to be excluded from the barfile when using the key letters c, x, or t. Multiple X function modifiers may be used, with one exclude_file per modifier.
Z Specify compression. bar will compress files when used with the c function letter and will uncompress files when used with the x function letter. bar will neither compress a compressed file, nor uncompress an uncompressed file. bar compression uses compress(1). It requires that there be free space in /tmp about 1.5 times the size of the uncompressed archive. If the space is not available, bar silently does an uncompressed archive. In this case, bar will exit with a status of 5.
OPTIONS
−C dir filename
In a c (create) or r (replace) operation, bar performs a chdir (see csh(1)) to that directory before interpreting filename. This allows multiple directories not related by a close common parent to be archived using short relative path names. The following example archives files from /usr/include and from /etc:
example% bar c −C /usr include −C /etc .
If you get a table of contents from the resulting barfile, you will see something like:
include/
include/a.out.h
and all the other files in /usr/include
and all the other files in /etc
Note: the -C option only applies to one following directory name and one following file name.
EXAMPLES
Here is a simple example using bar to create an archive of your home directory on a quarter-inch magnetic tape mounted on drive /dev/rst8:
example% cd
example% bar cvf /dev/rst8 .
messages
example%
The c key means create the archive, the v function modifier makes bar tell you what it’s doing as it works, and the f modifier means that you are specifically naming the file onto which the archive should be placed (/dev/rst8 in this example).
Here is another example using the 3.5-inch diskette drive, /dev/rfd0c:
example% cd
example% bar cvfH /dev/rfd0c “THIS IS MY HEADER” .
messages
example%
As in the first example, the c key means create the archive, the v function modifier makes bar tell you what it’s doing as it works, and the f modifier means that you are specifically naming the file onto which the archive should be placed (/dev/rfd0c in this example). The H function modifier says to use the string “THIS IS MY HEADER” as the ID field in the volume header.
Now you can read the table of contents from the archive like this:
example% bar tvf /dev/rfd0c
(accessuid/gidsizemod. datefilename)
rw-r--r--1677/402123Nov 7 18:15:1985./archive/test.c
. . .
example%
You can extract files from the archive like this:
example% bar xvf /dev/rfd0c
messages
example%
If there are multiple archive files on a tape, each is separated from the following one by an EOF marker. bar does not read the EOF mark on the tape after it finishes reading an archive file because bar looks for a special header to decide when it has reached the end of the archive. Now if you try to use bar to read the next archive file from the tape, bar does not know enough to skip over the EOF mark and tries to read the EOF mark as an archive instead. The result of this is an error message from bar to the effect:
bar: blocksize=0
This means that to read another archive from the tape, you must skip over the EOF marker before starting another bar command. You can accomplish this using the mt(1) command, as shown in the example below. Assume that you are reading from /dev/nrst8 (no rewind).
example% bar xvfp /dev/nrst8 read first archive from tape
messages
example% mt fsf 1skip over the end-of-file marker
example% bar xvfp /dev/nrst8 read second archive from tape
messages
example%
Finally, here is an example using bar to transfer files across the Ethernet. First, here is how to archive files from the local machine (example) to a tape on a remote system (host):
example% bar cvfb − 20 filenames | rsh host dd of=/dev/rst8 obs=20b
messages
example%
In the example above, we are creating a barfile with the c key letter, asking for verbose output from bar with the v function modifier, specifying the name of the output barfile using the f function modifier (the standard output is where the barfile appears, as indicated by the ‘−’ sign), and specifying the block size (20) with the b function modifier. To change the block size, you must change the block size arguments both on the bar command and on the dd(1) command.
Now, here is how to use bar to get files from a tape on the remote system back to the local system:
example% rsh −n host dd if=/dev/rst8 bs=20b | bar xvBfb − 20 filenames
messages
example%
In the example above, we are extracting from the barfile with the x key letter, asking for verbose output from bar with the v function modifier, telling bar it is reading from a pipe with the B function modifier, specifying the name of the input barfile using the f function modifier (the standard input is where the barfile appears, as indicated by the ‘−’ sign), and specifying the block size (20) with the b function modifier.
FILES
/dev/rfd0?3.5-inch diskette interface
/dev/rfdl0?low density 3.5-inch diskette interface
/dev/rfd2?high density 5.25-inch diskette interface †
/dev/rfdl2?low density 5.25-inch diskette interface †
/dev/rst?quarter-inch SCSI tape interface
/tmp/bar∗temporary files used with the u key letter
/tmp/tmp_∗temporary files used in compression
† Multiple volumes not supported
DIAGNOSTICS
bar’s exit status is normally zero. If one of the following errors occurs, bar will exit with a nonzero exit status:
User responded with ‘n’ to the volume change prompt, exits with -1.
Illegal arguments or bad usage, exits with 1.
Miscellaneous library function failure, exits with 2.
Bad format, exits with 3.
Uncompress failure, exits with 4.
Device error, exits with 5.
Wrong owner, exits with 6.
Compress failure, exits with 7.
NOTES
bar handles multiple volumes gracefully for quarter-inch SCSI magnetic tapes and 3.5-inch diskettes. If a media error is encountered, bar issues a message on the standard error requesting a new volume. The presence of a new volume is confirmed when bar reads a line beginning with Y or y on the standard input. A line beginning with N or n aborts the archive. Any other character causes bar to reissue the prompt.
SEE ALSO
cpio(1), tar(1), umask(2), bar(5), tar(5), dump(8), restore(8)
BUGS
Neither the r key nor the u key can be used with quarter-inch archive tapes, since these tape drives cannot backspace.
There is no way to ask for the nth occurrence of a file, unless n is equal to 1.
The u key can be slow.
There is no way to selectively follow symbolic links.
When extracting tapes created with the r or u keys, directory modification times may not be set correctly.
File name substitution wild cards do not work for extracting files from the archive. To get around this, use a command of the form:
example% bar xvf... /dev/rst0 ‘bar tf... /dev/rst0 | grep’pattern’‘
If you specify ‘−’ as the target file and the archive spans volumes, the request for a new volume may get lost.
Archives created with Sun386i SunOS 4.0 beta bar cannot be read by SunOS 4.0 and later versions of bar unless the H function modifier was specified when the Beta version was created. Under 4.0 Beta, the H modifier causes the bar volume header to be written. The volume header is always written by post-Beta versions of bar, whether or not the H modifier is specified.
Sun Release 4.0 — Last change: 17 July 1989