.\" (c) Copyright 1997-1999 by Matthew Dillon and Dima Ruban. Permission to .\" use and distribute based on the DragonFly copyright. Supplied as-is, .\" USE WITH EXTREME CAUTION. .\" .\" .\" $DragonFly: src/bin/cpdup/cpdup.1,v 1.19 2006/10/03 10:21:40 swildner Exp $ .Dd October 28, 1999 .Dt CPDUP 1 .Os .Sh NAME .Nm cpdup .Nd mirror filesystems .Sh SYNOPSIS .Nm cpdup .Op Fl v[vv..] .Op Fl u .Op Fl I .Op Fl f .Op Fl s0 .Op Fl i0 .Op Fl j0 .Op Fl q .Op Fl o .Op Fl m .Oo .Fl H .Ar path .Oc .Oo .Fl M .Ar file .Oc .Op Fl S .Op Fl k .Oo .Fl K .Ar file .Oc .Oo .Fl X .Ar file .Oc .Op Fl x .Ar [[user@]host:]source_dir .Ar [[user@]host:]target_dir .Sh DESCRIPTION The .Nm utility makes an exact mirror copy of the source in the destination, creating and deleting files and directories as necessary. UTimes, hardlinks, softlinks, devices, permissions, and flags are mirrored. By default, .Nm asks for confirmation if any file or directory needs to be removed from the destination and does not copy files which it believes to have already been synchronized (by observing that the source and destination file's size and mtimes match). .Nm does not cross mount points in either the source or the destination. As a safety measure, .Nm refuses to replace a destination directory with a file. .Pp The following options are available: .Bl -tag -width flag .It Fl v[vv] Set verboseness. By default .Nm does not report its progress except when asking for confirmation. A single .Fl v will only report modifications made to the destination. .Fl vv will report directories as they are being traversed as well as modifications made to the destination. .Fl vvv will cause all files and directories to be reported whether or not modifications are made. .It Fl u Causes the ouptut generated by .Fl v[vv] to be unbuffered. This can be useful for obtaining prompt progress updates through a pipe. .It Fl I will cause cpdup to print a summary at the end with performance counter. .It Fl f Forces file updates to occur even if the files appear to be the same. If the .Fl H option is used, this option will force a byte for byte comparison between the original file and the file in the hardlink path, even if all the stat info matches, but will still use a hardlink if they match. .It Fl s0 Disable the disallow-file-replaces-directory safety feature. This safety feature is enabled by default to prevent user mistakes from blowing away everything accidently. .It Fl i0 Do not request confirmation when removing something. .It Fl j0 Do not try to recreate CHR or BLK devices. .It Fl q Quiet operation .It Fl o Do not remove any files, just overwrite/add. .It Fl m Generate and maintain a MD5 checkfile in each directory on the source and do an MD5 check on each file of the destination when the destination appears to be the same as the source. If the check fails, .Nm the source is recopied to the destination. When you specify a destination directory the MD5 checkfile is only updated as needed and may not be updated even if modifications are made to a source file. If you do not specify a destination directory the .Nm command forcefully regenerates the MD5 checkfile for every file in the source. .It Fl H Ar path cpdup will create a hardlink from a file found under .Ar path to the target instead of copying the source to the target if the file found via .Ar path is identical to the source. Note that a remote host specification should not be used in this option, but the path will be relative to the target machine. .Pp This allows one to use .Nm to create incremental backups of a filesystem. Create a direct 'level 0' backup, and then specify the level 0 backup path with this option when creating an incremental backup to a different target directory. This method works so long as the filesystem does not hit a hardlink limit. If the system does hit a hardlink limit .Nm will generate a warning and copy the file instead. Note that .Nm must record file paths for any hardlinked file while operating and therefore uses a great deal more memory when dealing with hardlinks or hardlink-based backups. Example use: .Pp .Dl cpdup -i0 -s0 -I -H /backup/home.l0 /home /backup/home.l1 .Pp WARNING: If this option is used .Nm must record the paths for all files it encounters while it operates and it is possible that you may run the process out of memory. .It Fl M Ar file Works the same as .Fl m but allows you to specify the name of the MD5 checkfile. .It Fl S This places .Nm into slave mode and is used to initiate the slave protocol on a remote machine. .It Fl k Generate and maintain a FSMID checkfile called .FSMID.CHECK in each directory on the target. .Nm will check the FSMID for each source file or directory against the checkfile on the target and will not copy the file or recurse through the directory when a match occurs. Any source file or directory with the same name as the checkfile will be ignored. The FSMID will be re-checked after the copy has been completed and .Nm will loop on that directory or file until it is sure it has an exact copy. .Pp Warning: FSMID is not always supported by a filesystem and may not be synchronized if a crash occurs. .Dx will simulate an FSMID when it is otherwise not supported by the filesystem, and users should be aware that simulated FSMIDs may change state in such cases even if the underlying hierarchy does not due to cache flushes. Additionally, the FSMID may not reflect changes made to remote filesystems by other hosts. For example, using these options with NFS mounted sources will not work well. .It Fl K Ar file Works the same as .Fl k but allows you to specify the name of the FSMID checkfile. .It Fl x Causes .Nm to use the exclusion file ".cpignore" in each directory on the source to determine which files to ignore. When this option is used, the exclusion filename itself is automatically excluded from the copy. If this option is not used then the filename ".cpignore" is not considered special and will be copied along with everything else. .It Fl X Ar file Works the same as .Fl x but allows you to specify the name of the exclusion file. This file is automatically excluded from the copy. Only one exclusion file may be specified. .El .Sh REMOTE COPYING .Nm can mirror directory structures across machines and can also do third-party copies. .Xr ssh 1 sessions are used and .Nm is run on the remote machine(s) in slave mode. .Sh DIAGNOSTICS The .Nm utility exits 0 if no error occured and >0 if an error occured. .Sh SEE ALSO .Xr cp 1 , .Xr cpio 1 , .Xr tar 1 .Sh HISTORY The .Nm command was original created to update servers at BEST Internet circa 1997 and was placed under the FreeBSD copyright for inclusion in the ports area in 1999. The program was written by Matthew Dillon and Dima Ruban. .Sh BUGS UFS has a hardlink limit of 32767. Many programs, in particular CVS with regards to its CVS/Root file, will generate a lot of hard links. When using the .Fl H option it may not be possible for .Nm to maintain these hard links. If this occurs .Nm will be forced to copy the file instead of link it, and thus not be able to make a perfect copy of the filesystem.