13a42736dSMatthew Dillon.\" (c) Copyright 1997-1999 by Matthew Dillon and Dima Ruban. Permission to 23a42736dSMatthew Dillon.\" use and distribute based on the DragonFly copyright. Supplied as-is, 33a42736dSMatthew Dillon.\" USE WITH EXTREME CAUTION. 43a42736dSMatthew Dillon.\" 53a42736dSMatthew Dillon.\" 6*aa4f0cadSSascha Wildner.\" $DragonFly: src/bin/cpdup/cpdup.1,v 1.21 2007/02/24 13:00:32 swildner Exp $ 73a42736dSMatthew Dillon.Dd October 28, 1999 83a42736dSMatthew Dillon.Dt CPDUP 1 9b28a9db4SSascha Wildner.Os 103a42736dSMatthew Dillon.Sh NAME 113a42736dSMatthew Dillon.Nm cpdup 123a42736dSMatthew Dillon.Nd mirror filesystems 133a42736dSMatthew Dillon.Sh SYNOPSIS 1497983c9eSSascha Wildner.Nm 153a42736dSMatthew Dillon.Op Fl v[vv..] 164d2076d3SChris Pressey.Op Fl u 173a42736dSMatthew Dillon.Op Fl I 183a42736dSMatthew Dillon.Op Fl f 193a42736dSMatthew Dillon.Op Fl s0 203a42736dSMatthew Dillon.Op Fl i0 21ac482a7eSMatthew Dillon.Op Fl j0 223a42736dSMatthew Dillon.Op Fl q 233a42736dSMatthew Dillon.Op Fl o 243a42736dSMatthew Dillon.Op Fl m 253a42736dSMatthew Dillon.Oo 264e316ad5SMatthew Dillon.Fl H 274e316ad5SMatthew Dillon.Ar path 284e316ad5SMatthew Dillon.Oc 294e316ad5SMatthew Dillon.Oo 303a42736dSMatthew Dillon.Fl M 313a42736dSMatthew Dillon.Ar file 323a42736dSMatthew Dillon.Oc 334d858d58SMatthew Dillon.Op Fl S 34577109eaSMatthew Dillon.Op Fl k 35577109eaSMatthew Dillon.Oo 36577109eaSMatthew Dillon.Fl K 37577109eaSMatthew Dillon.Ar file 38577109eaSMatthew Dillon.Oc 393a42736dSMatthew Dillon.Oo 40c0d18d1dSMatthew Dillon.Fl X 413a42736dSMatthew Dillon.Ar file 423a42736dSMatthew Dillon.Oc 43c0d18d1dSMatthew Dillon.Op Fl x 444d858d58SMatthew Dillon.Ar [[user@]host:]source_dir 454d858d58SMatthew Dillon.Ar [[user@]host:]target_dir 463a42736dSMatthew Dillon.Sh DESCRIPTION 473a42736dSMatthew DillonThe 483a42736dSMatthew Dillon.Nm 493a42736dSMatthew Dillonutility makes an exact mirror copy of the source in the destination, creating 503a42736dSMatthew Dillonand deleting files and directories as necessary. UTimes, hardlinks, 513a42736dSMatthew Dillonsoftlinks, devices, permissions, and flags are mirrored. By default, 523a42736dSMatthew Dillon.Nm 533a42736dSMatthew Dillonasks for confirmation if any file or directory needs to be removed from 543a42736dSMatthew Dillonthe destination and does not copy files which it believes to have already 553a42736dSMatthew Dillonbeen synchronized (by observing that the source and destination file's size 563a42736dSMatthew Dillonand mtimes match). 573a42736dSMatthew Dillon.Nm 5873afa964SChris Presseydoes not cross mount points in either the source or the destination. 5973afa964SChris PresseyAs a safety measure, 603a42736dSMatthew Dillon.Nm 613a42736dSMatthew Dillonrefuses to replace a destination directory with a file. 623a42736dSMatthew Dillon.Pp 633a42736dSMatthew DillonThe following options are available: 643a42736dSMatthew Dillon.Bl -tag -width flag 650dc55843SLiam J. Foy.It Fl v[vv] 663a42736dSMatthew DillonSet verboseness. By default 673a42736dSMatthew Dillon.Nm 683a42736dSMatthew Dillondoes not report its progress except when asking for confirmation. A single 693a42736dSMatthew Dillon.Fl v 703a42736dSMatthew Dillonwill only report modifications made to the destination. 713a42736dSMatthew Dillon.Fl vv 723a42736dSMatthew Dillonwill report directories as they are being traversed as well as 733a42736dSMatthew Dillonmodifications made to the destination. 743a42736dSMatthew Dillon.Fl vvv 753a42736dSMatthew Dillonwill cause all files and directories to be reported whether or not 763a42736dSMatthew Dillonmodifications are made. 774d2076d3SChris Pressey.It Fl u 784d2076d3SChris PresseyCauses the ouptut generated by 794d2076d3SChris Pressey.Fl v[vv] 804d2076d3SChris Presseyto be unbuffered. 814d2076d3SChris PresseyThis can be useful for obtaining prompt progress updates through a pipe. 823a42736dSMatthew Dillon.It Fl I 833a42736dSMatthew Dillonwill cause cpdup to print a summary at the end with performance counter. 843a42736dSMatthew Dillon.It Fl f 854e316ad5SMatthew DillonForces file updates to occur even if the files appear to be the same. If 864e316ad5SMatthew Dillonthe 874e316ad5SMatthew Dillon.Fl H 886db8f15dSMatthew Dillonoption is used, this option will force a byte for byte comparison 894e316ad5SMatthew Dillonbetween the original file and the file in the hardlink path, even if 904e316ad5SMatthew Dillonall the stat info matches, but will still use a hardlink if they match. 913a42736dSMatthew Dillon.It Fl s0 923a42736dSMatthew DillonDisable the disallow-file-replaces-directory safety feature. This 933a42736dSMatthew Dillonsafety feature is enabled by default to prevent user mistakes from blowing 943a42736dSMatthew Dillonaway everything accidently. 953a42736dSMatthew Dillon.It Fl i0 963a42736dSMatthew DillonDo not request confirmation when removing something. 97ac482a7eSMatthew Dillon.It Fl j0 98ac482a7eSMatthew DillonDo not try to recreate CHR or BLK devices. 993a42736dSMatthew Dillon.It Fl q 1003a42736dSMatthew DillonQuiet operation 1013a42736dSMatthew Dillon.It Fl o 1023a42736dSMatthew DillonDo not remove any files, just overwrite/add. 1033a42736dSMatthew Dillon.It Fl m 104577109eaSMatthew DillonGenerate and maintain a MD5 checkfile in each directory on the source 1053a42736dSMatthew Dillonand do an MD5 check on each file of the destination when the destination 1063a42736dSMatthew Dillonappears to be the same as the source. If the check fails, 1073a42736dSMatthew Dillon.Nm 1083a42736dSMatthew Dillonthe source is recopied to the destination. When you specify a destination 1093a42736dSMatthew Dillondirectory the MD5 checkfile is only updated as needed and may not be updated 1103a42736dSMatthew Dilloneven if modifications are made to a source file. If you do not specify a 1113a42736dSMatthew Dillondestination directory the 1123a42736dSMatthew Dillon.Nm 1133a42736dSMatthew Dilloncommand forcefully regenerates the MD5 checkfile for every file in the source. 1144e316ad5SMatthew Dillon.It Fl H Ar path 1154e316ad5SMatthew Dilloncpdup will create a hardlink from a file found under 1164e316ad5SMatthew Dillon.Ar path 1174e316ad5SMatthew Dillonto the target instead of copying the source to the target if the file found 1184e316ad5SMatthew Dillonvia 1194e316ad5SMatthew Dillon.Ar path 1204d858d58SMatthew Dillonis identical to the source. 1214d858d58SMatthew DillonNote that a remote host specification should not be used in this option, 1224d858d58SMatthew Dillonbut the path will be relative to the target machine. 1234d858d58SMatthew Dillon.Pp 1244d858d58SMatthew DillonThis allows one to use 1254e316ad5SMatthew Dillon.Nm 1264e316ad5SMatthew Dillonto create incremental backups of a filesystem. Create a direct 'level 0' 1274e316ad5SMatthew Dillonbackup, and then specify the level 0 backup path with this option when 1289b2d9484SMatthew Dilloncreating an incremental backup to a different target directory. 1299b2d9484SMatthew DillonThis method works so long as the filesystem does not hit a hardlink limit. 1309b2d9484SMatthew DillonIf the system does hit a hardlink limit 1319b2d9484SMatthew Dillon.Nm 1329b2d9484SMatthew Dillonwill generate a warning and copy the file instead. 1339b2d9484SMatthew DillonNote that 1344e316ad5SMatthew Dillon.Nm 1354e316ad5SMatthew Dillonmust record file paths for any hardlinked file while operating and therefore 1364e316ad5SMatthew Dillonuses a great deal more memory when dealing with hardlinks or hardlink-based 1374e316ad5SMatthew Dillonbackups. Example use: 1384e316ad5SMatthew Dillon.Pp 1394e316ad5SMatthew Dillon.Dl cpdup -i0 -s0 -I -H /backup/home.l0 /home /backup/home.l1 1404e316ad5SMatthew Dillon.Pp 1414e316ad5SMatthew DillonWARNING: If this option is used 1424e316ad5SMatthew Dillon.Nm 1434e316ad5SMatthew Dillonmust record the paths for all files it encounters while it operates 1444e316ad5SMatthew Dillonand it is possible that you may run the process out of memory. 145577109eaSMatthew Dillon.It Fl M Ar file 1463a42736dSMatthew DillonWorks the same as 1473a42736dSMatthew Dillon.Fl m 1483a42736dSMatthew Dillonbut allows you to specify the name of the MD5 checkfile. 1494d858d58SMatthew Dillon.It Fl S 1504d858d58SMatthew DillonThis places 1514d858d58SMatthew Dillon.Nm 1524d858d58SMatthew Dilloninto slave mode and is used to initiate the slave protocol on a remote 1534d858d58SMatthew Dillonmachine. 154577109eaSMatthew Dillon.It Fl k 155577109eaSMatthew DillonGenerate and maintain a FSMID checkfile called .FSMID.CHECK in each 156577109eaSMatthew Dillondirectory on the target. 157577109eaSMatthew Dillon.Nm 158577109eaSMatthew Dillonwill check the FSMID for each source file or directory against the checkfile 159577109eaSMatthew Dillonon the target and will not copy the file or recurse through the directory 160577109eaSMatthew Dillonwhen a match occurs. Any source file or directory with the same name as the 161577109eaSMatthew Dilloncheckfile will be ignored. The FSMID will be re-checked after the copy 162577109eaSMatthew Dillonhas been completed and 163577109eaSMatthew Dillon.Nm 164577109eaSMatthew Dillonwill loop on that directory or file until it is sure it has an exact copy. 165577109eaSMatthew Dillon.Pp 166577109eaSMatthew DillonWarning: FSMID is not always supported by a filesystem and may not be 1671df089c8SSascha Wildnersynchronized if a crash occurs. 1681df089c8SSascha Wildner.Dx 1691df089c8SSascha Wildnerwill simulate an FSMID when 170577109eaSMatthew Dillonit is otherwise not supported by the filesystem, and users should be aware 171577109eaSMatthew Dillonthat simulated FSMIDs may change state in such cases even if the underlying 172577109eaSMatthew Dillonhierarchy does not due to cache flushes. 173577109eaSMatthew DillonAdditionally, the FSMID may not reflect changes made to remote filesystems 174577109eaSMatthew Dillonby other hosts. For example, using these options with NFS mounted sources 175577109eaSMatthew Dillonwill not work well. 176577109eaSMatthew Dillon.It Fl K Ar file 177577109eaSMatthew DillonWorks the same as 178577109eaSMatthew Dillon.Fl k 179577109eaSMatthew Dillonbut allows you to specify the name of the FSMID checkfile. 1803a42736dSMatthew Dillon.It Fl x 1813a42736dSMatthew DillonCauses 1823a42736dSMatthew Dillon.Nm 1833a42736dSMatthew Dillonto use the exclusion file ".cpignore" in each directory on the source to 1843a42736dSMatthew Dillondetermine which files to ignore. When this option is used, the exclusion 1853a42736dSMatthew Dillonfilename itself is automatically excluded from the copy. If this option is 1863a42736dSMatthew Dillonnot used then the filename ".cpignore" is not considered special and will 1873a42736dSMatthew Dillonbe copied along with everything else. 188577109eaSMatthew Dillon.It Fl X Ar file 1893a42736dSMatthew DillonWorks the same as 1903a42736dSMatthew Dillon.Fl x 1913a42736dSMatthew Dillonbut allows you to specify the name of the exclusion file. This file is 1923a42736dSMatthew Dillonautomatically excluded from the copy. Only one exclusion file may be 1933a42736dSMatthew Dillonspecified. 19452ac7bd7SHiten Pandya.El 1954d858d58SMatthew Dillon.Sh REMOTE COPYING 1964d858d58SMatthew Dillon.Nm 1974d858d58SMatthew Dilloncan mirror directory structures across machines and can also do third-party 1984d858d58SMatthew Dilloncopies. 1994d858d58SMatthew Dillon.Xr ssh 1 2004d858d58SMatthew Dillonsessions are used and 2014d858d58SMatthew Dillon.Nm 2024d858d58SMatthew Dillonis run on the remote machine(s) in slave mode. 2033a42736dSMatthew Dillon.Sh DIAGNOSTICS 2043a42736dSMatthew DillonThe 2053a42736dSMatthew Dillon.Nm 2069b2d9484SMatthew Dillonutility exits 0 if no error occured and >0 if an error occured. 2073a42736dSMatthew Dillon.Sh SEE ALSO 2083a42736dSMatthew Dillon.Xr cp 1 , 2093a42736dSMatthew Dillon.Xr cpio 1 , 2102653401fSChris Pressey.Xr tar 1 211de023c90SSascha Wildner.Sh HISTORY 212de023c90SSascha WildnerThe 213de023c90SSascha Wildner.Nm 214*aa4f0cadSSascha Wildnercommand was originally created to update servers at BEST Internet circa 1997 215de023c90SSascha Wildnerand was placed under the FreeBSD copyright for inclusion in the ports area 216de023c90SSascha Wildnerin 1999. The program was written by Matthew Dillon and Dima Ruban. 2179b2d9484SMatthew Dillon.Sh BUGS 2189b2d9484SMatthew DillonUFS has a hardlink limit of 32767. Many programs, in particular CVS 2199b2d9484SMatthew Dillonwith regards to its CVS/Root file, will generate a lot of hard links. 2209b2d9484SMatthew DillonWhen using the 2219b2d9484SMatthew Dillon.Fl H 2229b2d9484SMatthew Dillonoption it may not be possible for 2239b2d9484SMatthew Dillon.Nm 2249b2d9484SMatthew Dillonto maintain these hard links. If this occurs 2259b2d9484SMatthew Dillon.Nm 2269b2d9484SMatthew Dillonwill be forced to copy the file instead of link it, and thus not be able 2279b2d9484SMatthew Dillonto make a perfect copy of the filesystem. 228