Imported Upstream version 2.5.1
[debian/amanda] / docs / dumperapi.txt
1
2         Chapter 23. Amanda dumper API
3 Prev  Part V. Technical Background  Next
4
5 -------------------------------------------------------------------------------
6
7 Chapter 23. Amanda dumper API
8
9
10 Alexandre Oliva
11
12 Original text
13 AMANDA Core Team
14 <oliva@dcc.unicamp.br>>
15
16 Stefan G. Weichinger
17
18 XML-conversion;Updates
19 AMANDA Core Team
20 <sgw@amanda.org>
21 Table of Contents
22
23
24   Introduction
25
26   The_Problem
27
28   Overview_of_the_API
29
30
31         The_`support'_command
32
33
34   The_`selfcheck'_command
35
36   The_`estimate'_and_`estimate-parse'_commands
37
38   The_`backup'_and_`backup-parse'_commands
39
40   The_`index-from-output'_and_`index-from-image'_commands
41
42   The_`restore'_command
43
44   The_`print-command'_command
45
46   Conclusion
47
48
49 Note
50
51 Refer to http://www.amanda.org/docs/dumperapi.html for the current version of
52 this document.
53
54  Introduction
55
56 This is a proposal of a mechanism for Amanda to support arbitrary backup
57 programs, that relies on a generic backup driver and scripts or programs that
58 interface with backup programs such as dump, tar, smbclient, and others. It can
59 also be used to introduce pre- and post-backup commands.
60 The interface is simple, but supports everything that is currently supported by
61 Amanda, and it can be consistently extended to support new abstractions that
62 may be introduced in the backup driver in the future.
63 This proposal does not imply any modification in the Amanda protocol or in
64 Amanda servers; only Amanda clients have to be modified. By Amanda clients, we
65 refer to hosts whose disks are to be backed up; an Amanda server is a host
66 connected to a tape unit.
67 Currently (as of release 2.4.1 of Amanda), Amanda clients support three
68 operations: selfcheck, estimate and backup.
69 Selfcheck is used by the server program amcheck, to check whether a client is
70 responding or if there are configuration or permission problems in the client
71 that might prevent the backup from taking place.
72 Estimates are requested by the Amanda planner, that runs on the server and
73 collects information about the expected sizes of backups of each disk at
74 several levels. Given this information and the amount of available tape space,
75 the planner can select which disks and which levels it should tell dumper to
76 run.
77 dumper is yet another server-side program; it requests clients to perform
78 dumps, as determined by planner, and stores these dumps in holding disks or
79 sends them directly to the taper program. The interaction between dumper and
80 taper is beyond the scope of this text.
81 We are going to focus on the interaction between the Amanda client program and
82 wrappers of dump programs. These wrappers must implement the DUMPER API. The
83 dumptype option `program' should name the wrapper that will be used to back up
84 filesystems of that dumptype. One wrapper may call another, so as to extend its
85 functionality.
86
87  The Problem
88
89 Different backup programs present distinct requirements; some must be run as
90 super-user, whereas others can be run under other user-ids. Some require a
91 directory name, the root of the tree to be backed up; others prefer a raw
92 device name; some don't even refer to local disks (SAMBA). Some wrappers may
93 need to know a filesystem type in order to decide which particular backup
94 program to use (dump, vdump, vxdump, xfsdump, backup).
95 Some provide special options for estimates, whereas others must be started as
96 if a complete dump were to be performed, and must be killed as soon as they
97 print an estimate.
98 Furthermore, the output formats of these backup programs vary wildly. Some will
99 print estimates and total sizes in bytes, in 512-byte tape blocks units, in
100 Kbytes, Mbytes, Gbytes, and possibly Tbytes in the near future. Some will print
101 a timestamp for the backup; some won't.
102 There are also restrictions related with possible scheduling policies. For
103 example, some backup programs only support full backups or incrementals based
104 on the last full backup (0-1). Some support full backups or incrementals based
105 on the last backup, be it a full or an incremental backup (0-inf++). Some
106 support incrementals based on a timestamp (incr/date); whereas others are based
107 on a limited number of incremental levels, but incrementals of the same level
108 can be repeated, such as dump (0-9).
109 Amanda was originally built upon DUMP incremental levels, so this is the only
110 model it currently supports. Backup programs that use other incremental
111 management mechanisms had to be adapted to this policy. Wrapper scripts are
112 responsible for this adaptation.
113 Another important issue has to do with index generation. Some backup programs
114 can generate indexes, but each one lists files in its own particular format,
115 but they must be stored in a common format, so that the Amanda server can
116 manipulate them.
117 The DUMPER API must accomodate for all these variations.
118
119  Overview of the API
120
121 We are going to define a standard format of argument lists that the backup
122 driver will provide to wrapper programs, and the expected result of the
123 execution of these wrappers.
124 The first argument to a wrapper should always be a command name. If no
125 arguments are given, or an unsupported command is requested, an error message
126 should be printed to stderr, and the program should terminate with exit status
127 1.
128
129  The `support' command
130
131 As a general mechanism for Amanda to probe for features provided by a backup
132 program, a wrapper script must support at least the `support' command. Some
133 features must be supported, and Amanda won't ever ask about them. Others will
134 be considered as extensions, and Amanda will ask the wrapper whether they are
135 supported before issuing the corresponding commands.
136
137  The `level-incrementals' subcommand
138
139 For example, before requesting for an incremental backup of a given level,
140 Amanda should ask the wrapper whether the backup program supports level-based
141 incrementals. We don't currently support backup programs that don't, but we may
142 in the future, so it would be nice if wrappers already implemented the command
143 `support level-incrementals', by returning a 0 exit status, printing, say, the
144 maximum incremental level it supports, i.e., 9. A sample session would be:
145
146   % /usr/local/amanda/libexec/wrappers/dump support level-incrementals hda0 9
147         
148
149 Note that the result of this support command may depend on filesystem
150 information, so the disklist filesystem entry should be specified as a command
151 line argument. In the next examples, we are not going to use full pathnames to
152 wrapper scripts any more.
153 We could have defined a `support' command for full backups, but I can't think
154 of a backup program that does not support full backups...
155
156  The `index' subcommand
157
158 The ability to produce index files is also subject to an invocation of
159 `support' command. When the support sub-command is `index', like in the
160 invocation below, the wrapper must print a list of valid indexing mechanisms,
161 one per line, most preferred first. If indexing is not supported, nothing
162 should be printed, and the exit status should be 1.
163 DUMP support index hda0
164 The currently known indexing mechanisms are:
165 output: implies that the command `index-from-output' generates an index file
166 from the output produced by the backup program (for example, from tar -cv).
167 image: implies that the command `index-from-image' generates an index file from
168 a backup image (for example, tar -t).
169 direct: implies that the `backup' command can produce an index file as it
170 generates the backup image.
171 parse: implies that the `backup-parse' command can produce an index file as it
172 generates the backup formatted output .
173 The indexing mechanisms will be explicitly requested with the additionnal
174 option `index-<mode>' in the `backup' and `backup-parse' command invocation.
175 `index-from-image' should be supported, if possible, even if other index
176 commands are not, since it can be used in the future to create index files from
177 previously backed up filesystems.
178
179  The `parse-estimate' subcommand
180
181 The `parse-estimate' support subcommand print a list of valid mechanisms to
182 parse the estimate output and write the estimate size to its output, the two
183 mechanisms are:
184 direct: implies that the `estimate' command can produce the estimate output.
185 parse: implies that the `estimate-parse' command can produce the estimate
186 output when fed with the `estimate' output.
187 The estimate parsing mechanisms will be explicitly requested with the
188 additionnal option `estimate-<mode>' in the `estimate' and `estimate-parse'
189 command invocation.
190
191  The `parse-backup' subcommand
192
193 The `parse-backup' support subcommand print a list of valid mechanisms to parse
194 the backup stderr, the two mechanisms are:
195 direct: implies that the `backup' command can produce the backup-formatted-
196 ouput.
197 parse: implies that the `backup-parse' command can produce the backup-
198 formatted-ouput when fed with the `backup' stderr.
199 The backup parsing mechanisms will be explicitly requested with the additional
200 option `backup-<mode>' in the `backup' and `backup-parse' command invocation.
201
202  Other subcommands
203
204 Some other standard `support' sub-commands are `exclude' and `exclude-list'.
205 One may think (and several people did :-) ) that there should be only one
206 support command, that would print information about all supported commands. The
207 main arguments against this proposal have to do with extensibility:
208 The availability of commands might vary from filesystem to filesystem. No, I
209 don't have an example, I just want to keep it as open as possible :-) one
210 support subcommand may require command line arguments that others don't, and we
211 can't know in advance what these command line arguments are going to be
212 The output format and exit status conventions of a support command may vary
213 from command to command; the only pre-defined convention is that, if a wrapper
214 does not know about a support subcommand, it should return exit status 1,
215 implying that the inquired feature is not supported.
216
217  The `selfcheck' command
218
219 We should support commands to perform self-checks, run estimates, backups and
220 restores (for future extensions of the Amanda protocol so as to support
221 restores)
222 A selfcheck request would go like this:
223 DUMP selfcheck hda0 option option=value ...
224 The options specified as command-line arguments are dumptype options enabled
225 for that disk, such as `index', `norecord', etc. Unknown options should be
226 ignored. For each successful check, a message such as:
227 OK [/dev/hda0 is readable] OK [/usr/sbin/dump is executable]
228 Errors should be printed as:
229 ERROR [/etc/dumpdates is not writable]
230 A wrapper script will certainly have to figure out either the disk device name
231 or its mount point, given a filesystem name such as `hda0', as specified in the
232 disklist. In order to help these scripts, Amanda provides a helper program that
233 can guess device names, mount points and filesystem types, when given disklist
234 entries.
235 The filesystem type can be useful on some operation systems, in which more than
236 one dump program is available; this information can help automatically
237 selecting the appropriate dump program.
238 The exit status of selfcheck and of this alternate script are probably going to
239 be disregarded. Anyway, for consistency, selfcheck should return exit status 0
240 for complete success, 1 if any failures have occurred.
241
242  The `estimate' and `estimate-parse' commands
243
244 Estimate requests can be on several different forms. An estimate of a full
245 backup may be requested, or estimates for level- or timestamp-based
246 incrementals:
247 DUMP estimate full hda0 option ... DUMP estimate level 1 hda0 option ... DUMP
248 estimate diff 1998:09:24:01:02:03 hda0 option ...
249 If requested estimate type is not supported, exit status 3 should be returned.
250 If the option `estimate-direct' is set, then the `estimate' command should
251 write to stdout the estimated size, in bytes, a pair of numbers that,
252 multiplied by one another, yield the estimated size in bytes.
253 If the option `estimate-parse' is set, then the `estimate' command should write
254 to stdout the informations needed by the `estimate-parse' command, that should
255 extract from its input the estimated size.
256 The syntax of `estimate-parse' is identical to that of `estimate'.
257 Both `estimate' and `estimate-parse' can output the word `KILL', after printing
258 the estimate. In this case, Amanda will send a SIGTERM signal to the process
259 group of the `estimate' process. If it does not die within a few seconds, a
260 SIGKILL will be issued.
261 If `estimate' or `estimate-parse' succeed, they should exit 0, otherwise exit
262 1, except for the already listed cases of exit status 3.
263
264  The `backup' and `backup-parse' commands
265
266 The syntax of `backup' is the same as that of `estimate'. The backup image
267 should be written to standard output, whereas stderr should be used for the
268 user-oriented output of the backup program and other messages.
269 If the option `backup-direct' is set, then the `backup' command should write to
270 stderr a formatted-output-backup.
271 If the option `backup-parse' is set, then the `backup' command should write to
272 stderr the informations needed by the `backup-parse' command, that should edit
273 its input so that it prints to standard output a formatted-output-backup.
274 If the option `no-record' is set, then the `backup' command should not modify
275 its state file (ex. dump should not modify /etc/dumpdates).
276 The syntax of `backup-parse' is identical to that of `backup'.
277 The syntax of the formatted-output-backup is as follow: All lines should start
278 with either `| ' for normal output, `? ' for strange output or `& ' for error
279 output. If the wrapper can determine the total backup size from the output of
280 the backup program, it should print a line starting with `# ', followed by the
281 total backup size in bytes or by a pair of numbers that, multiplied, yield the
282 total backup size; this number will be used for consistency check.
283 The option `index-direct' should cause commands `backup' to output the index
284 directly to file descriptor 3. The option `index-parse' should cause commands
285 `backup-parse' to output the index directly to file descriptor 3. The syntax of
286 the index file is described in the next section.
287
288  The `index-from-output' and `index-from-image' commands
289
290 The syntax of the `index-from-output' and `index-from-image' commands is
291 identical to the one of `backup'. They are fed the backup output or image, and
292 they must produce a list of files and directories, one per line, to the
293 standard output. Directories must be identified by the `/' termination.
294 After the file name and a blank space, any additional information about the
295 file or directory, such as permission data, size, etc, can be added. For this
296 reason, blanks and backslashes within filenames should be quoted with
297 backslashes. Linefeeds should be represented as `\n', although it is not always
298 possible to distinguish linefeeds in the middle of filenames from ones that
299 separate one file from another, in the output of, say `restore -t'. It is not
300 clear whether we should also support quoting mechanisms such as `\xHH', `\OOO'
301 or `\uXXXX'.
302
303  The `restore' command
304
305 Yet to be specified.
306
307  The `print-command' command
308
309 This command must be followed by a valid backup or restore command, and it
310 should print a shell-command that would produce an equivalent result, i.e.,
311 that would perform the backup to standard output, or that would restore the
312 whole filesystem reading from standard input. This command is to be included in
313 the header of backup images, to ease crash-recovery.
314
315  Conclusion
316
317 Well, that's all. Drop us a note at the amanda-hackers mailing list (mailto://
318 amanda-hackers@amanda.org) if you have suggestions to improve this document
319 and/or the API. Some help on its implementation would be welcome, too.
320 -------------------------------------------------------------------------------
321
322 Prev                                     Up                           Next
323 Chapter 22. How Amanda uses UDP and TCP Home  Chapter 24. Amanda Internals
324 ports 
325