xref: /dragonfly/bin/cpdup/cpdup.1 (revision f746689a)
1.\" (c) Copyright 1997-1999 by Matthew Dillon and Dima Ruban.  Permission to
2.\"    use and distribute based on the DragonFly copyright.  Supplied as-is,
3.\"    USE WITH EXTREME CAUTION.
4.\"
5.\"
6.\" $DragonFly: src/bin/cpdup/cpdup.1,v 1.31 2008/05/30 18:00:23 swildner Exp $
7.Dd April 11, 2008
8.Dt CPDUP 1
9.Os
10.Sh NAME
11.Nm cpdup
12.Nd mirror filesystems
13.Sh SYNOPSIS
14.Nm
15.Op Fl C
16.Op Fl v[vv..]
17.Op Fl u
18.Op Fl I
19.Op Fl f
20.Op Fl s0
21.Op Fl i0
22.Op Fl j0
23.Op Fl l
24.Op Fl p Ar number
25.Op Fl q
26.Op Fl o
27.Op Fl m
28.Oo
29.Fl H
30.Ar path
31.Oc
32.Oo
33.Fl M
34.Ar file
35.Oc
36.Op Fl V
37.Op Fl S
38.Op Fl k
39.Oo
40.Fl K
41.Ar file
42.Oc
43.Oo
44.Fl X
45.Ar file
46.Oc
47.Op Fl x
48.Ar [[user@]host:]source_dir
49.Ar [[user@]host:]target_dir
50.Sh DESCRIPTION
51The
52.Nm
53utility makes an exact mirror copy of the source in the destination, creating
54and deleting files and directories as necessary.  UTimes, hardlinks,
55softlinks, devices, permissions, and flags are mirrored.  By default,
56.Nm
57asks for confirmation if any file or directory needs to be removed from
58the destination and does not copy files which it believes to have already
59been synchronized (by observing that the source and destination file's size
60and mtimes match).
61.Nm
62does not cross mount points in either the source or the destination.
63As a safety measure,
64.Nm
65refuses to replace a destination directory with a file.
66.Pp
67The following options are available:
68.Bl -tag -width flag
69.It Fl C
70If the source or target is a remote host request that the
71.Xr ssh 1
72session be compressed.
73.It Fl v[vv]
74Set verboseness.  By default
75.Nm
76does not report its progress except when asking for confirmation.  A single
77.Fl v
78will only report modifications made to the destination.
79.Fl vv
80will report directories as they are being traversed as well as
81modifications made to the destination.
82.Fl vvv
83will cause all files and directories to be reported whether or not
84modifications are made.
85.It Fl u
86Causes the ouptut generated by
87.Fl v[vv]
88to be unbuffered.
89This can be useful for obtaining prompt progress updates through a pipe.
90.It Fl I
91will cause
92.Nm
93to print a summary at the end with performance counter.
94.It Fl f
95Forces file updates to occur even if the files appear to be the same.  If
96the
97.Fl H
98option is used, this option will force a byte for byte comparison
99between the original file and the file in the hardlink path, even if
100all the stat info matches, but will still use a hardlink if they match.
101.It Fl s0
102Disable the disallow-file-replaces-directory safety feature.  This
103safety feature is enabled by default to prevent user mistakes from blowing
104away everything accidentally.
105.It Fl i0
106Do not request confirmation when removing something.
107.It Fl j0
108Do not try to recreate CHR or BLK devices.
109.It Fl l
110Line buffer verbose output.
111.It Fl p Ar number
112Use threaded transactions with up to the specified
113.Ar number
114of threads.
115This typically improves operation when a remote host specification is
116given.
117.It Fl q
118Quiet operation
119.It Fl o
120Do not remove any files, just overwrite/add.
121.It Fl m
122Generate and maintain a MD5 checkfile in each directory on the source
123and do an MD5 check on each file of the destination when the destination
124appears to be the same as the source.  If the check fails,
125.Nm
126the source is recopied to the destination.  When you specify a destination
127directory the MD5 checkfile is only updated as needed and may not be updated
128even if modifications are made to a source file.  If you do not specify a
129destination directory the
130.Nm
131command forcefully regenerates the MD5 checkfile for every file in the source.
132.It Fl H Ar path
133.Nm
134will create a hardlink from a file found under
135.Ar path
136to the target instead of copying the source to the target if the file found
137via
138.Ar path
139is identical to the source.
140Note that a remote host specification should not be used for this option's
141path, but the path will be relative to the target machine.
142.Pp
143This allows one to use
144.Nm
145to create incremental backups of a filesystem.  Create a direct 'level 0'
146backup, and then specify the level 0 backup path with this option when
147creating an incremental backup to a different target directory.
148This method works so long as the filesystem does not hit a hardlink limit.
149If the system does hit a hardlink limit
150.Nm
151will generate a warning and copy the file instead.
152Note that
153.Nm
154must record file paths for any hardlinked file while operating and therefore
155uses a great deal more memory when dealing with hardlinks or hardlink-based
156backups.  Example use:
157.Pp
158.Dl cpdup -i0 -s0 -I -H /backup/home.l0 /home /backup/home.l1
159.Pp
160WARNING: If this option is used
161.Nm
162must record the paths for all files it encounters while it operates
163and it is possible that you may run the process out of memory.
164.Pp
165The file found via the hardlink path will be byte-by-byte compared with the
166source if the
167.Fl V
168or
169.Fl f
170option is also used, otherwise only the stat info is checked to determine
171whether it matches the source.
172.It Fl M Ar file
173Works the same as
174.Fl m
175but allows you to specify the name of the MD5 checkfile.
176.It Fl V
177This forces the contents of regular files to be verified, even if the
178files appear to the be the same.  Whereas the
179.Fl f
180(force) option forces a copy regardless, this option will avoid rewriting
181the target if everything matches and the contents are verified to be the
182same.
183.It Fl S
184This places
185.Nm
186into slave mode and is used to initiate the slave protocol on a remote
187machine.
188.It Fl k
189Generate and maintain a FSMID checkfile called .FSMID.CHECK in each
190directory on the target.
191.Nm
192will check the FSMID for each source file or directory against the checkfile
193on the target and will not copy the file or recurse through the directory
194when a match occurs.  Any source file or directory with the same name as the
195checkfile will be ignored.  The FSMID will be re-checked after the copy
196has been completed and
197.Nm
198will loop on that directory or file until it is sure it has an exact copy.
199.Pp
200Warning: FSMID is not always supported by a filesystem and may not be
201synchronized if a crash occurs.
202.Dx
203will simulate an FSMID when
204it is otherwise not supported by the filesystem, and users should be aware
205that simulated FSMIDs may change state in such cases even if the underlying
206hierarchy does not due to cache flushes.
207Additionally, the FSMID may not reflect changes made to remote filesystems
208by other hosts.  For example, using these options with NFS mounted sources
209will not work well.
210.It Fl K Ar file
211Works the same as
212.Fl k
213but allows you to specify the name of the FSMID checkfile.
214.It Fl x
215Causes
216.Nm
217to use the exclusion file ".cpignore" in each directory on the source to
218determine which files to ignore.  When this option is used, the exclusion
219filename itself is automatically excluded from the copy.  If this option is
220not used then the filename ".cpignore" is not considered special and will
221be copied along with everything else.
222.It Fl X Ar file
223Works the same as
224.Fl x
225but allows you to specify the name of the exclusion file.  This file is
226automatically excluded from the copy.  Only one exclusion file may be
227specified.
228.El
229.Sh REMOTE COPYING
230.Nm
231can mirror directory structures across machines and can also do third-party
232copies.
233.Xr ssh 1
234sessions are used and
235.Nm
236is run on the remote machine(s) in slave mode.
237.Sh DIAGNOSTICS
238The
239.Nm
240utility exits 0 if no error occurred and >0 if an error occurred.
241.Sh SEE ALSO
242.Xr cp 1 ,
243.Xr cpio 1 ,
244.Xr tar 1
245.Sh HISTORY
246The
247.Nm
248command was originally created to update servers at BEST Internet circa 1997
249and was placed under the
250.Fx
251copyright for inclusion in the ports area in 1999.
252The program was written by Matthew Dillon and Dima Ruban.
253.Sh BUGS
254.Xr UFS 5
255has a hardlink limit of 32767.  Many programs, in particular CVS
256with regards to its CVS/Root file, will generate a lot of hard links.
257When using the
258.Fl H
259option it may not be possible for
260.Nm
261to maintain these hard links.  If this occurs
262.Nm
263will be forced to copy the file instead of link it, and thus not be able
264to make a perfect copy of the filesystem.
265