PostgreSQL Source Code  git master
basebackup_target.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * basebackup_target.h
4  * Extensibility framework for adding base backup targets.
5  *
6  * Portions Copyright (c) 2010-2024, PostgreSQL Global Development Group
7  *
8  * src/include/backup/basebackup_target.h
9  *
10  *-------------------------------------------------------------------------
11  */
12 #ifndef BASEBACKUP_TARGET_H
13 #define BASEBACKUP_TARGET_H
14 
15 #include "backup/basebackup_sink.h"
16 
19 
20 /*
21  * Extensions can call this function to create new backup targets.
22  *
23  * 'name' is the name of the new target.
24  *
25  * 'check_detail' is a function that accepts a target name and target detail
26  * and either throws an error (if the target detail is not valid or some other
27  * problem, such as a permissions issue, is detected) or returns a pointer to
28  * the data that will be needed to create a bbsink implementing that target.
29  * The second argument will be NULL if the TARGET_DETAIL option to the
30  * BASE_BACKUP command was not specified.
31  *
32  * 'get_sink' is a function that creates the bbsink. The first argument
33  * is the successor sink; the sink created by this function should always
34  * forward to this sink. The second argument is the pointer returned by a
35  * previous call to the 'check_detail' function.
36  *
37  * In practice, a user will type something like "pg_basebackup --target foo:bar
38  * -Xfetch". That will cause the server to look for a backup target named
39  * "foo". If one is found, the check_detail callback will be invoked for the
40  * string "bar", and whatever that callback returns will be passed as the
41  * second argument to the get_sink callback.
42  */
43 extern void BaseBackupAddTarget(char *name,
44  void *(*check_detail) (char *, char *),
45  bbsink *(*get_sink) (bbsink *, void *));
46 
47 /*
48  * These functions are used by the core code to access base backup targets
49  * added via BaseBackupAddTarget(). The core code will pass the TARGET and
50  * TARGET_DETAIL strings obtained from the user to BaseBackupGetTargetHandle,
51  * which will either throw an error (if the TARGET is not recognized or the
52  * check_detail hook for that TARGET doesn't like the TARGET_DETAIL) or
53  * return a BaseBackupTargetHandle object that can later be passed to
54  * BaseBackupGetSink.
55  *
56  * BaseBackupGetSink constructs a bbsink implementing the desired target
57  * using the BaseBackupTargetHandle and the successor bbsink. It does this
58  * by arranging to call the get_sink() callback provided by the extension
59  * that implements the base backup target.
60  */
62  char *target_detail);
64  bbsink *next_sink);
65 
66 #endif
bbsink * BaseBackupGetSink(BaseBackupTargetHandle *handle, bbsink *next_sink)
BaseBackupTargetHandle * BaseBackupGetTargetHandle(char *target, char *target_detail)
void BaseBackupAddTarget(char *name, void *(*check_detail)(char *, char *), bbsink *(*get_sink)(bbsink *, void *))
const char * name