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