-
Notifications
You must be signed in to change notification settings - Fork 107
/
dcp.man
257 lines (256 loc) · 7.67 KB
/
dcp.man
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
.TH DCP 1
.SH NAME
dcp \- copy and profile files and directories
.SH SYNOPSIS
.B dcp
[\fIOPTION\fP]... [\fB\-h\fP \fIPATH\fP]
\fB[\-o\fP \fIPATH\fP] \fISOURCE\fP \fIDEST\fP
.SH DESCRIPTION
dcp combines cp, stat, md5sum and shasum to streamline mirroring and gathering
information about all the files copied. All information gathered is written to
an output file. The output file can be fed back into dcp when copying
snapshots of a directory, this allows only files which differ in location or
hash to be copied.
.SH OPTIONS
.TP
.BR \-a ", "\-\-all
same as \fB\-stu\fP
.TP
.BR \-h ", "\-\-help
Print help and exit
.TP
.BR \-m ", "\-\-md5
calculate the md5 hash for all regular files.
.TP
.BR \-s ", "\-\-sha1
calculate the sha1 hash for all regular files
.TP
.BR \-t ", "\-\-sha256
calculate the sha256 hash for all regular files
.TP
.BR \-u ", "\-\-sha512
calculate the sha512 hash for all regular files
.TP
.BR \-o ", "\-\-output=\fIPATH\fP
file to write profile information to, will append if PATH exists
.TP
.BR \-i ", "\-\-input=\fIPATH\fP
results from a previous run
.TP
.BR \-O ", "\-\-owner=\fIUSER\fP
username to chown new files to
.TP
.BR \-G ", "\-\-group=\fIGROUP\fP
group name to chown new files to
.TP
.BR \-v ", "\-\-verbose
explain what is being done
.TP
.BR \-c ", "\-\-cache\-size=\fISIZE\fP
amount of memory to set aside for caching files
.TP
.BR \-D ", "\-\-debug
when logging output debugging information (source and line #)
.SH ENVIRONMENT
.P
dcp responds to the following Environment variables. When parsing
precedence is as follows cmd line args > envi vars > default vals.
.TP
.BR DCP_OWNER
if set the username that all new files and directories will belong, overridden
by \fB\-O\fP/\fB\-\-owner\fP
.TP
.BR DCP_GROUP
if set the group name that all new files and directories will belong,
overridden by \fB\-G\fP/\fB\-\-group\fP
.TP
.BR DCP_CACHE_SIZE
How much memory should be set aside for caching files in memory, ignored if
\fB\-c\fP/\fB\-\-cache\-size\fP is set
.SH INPUT
dcp can limit what files are copied by using the output of a previous run. The
idea is a previous run of sfcp copied the current partition and the current run
is to copy just the differences from a snapshot of the system. Multiple input
files can be specified with the \-i/\-\-input option by supplying a comma
separated list or providing multiple \-i args.
.SH OUTPUT FORMAT
dcp's output is simply a newline separated file of json objects. There are two
types of lines in the file, Metadata and file Entry. Metadata lines provide
context to how and when dcp was run, while Entries provide information on
every single file that was seen while copying.
.PP
Metadata lines are of the format "#KEY\\tVALUE\\n". KEY and VALUE are
strings with '\\t' and '\\n' escaped with "\\\\t" and "\\\\n".
.PP
File Entry lines are a json object, described below in \fBOUTPUT JSON
SCHEMA\fP. Each file found during the copy has an entry in the output, even if
dcp cannot process it. The following states can occur
.TP
.BR FILE_FAILED
Processing failed, see dcp's error output for more information.
.TP
.BR FILE_COPIED
dcp successfully copied the file to the specified destination.
.TP
.BR DIR_CREATED
Successfully created the directory.
.TP
.BR DIR_FAILED
An error occured attempting to create the directory.
.TP
.BR SYMLINK_CREATED
Successfully copied the symlink.
.TP
.BR SPECIAL_CREATED
Successfully copied a block, character, socket or fifo file.
.SH CACHE SIZE
dcp sets aside memory to store the bytes from files that it is reading. The
larger the buffer the fewer number of files that must be read more than once. To
combat this dcp allows a user to set a "cache size". By default 32KiB is used.
The \-\-cache\-size argument responds the following suffixes ['','b','k','m',
'g'], case\-insensitive. Ex setting cache to 512Mib becomes "\-c 512m".
.SH EXAMPLES
Use dcp to mirror the contents of 'dir1' to '/dest' while generating the
md5 & sha1's for each file.
.PP
.nf
.RS
sfcp \-ms \-o /dest/dir1.dcp /media/dir1 /dest/dir1 2> /backup/dir1.log
.RE
.fi
.PP
Using the results above run dcp on a snapshot 'sndir1' only copying
files that are different or didn't exist in main.
.PP
.nf
.RS
sfcp \-i /dest/dir1.dcp \\
/media/sndir1 /dest/snapshot1 2> /backup/snapshotdir1.log
.RE
.fi
.PP
Multiple results can be specified as follows
.PP
.nf
.RS
sfcp \-i dir1.dcp \-i dir2.dcp \\
/media/dir3 /dest/dir3 2> /backup/part3.log
.RE
.fi
.PP
The first example above will copy all the files in 'dir1' to the
destination directory. It will store the hashes and file attributes in
'dir1.dcp'. In the second run all new/modified files that were in the
snapshot will be copied and their attributes and hashes will be written to
dcp.out. Note that the second run didn't specify what digests to calculate, if
input is provided only the hashes in the input file will be calculated.
.SH SEE ALSO
cp(1), rsync(1), stat(2)
.SH OUTPUT JSON SCHEMA
The output format of a File Entry is described below
.PP
.nf
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "DCP's File Entry Schema",
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "file path from partition root"
},
"pathhex": {
"type": "string",
"description": "hex of the path, used instead of 'path' if it contains invalid UTF-8 bytes"
},
"pathmd5": {
"type": "string",
"description": "hex md5 of path"
},
"md5": {
"type": "string",
"description": "hex md5 of regular file"
},
"sha1": {
"type": "string",
"description": "hex sha1 of regular file"
},
"sha256": {
"type": "string",
"description": "hex sha256 of regular file"
},
"sha512": {
"type": "string",
"description": "hex sha512 of regular file"
},
"uid": {
"type": "number",
"description": "file's user id"
},
"gid": {
"type": "number",
"description": "file's group id"
},
"mode": {
"type": "number",
"description": "file's st_mode see stat(2)"
},
"size": {
"type": "number",
"description": "file's st_size see stat(2)"
},
"asec": {
"type": "number",
"description": "access time, st_atim.tv_sec, see stat(2)",
"minimum": 0
},
"ansec": {
"type": "number",
"description": "access time, st_atim.tv_nsec, see stat(2)",
"minimum": 0
},
"msec": {
"type": "number",
"description": "modification time, st_mtim.tv_sec, see stat(2)",
"minimum": 0
},
"mnsec": {
"type": "number",
"description": "modification time, st_mtim.tv_nsec, see stat(2)",
"minimum": 0
},
"csec": {
"type": "number",
"description": "status change time, st_ctim.tv_sec, see stat(2)",
"minimum": 0
},
"cnsec": {
"type": "number",
"description": "status change time, st_ctim.tv_nsec, see stat(2)",
"minimum": 0
},
"type": {
"enum": [
"reg", "dir", "lnk", "chr", "blk", "fifo", "sock", "unkn"
],
"description": "file type extracted from st_mode, see stat(2)"
},
"state": {
"enum": [
"FILE_COPIED", "FILE_FAILED", "DIR_CREATED", "SYMLINK_CREATED",
"SPECIAL_CREATED", "DIR_FAILED"
],
"description": "what is the state after the file was processed"
},
"elapsed": {
"type": "number",
"description": "number of milliseconds it took to process the file"
}
},
"requred": [
"pathmd5", "uid", "gid", "size", "asec", "ansec", "msec",
"mnsec", "csec", "cnsec"," type", "state"
],
"additionalProperties": false
}
.fi