xref: /freebsd/usr.bin/tcopy/tcopy.1 (revision acd546f01e58354af049455472980c6c4a52e18b)
1.\" Copyright (c) 1985, 1990, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd December 20, 2006
29.Dt TCOPY 1
30.Os
31.Sh NAME
32.Nm tcopy
33.Nd read, write, copy and verify tapes
34.Sh SYNOPSIS
35.Nm
36.Op Fl crvx
37.Op Fl l Ar logfile
38.Op Fl s Ar maxblk
39.Oo Ar src Op Ar dest
40.Oc
41.Sh DESCRIPTION
42The
43.Nm
44utility is designed to read, write and copy tapes.
45.Pp
46The only assumption made
47about the tape layout is that there are two sequential EOF marks
48at the end.
49.Pp
50The
51.Ar src
52argument can be a tape device and defaults to
53.Pa /dev/sa0
54or it can be data in SIMH-TAP format.
55If
56.Ar src
57is
58.Dq Cm -
59the standard input is read.
60.Pp
61If the
62.Ar dest
63argument is also specified, a copy of the
64.Ar src
65will be made onto the
66.Ar dest .
67If
68.Ar dest
69is
70.Dq Cm -
71standard output will be written to.
72.Pp
73If
74.Ar dest
75is a tape device, the file and record structure will be the same.
76.Pp
77If
78.Ar dest
79is a filename ending in
80.Dq Cm .000
81the contents each file on
82.Ar src
83will be written to sequentially numbered files
84.Dq Cm .000 ,
85.Dq Cm .001 ,
86.Dq Cm .002
87etc.
88Information about record sizes will be lost.
89.Pp
90If the
91.Fl r
92flag is specified, only the data will be written, information about
93file and record layout is lost.
94.Pp
95Otherwise the data, file and record structure of
96.Ar src
97will be written in SIMH-TAP format.
98.Pp
99The
100.Nm
101utility will report information about the layout of
102.Ar src
103like this on standard output:
104.Bd -literal -offset indent
105file 0: block size 80: 6 records
106file 0: eof after 6 records: 480 bytes
107file 1: block size 3072: records 0 to 262
108file 1: block size 612: record 262
109file 1: eof after 263 records: 805476 bytes
110[…]
111eot
112total length: 972851280 bytes time: 41 s rate: 22934.8 kB/s
113.Ed
114.Pp
115If
116.Ar dest
117is
118.Dq Cm -
119or if
120.Fl x
121is specified this goes to standard error instead,
122and can also be redirected with
123.Fl l Ar logfile ,
124in which case the final total line will also be reported on standard error.
125.Pp
126If
127.Nm
128receives a
129.Dv SIGINFO
130signal, current counts are reported on standard error.
131.Pp
132The following options are available:
133.Bl -tag -width ".Fl s Ar maxblk"
134.It Fl c
135Rewind both tapes, copy
136.Ar src
137to
138.Ar dest ,
139rewind again and verify that the two tapes are now identical.
140.It Fl l Ar logfile
141Output all informational messages to
142.Ar logfile .
143.It Fl r
144Write only the contents of all data blocks to the output.
145The file and record structure of the input will be lost.
146.It Fl s Ar maxblk
147Specify a maximum block size,
148.Ar maxblk .
149The default is
150.Va kern.maxphys .
151.It Fl v
152Verify that
153.Ar src
154and
155.Ar dest
156are identical.
157Note that the tapes are not rewound prior to the comparison.
158.It Fl x
159Output all informational messages to the standard error
160instead of the standard output.
161This option is automatic if
162.Ar dest
163is given as
164.Dq Cm - .
165.El
166.Sh EXIT STATUS
167Unfortunately all over the place, but zero always means succeess.
168.Sh EXAMPLES
169Verify that the tape in /dev/sa0 can be read and see the layout
170of its content:
171.Bd -literal -offset indent
172tcopy
173.Ed
174.Pp
175Copy a tape using two tape drives:
176.Bd -literal -offset indent
177tcopy  /dev/sa0 /dev/sa1
178.Ed
179.Pp
180Copy a tape using only a single tape drive, and verify the result:
181.Bd -literal -offset indent
182tcopy /dev/sa0 /tmp/temp.tapfile
183# change tape
184tcopy -c /tmp/temp.tapfile /dev/sa0
185.Ed
186.Pp
187Make a cryptographic hash of both the contents and the layout of the tape in
188/dev/sa1:
189.Pp
190.Bd -literal -offset indent
191tcopy /dev/sa1 - | sha256
192.Ed
193.Pp
194Copy a tape to a tape drive on another machine:
195.Bd -literal -offset indent
196tcopy /dev/sa0 - | ssh otherhost tcopy - /dev/sa0
197.Ed
198.Pp
199Extract the tape files into individual files:
200.Bd -literal -offset indent
201tcopy /dev/sa0 /tmp/_.tape.000
202.Ed
203.Pp
204Ignore all structure on the tape and feed all data to
205.Xr tar 1 :
206.Bd -literal -offset indent
207tcopy -l /dev/null -r /dev/sa0 - | tar tvf -
208.Ed
209.Sh SEE ALSO
210.Xr mt 1 ,
211.Xr sa 4 ,
212.Xr mtio 4
213.Sh STANDARDS
214The SIMH-TAP format is documented in the open-simh github repos:
215.Pa https://github.com/open-simh/simh/blob/master/doc/simh_magtape.doc
216.Sh HISTORY
217The
218.Nm
219command appeared in
220.Bx 4.3 .
221.Sh BUGS
222.Bl -item
223.It
224Modern tape drives may return a SCSI "Incorrect Length Indicator (ILI)"
225for each read with a different block size that what is on the
226tape, and that slows
227.Nm
228down a lot.
229This can be disabled with the
230.Xr mt 1
231command:
232.Bd -literal -offset indent
233mt param sili -s 1
234.Ed
235.It
236End of data (EOD) is determined by two sequential EOF marks
237with no data between them.
238There used to be old systems which typically wrote three EOF's between tape
239files.
240The
241.Nm
242utility will erroneously stop copying early in this case.
243.It
244With
245.Fl c
246the tape drives are not rewound at the same time, but one after the other.
247.El
248