1/******************************************************
2Copyright (c) 2011-2015 Percona LLC and/or its affiliates.
3
4Declarations for xtrabackup.cc
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; version 2 of the License.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18
19*******************************************************/
20
21#ifndef XB_XTRABACKUP_H
22#define XB_XTRABACKUP_H
23
24#include <my_getopt.h>
25#include "datasink.h"
26#include "xbstream.h"
27#include "changed_page_bitmap.h"
28
29struct xb_delta_info_t
30{
31 xb_delta_info_t(page_size_t page_size, ulint space_id)
32 : page_size(page_size), space_id(space_id) {}
33
34 page_size_t page_size;
35 ulint space_id;
36};
37
38/* value of the --incremental option */
39extern lsn_t incremental_lsn;
40
41extern char *xtrabackup_target_dir;
42extern char *xtrabackup_incremental_dir;
43extern char *xtrabackup_incremental_basedir;
44extern char *innobase_data_home_dir;
45extern char *innobase_buffer_pool_filename;
46extern char *xb_plugin_dir;
47extern uint opt_protocol;
48extern ds_ctxt_t *ds_meta;
49extern ds_ctxt_t *ds_data;
50
51/* The last checkpoint LSN at the backup startup time */
52extern lsn_t checkpoint_lsn_start;
53
54extern xb_page_bitmap *changed_page_bitmap;
55
56extern char *xtrabackup_incremental;
57extern my_bool xtrabackup_incremental_force_scan;
58
59extern lsn_t metadata_from_lsn;
60extern lsn_t metadata_to_lsn;
61extern lsn_t metadata_last_lsn;
62
63extern xb_stream_fmt_t xtrabackup_stream_fmt;
64extern ibool xtrabackup_stream;
65
66extern char *xtrabackup_tables;
67extern char *xtrabackup_tables_file;
68extern char *xtrabackup_databases;
69extern char *xtrabackup_databases_file;
70extern char *xtrabackup_tables_exclude;
71extern char *xtrabackup_databases_exclude;
72
73extern ibool xtrabackup_compress;
74
75extern my_bool xtrabackup_backup;
76extern my_bool xtrabackup_prepare;
77extern my_bool xtrabackup_copy_back;
78extern my_bool xtrabackup_move_back;
79extern my_bool xtrabackup_decrypt_decompress;
80
81extern char *innobase_data_file_path;
82extern longlong innobase_page_size;
83
84extern int xtrabackup_parallel;
85
86extern my_bool xb_close_files;
87extern const char *xtrabackup_compress_alg;
88#ifdef __cplusplus
89extern "C"{
90#endif
91 extern uint xtrabackup_compress_threads;
92 extern ulonglong xtrabackup_compress_chunk_size;
93#ifdef __cplusplus
94}
95#endif
96extern my_bool xtrabackup_export;
97extern char *xtrabackup_extra_lsndir;
98extern ulint xtrabackup_log_copy_interval;
99extern char *xtrabackup_stream_str;
100extern long xtrabackup_throttle;
101extern longlong xtrabackup_use_memory;
102
103extern my_bool opt_galera_info;
104extern my_bool opt_slave_info;
105extern my_bool opt_no_lock;
106extern my_bool opt_safe_slave_backup;
107extern my_bool opt_rsync;
108extern my_bool opt_force_non_empty_dirs;
109extern my_bool opt_noversioncheck;
110extern my_bool opt_no_backup_locks;
111extern my_bool opt_decompress;
112extern my_bool opt_remove_original;
113extern my_bool opt_lock_ddl_per_table;
114
115extern char *opt_incremental_history_name;
116extern char *opt_incremental_history_uuid;
117
118extern char *opt_user;
119extern char *opt_password;
120extern char *opt_host;
121extern char *opt_defaults_group;
122extern char *opt_socket;
123extern uint opt_port;
124extern char *opt_log_bin;
125
126extern const char *query_type_names[];
127
128enum query_type_t {QUERY_TYPE_ALL, QUERY_TYPE_UPDATE,
129 QUERY_TYPE_SELECT};
130
131extern TYPELIB query_type_typelib;
132
133extern ulong opt_lock_wait_query_type;
134extern ulong opt_kill_long_query_type;
135
136extern uint opt_kill_long_queries_timeout;
137extern uint opt_lock_wait_timeout;
138extern uint opt_lock_wait_threshold;
139extern uint opt_debug_sleep_before_unlock;
140extern uint opt_safe_slave_backup_timeout;
141
142extern const char *opt_history;
143
144enum binlog_info_enum { BINLOG_INFO_OFF, BINLOG_INFO_LOCKLESS, BINLOG_INFO_ON,
145 BINLOG_INFO_AUTO};
146
147extern ulong opt_binlog_info;
148
149void xtrabackup_io_throttling(void);
150my_bool xb_write_delta_metadata(const char *filename,
151 const xb_delta_info_t *info);
152
153/************************************************************************
154Checks if a table specified as a name in the form "database/name" (InnoDB 5.6)
155or "./database/name.ibd" (InnoDB 5.5-) should be skipped from backup based on
156the --tables or --tables-file options.
157
158@return TRUE if the table should be skipped. */
159my_bool
160check_if_skip_table(
161/******************/
162 const char* name); /*!< in: path to the table */
163
164
165/************************************************************************
166Checks if a database specified by path should be skipped from backup based on
167the --databases, --databases_file or --databases_exclude options.
168
169@return TRUE if the table should be skipped. */
170my_bool
171check_if_skip_database_by_path(
172 const char* path /*!< in: path to the db directory. */
173);
174
175/************************************************************************
176Check if parameter is set in defaults file or via command line argument
177@return true if parameter is set. */
178bool
179check_if_param_set(const char *param);
180
181#if defined(HAVE_OPENSSL)
182extern my_bool opt_ssl_verify_server_cert;
183#endif
184
185
186my_bool
187xb_get_one_option(int optid,
188 const struct my_option *opt __attribute__((unused)),
189 char *argument);
190
191const char*
192xb_get_copy_action(const char *dflt = "Copying");
193
194void mdl_lock_init();
195void mdl_lock_table(ulint space_id);
196void mdl_unlock_all();
197bool ends_with(const char *str, const char *suffix);
198#endif /* XB_XTRABACKUP_H */
199