2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version three of the GNU Affero General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
29 * Director external function prototypes
33 extern bool do_admin_init(JCR *jcr);
34 extern bool do_admin(JCR *jcr);
35 extern void admin_cleanup(JCR *jcr, int TermCode);
39 extern bool authenticate_storage_daemon(JCR *jcr, STORE *store);
40 extern int authenticate_file_daemon(JCR *jcr);
41 extern int authenticate_user_agent(UAContext *ua);
44 extern void do_autoprune(JCR *jcr);
45 extern void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr);
48 extern bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr);
49 extern int recycle_volume(JCR *jcr, MEDIA_DBR *mr);
50 extern bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr);
53 extern int wait_for_job_termination(JCR *jcr, int timeout=0);
54 extern bool do_backup_init(JCR *jcr);
55 extern bool do_backup(JCR *jcr);
56 extern void backup_cleanup(JCR *jcr, int TermCode);
57 extern void update_bootstrap_file(JCR *jcr);
58 extern bool send_accurate_current_files(JCR *jcr);
62 extern bool do_vbackup_init(JCR *jcr);
63 extern bool do_vbackup(JCR *jcr);
64 extern void vbackup_cleanup(JCR *jcr, int TermCode);
69 void free_bsr(RBSR *bsr);
70 bool complete_bsr(UAContext *ua, RBSR *bsr);
71 uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx);
72 void display_bsr_info(UAContext *ua, RESTORE_CTX &rx);
73 void add_findex(RBSR *bsr, uint32_t JobId, int32_t findex);
74 void add_findex_all(RBSR *bsr, uint32_t JobId);
75 RBSR_FINDEX *new_findex();
76 void make_unique_restore_filename(UAContext *ua, POOLMEM **fname);
77 void print_bsr(UAContext *ua, RESTORE_CTX &rx);
81 extern void catalog_request(JCR *jcr, BSOCK *bs);
82 extern void catalog_update(JCR *jcr, BSOCK *bs);
83 extern bool despool_attributes_from_file(JCR *jcr, const char *file);
86 extern const char *level_to_str(int level);
87 extern "C" char *job_code_callback_filesetname(JCR *jcr, const char*);
90 int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp);
94 extern int connect_to_file_daemon(JCR *jcr, int retry_interval,
95 int max_retry_time, int verbose);
96 extern bool send_include_list(JCR *jcr);
97 extern bool send_exclude_list(JCR *jcr);
98 extern bool send_level_command(JCR *jcr);
99 extern bool send_bwlimit(JCR *jcr, const char *Job);
100 extern int get_attributes_and_put_in_catalog(JCR *jcr);
101 extern void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId);
102 extern int put_file_into_catalog(JCR *jcr, long file_index, char *fname,
103 char *link, char *attr, int stream);
104 extern void get_level_since_time(JCR *jcr, char *since, int since_len);
105 extern int send_runscripts_commands(JCR *jcr);
106 extern bool send_restore_objects(JCR *jcr);
113 extern bool response(JCR *jcr, BSOCK *fd, char *resp, const char *cmd, e_prtmsg prtmsg);
116 extern bool allow_duplicate_job(JCR *jcr);
117 extern void set_jcr_defaults(JCR *jcr, JOB *job);
118 extern void create_unique_job_name(JCR *jcr, const char *base_name);
119 extern void update_job_end_record(JCR *jcr);
120 extern bool get_or_create_client_record(JCR *jcr);
121 extern bool get_or_create_fileset_record(JCR *jcr);
122 extern DBId_t get_or_create_pool_record(JCR *jcr, char *pool_name);
123 extern void apply_pool_overrides(JCR *jcr);
124 extern JobId_t run_job(JCR *jcr);
125 extern bool cancel_job(UAContext *ua, JCR *jcr);
126 extern void get_job_storage(USTORE *store, JOB *job, RUN *run);
127 extern void init_jcr_job_record(JCR *jcr);
128 extern void update_job_end(JCR *jcr, int TermCode);
129 extern void copy_rwstorage(JCR *jcr, alist *storage, const char *where);
130 extern void set_rwstorage(JCR *jcr, USTORE *store);
131 extern void free_rwstorage(JCR *jcr);
132 extern void copy_wstorage(JCR *jcr, alist *storage, const char *where);
133 extern void set_wstorage(JCR *jcr, USTORE *store);
134 extern void free_wstorage(JCR *jcr);
135 extern void copy_rstorage(JCR *jcr, alist *storage, const char *where);
136 extern void set_rstorage(JCR *jcr, USTORE *store);
137 extern void free_rstorage(JCR *jcr);
138 extern bool setup_job(JCR *jcr);
139 extern void create_clones(JCR *jcr);
140 extern int create_restore_bootstrap_file(JCR *jcr);
141 extern void dird_free_jcr(JCR *jcr);
142 extern void dird_free_jcr_pointers(JCR *jcr);
143 extern void cancel_storage_daemon_job(JCR *jcr);
144 extern bool run_console_command(JCR *jcr, const char *cmd);
145 extern void sd_msg_thread_send_signal(JCR *jcr, int sig);
148 extern bool inc_read_store(JCR *jcr);
149 extern void dec_read_store(JCR *jcr);
152 extern bool do_migration(JCR *jcr);
153 extern bool do_migration_init(JCR *jcr);
154 extern void migration_cleanup(JCR *jcr, int TermCode);
155 extern bool set_migration_wstorage(JCR *jcr, POOL *pool);
159 extern void mount_request(JCR *jcr, BSOCK *bs, char *buf);
162 extern bool connect_to_storage_daemon(JCR *jcr, int retry_interval,
163 int max_retry_time, int verbose);
164 extern bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore,
165 bool send_bsr=false);
166 extern bool start_storage_daemon_message_thread(JCR *jcr);
167 extern int bget_dirmsg(BSOCK *bs);
168 extern void wait_for_storage_daemon_termination(JCR *jcr);
169 extern bool send_bootstrap_file(JCR *jcr, BSOCK *sd);
172 int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index,
173 bool create, bool purge);
174 bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr);
175 void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **reason);
176 bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr);
179 bool newVolume(JCR *jcr, MEDIA_DBR *mr);
182 int generate_job_event(JCR *jcr, const char *event);
186 extern bool do_restore(JCR *jcr);
187 extern bool do_restore_init(JCR *jcr);
188 extern void restore_cleanup(JCR *jcr, int TermCode);
192 bool acl_access_ok(UAContext *ua, int acl, const char *item);
193 bool acl_access_ok(UAContext *ua, int acl, const char *item, int len);
196 bool do_a_command(UAContext *ua);
197 bool do_a_dot_command(UAContext *ua);
198 int qmessagescmd(UAContext *ua, const char *cmd);
199 bool open_new_client_db(UAContext *ua);
200 bool open_client_db(UAContext *ua);
201 bool open_db(UAContext *ua);
202 void close_db(UAContext *ua);
207 int create_pool(JCR *jcr, B_DB *db, POOL *pool, e_pool_op op);
208 void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr);
209 bool set_pooldbr_references(JCR *jcr, B_DB *db, POOL_DBR *pr, POOL *pool);
210 void set_pooldbr_from_poolres(POOL_DBR *pr, POOL *pool, e_pool_op op);
211 int update_pool_references(JCR *jcr, B_DB *db, POOL *pool);
214 int get_cmd(UAContext *ua, const char *prompt, bool subprompt=false);
215 bool get_pint(UAContext *ua, const char *prompt);
216 bool get_yesno(UAContext *ua, const char *prompt);
217 bool is_yesno(char *val, int *ret);
218 int get_enabled(UAContext *ua, const char *val);
219 void parse_ua_args(UAContext *ua);
220 bool is_comment_legal(UAContext *ua, const char *name);
223 bool is_volume_name_legal(UAContext *ua, const char *name);
224 int get_num_drives_from_SD(UAContext *ua);
225 void update_slots(UAContext *ua);
228 void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *opr);
231 void prtit(void *ctx, const char *msg);
232 bool complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool);
233 RUN *find_next_run(RUN *run, JOB *job, utime_t &runtime, int ndays);
236 void find_storage_resource(UAContext *ua, RESTORE_CTX &rx, char *Storage, char *MediaType);
239 void bsendmsg(void *ua_ctx, const char *fmt, ...);
240 void berrormsg(void *ua_ctx, const char *fmt, ...);
241 void bwarningmsg(void *ua_ctx, const char *fmt, ...);
242 void binfomsg(void *ua_ctx, const char *fmt, ...);
243 UAContext *new_ua_context(JCR *jcr);
244 JCR *new_control_jcr(const char *base_name, int job_type);
245 void free_ua_context(UAContext *ua);
248 STORE *select_storage_resource(UAContext *ua);
249 JOB *select_job_resource(UAContext *ua);
250 JOB *select_enable_disable_job_resource(UAContext *ua, bool enable);
251 JOB *select_restore_job_resource(UAContext *ua);
252 CLIENT *select_client_resource(UAContext *ua);
253 FILESET *select_fileset_resource(UAContext *ua);
254 int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr);
255 int select_media_dbr(UAContext *ua, MEDIA_DBR *mr);
256 bool select_pool_dbr(UAContext *ua, POOL_DBR *pr, const char *argk="pool");
257 bool select_client_dbr(UAContext *ua, CLIENT_DBR *cr);
259 void start_prompt(UAContext *ua, const char *msg);
260 void add_prompt(UAContext *ua, const char *prompt);
261 int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, int max_prompt);
262 CAT *get_catalog_resource(UAContext *ua);
263 STORE *get_storage_resource(UAContext *ua, bool use_default);
264 int get_storage_drive(UAContext *ua, STORE *store);
265 int get_storage_slot(UAContext *ua, STORE *store);
266 int get_media_type(UAContext *ua, char *MediaType, int max_media);
267 bool get_pool_dbr(UAContext *ua, POOL_DBR *pr, const char *argk="pool");
268 bool get_client_dbr(UAContext *ua, CLIENT_DBR *cr);
269 POOL *get_pool_resource(UAContext *ua);
270 POOL *select_pool_resource(UAContext *ua);
271 JCR *select_running_job(UAContext *ua, const char *reason);
272 CLIENT *get_client_resource(UAContext *ua);
273 int get_job_dbr(UAContext *ua, JOB_DBR *jr);
275 int find_arg_keyword(UAContext *ua, const char **list);
276 int find_arg(UAContext *ua, const char *keyword);
277 int find_arg_with_value(UAContext *ua, const char *keyword);
278 int do_keyword_prompt(UAContext *ua, const char *msg, const char **list);
279 int confirm_retention(UAContext *ua, utime_t *ret, const char *msg);
280 bool get_level_from_name(JCR *jcr, const char *level_name);
283 void list_dir_status_header(UAContext *ua);
286 bool user_select_files_from_tree(TREE_CTX *tree);
287 int insert_tree_handler(void *ctx, int num_fields, char **row);
290 int prune_files(UAContext *ua, CLIENT *client, POOL *pool);
291 int prune_jobs(UAContext *ua, CLIENT *client, POOL *pool, int JobType);
292 int prune_stats(UAContext *ua, utime_t retention);
293 bool prune_volume(UAContext *ua, MEDIA_DBR *mr);
294 int job_delete_handler(void *ctx, int num_fields, char **row);
295 int del_count_handler(void *ctx, int num_fields, char **row);
296 int file_delete_handler(void *ctx, int num_fields, char **row);
297 int get_prune_list_for_volume(UAContext *ua, MEDIA_DBR *mr, del_ctx *del);
298 int exclude_running_jobs_from_list(del_ctx *prune_list);
301 bool is_volume_purged(UAContext *ua, MEDIA_DBR *mr, bool force=false);
302 bool mark_media_purged(UAContext *ua, MEDIA_DBR *mr);
303 void purge_files_from_volume(UAContext *ua, MEDIA_DBR *mr);
304 bool purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr, bool force=false);
305 void purge_files_from_jobs(UAContext *ua, char *jobs);
306 void purge_jobs_from_catalog(UAContext *ua, char *jobs);
307 void purge_job_list_from_catalog(UAContext *ua, del_ctx &del);
308 void purge_files_from_job_list(UAContext *ua, del_ctx &del);
312 extern int run_cmd(UAContext *ua, const char *cmd);
315 extern bool do_verify(JCR *jcr);
316 extern bool do_verify_init(JCR *jcr);
317 extern void verify_cleanup(JCR *jcr, int TermCode);