From: Kern Sibbald Date: Wed, 22 Jan 2003 21:04:06 +0000 (+0000) Subject: prefix links code in Dir X-Git-Tag: Release-1.29~7 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6e07787131ed724092e4336bdc30c82fe5503ff8;p=bacula%2Fbacula prefix links code in Dir git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@313 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 92733f3553..cc21842f88 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -379,8 +379,10 @@ extern int thr_setconcurrency(int); #define S_ISWIN32 020000 #endif -/* Replace codes needed in both file routines and non-file routines */ -/* Job replace codes -- in "replace" */ +/* + * Replace codes needed in both file routines and non-file routines + * Job replace codes -- in "replace" + */ #define REPLACE_ALWAYS 'a' #define REPLACE_IFNEWER 'w' #define REPLACE_NEVER 'n' diff --git a/bacula/src/dird/bacula-dir.conf.in b/bacula/src/dird/bacula-dir.conf.in index 6b3a98b0ee..1daf984bd0 100644 --- a/bacula/src/dird/bacula-dir.conf.in +++ b/bacula/src/dird/bacula-dir.conf.in @@ -77,7 +77,10 @@ FileSet { # # @file-name # -# Note: / backs up everything +# Note: / backs up everything on the root partition. +# if you have other partitons such as /usr or /home +# you will probably want to add them too. +# / diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index bebf9c27ad..c0ec70f10c 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -178,6 +178,7 @@ static struct res_items job_items[] = { {"bootstrap",store_dir, ITEM(res_job.RestoreBootstrap), 0, 0, 0}, {"maxruntime", store_time, ITEM(res_job.MaxRunTime), 0, 0, 0}, {"maxstartdelay", store_time,ITEM(res_job.MaxStartDelay), 0, 0, 0}, + {"prefixlinks", store_yesno, ITEM(res_job.PrefixLinks), 1, ITEM_DEFAULT, 0}, {"prunejobs", store_yesno, ITEM(res_job.PruneJobs), 1, ITEM_DEFAULT, 0}, {"prunefiles", store_yesno, ITEM(res_job.PruneFiles), 1, ITEM_DEFAULT, 0}, {"prunevolumes", store_yesno, ITEM(res_job.PruneVolumes), 1, ITEM_DEFAULT, 0}, @@ -1016,7 +1017,7 @@ static void store_replace(LEX *lc, struct res_items *item, int index, int pass) /* Scan Replacement options */ for (i=0; ReplaceOptions[i].name; i++) { if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) { - ((JOB *)(item->value))->replace = ReplaceOptions[i].token; + ((JOB *)(item->value))->replace = ReplaceOptions[i].token; i = 0; break; } diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 570a3251af..d72a1b6319 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -30,44 +30,44 @@ /* * Resource codes -- they must be sequential for indexing */ -#define R_FIRST 1001 - -#define R_DIRECTOR 1001 -#define R_CLIENT 1002 -#define R_JOB 1003 -#define R_STORAGE 1004 -#define R_CATALOG 1005 -#define R_SCHEDULE 1006 -#define R_FILESET 1007 -#define R_GROUP 1008 -#define R_POOL 1009 -#define R_MSGS 1010 -#define R_COUNTER 1011 -#define R_FILEOPTIONS 1012 - -#define R_LAST R_FILEOPTIONS +#define R_FIRST 1001 + +#define R_DIRECTOR 1001 +#define R_CLIENT 1002 +#define R_JOB 1003 +#define R_STORAGE 1004 +#define R_CATALOG 1005 +#define R_SCHEDULE 1006 +#define R_FILESET 1007 +#define R_GROUP 1008 +#define R_POOL 1009 +#define R_MSGS 1010 +#define R_COUNTER 1011 +#define R_FILEOPTIONS 1012 + +#define R_LAST R_FILEOPTIONS /* * Some resource attributes */ -#define R_NAME 1020 -#define R_ADDRESS 1021 -#define R_PASSWORD 1022 -#define R_TYPE 1023 -#define R_BACKUP 1024 +#define R_NAME 1020 +#define R_ADDRESS 1021 +#define R_PASSWORD 1022 +#define R_TYPE 1023 +#define R_BACKUP 1024 /* Used for certain KeyWord tables */ -struct s_kw { +struct s_kw { char *name; - int token; + int token; }; /* Job Level keyword structure */ struct s_jl { - char *level_name; /* level keyword */ - int level; /* level */ - int job_type; /* JobType permitting this level */ + char *level_name; /* level keyword */ + int level; /* level */ + int job_type; /* JobType permitting this level */ }; /* Job Type keyword structure */ @@ -79,22 +79,22 @@ struct s_jt { /* Definition of the contents of each Resource */ /* - * Director Resource + * Director Resource * */ struct s_res_dir { - RES hdr; - int DIRport; /* where we listen -- UA port server port */ - char *DIRaddr; /* bind address */ - char *password; /* Password for UA access */ - char *query_file; /* SQL query file */ - char *working_directory; /* WorkingDirectory */ - char *pid_directory; /* PidDirectory */ - char *subsys_directory; /* SubsysDirectory */ + RES hdr; + int DIRport; /* where we listen -- UA port server port */ + char *DIRaddr; /* bind address */ + char *password; /* Password for UA access */ + char *query_file; /* SQL query file */ + char *working_directory; /* WorkingDirectory */ + char *pid_directory; /* PidDirectory */ + char *subsys_directory; /* SubsysDirectory */ struct s_res_msgs *messages; /* Daemon message handler */ - int MaxConcurrentJobs; - utime_t FDConnectTimeout; /* timeout for connect in seconds */ - utime_t SDConnectTimeout; /* timeout in seconds */ + int MaxConcurrentJobs; + utime_t FDConnectTimeout; /* timeout for connect in seconds */ + utime_t SDConnectTimeout; /* timeout in seconds */ }; typedef struct s_res_dir DIRRES; @@ -103,12 +103,12 @@ typedef struct s_res_dir DIRRES; * */ struct s_res_client { - RES hdr; + RES hdr; - int FDport; /* Where File daemon listens */ - int AutoPrune; /* Do automatic pruning? */ - utime_t FileRetention; /* file retention period in seconds */ - utime_t JobRetention; /* job retention period in seconds */ + int FDport; /* Where File daemon listens */ + int AutoPrune; /* Do automatic pruning? */ + utime_t FileRetention; /* file retention period in seconds */ + utime_t JobRetention; /* job retention period in seconds */ char *address; char *password; struct s_res_cat *catalog; /* Catalog resource */ @@ -120,15 +120,15 @@ typedef struct s_res_client CLIENT; * */ struct s_res_store { - RES hdr; + RES hdr; - int SDport; /* port where Directors connect */ - int SDDport; /* data port for File daemon */ + int SDport; /* port where Directors connect */ + int SDDport; /* data port for File daemon */ char *address; char *password; char *media_type; char *dev_name; - int autochanger; /* set if autochanger */ + int autochanger; /* set if autochanger */ }; typedef struct s_res_store STORE; @@ -137,9 +137,9 @@ typedef struct s_res_store STORE; * */ struct s_res_cat { - RES hdr; + RES hdr; - int DBport; /* Port -- not yet implemented */ + int DBport; /* Port -- not yet implemented */ char *address; char *db_password; char *db_user; @@ -152,30 +152,31 @@ typedef struct s_res_cat CAT; * */ struct s_res_job { - RES hdr; - - int JobType; /* job type (backup, verify, restore */ - int level; /* default backup/verify level */ - int RestoreJobId; /* What -- JobId to restore */ - char *RestoreWhere; /* Where on disk to restore -- directory */ - char *RestoreBootstrap; /* Bootstrap file */ - char *RunBeforeJob; /* Run program before Job */ - char *RunAfterJob; /* Run program after Job */ - char *WriteBootstrap; /* Where to write bootstrap Job updates */ - int replace; /* How (overwrite, ..) */ - utime_t MaxRunTime; /* max run time in seconds */ - utime_t MaxStartDelay; /* max start delay in seconds */ - int PruneJobs; /* Force pruning of Jobs */ - int PruneFiles; /* Force pruning of Files */ - int PruneVolumes; /* Force pruning of Volumes */ - int SpoolAttributes; /* Set to spool attributes in SD */ + RES hdr; + + int JobType; /* job type (backup, verify, restore */ + int level; /* default backup/verify level */ + int RestoreJobId; /* What -- JobId to restore */ + char *RestoreWhere; /* Where on disk to restore -- directory */ + char *RestoreBootstrap; /* Bootstrap file */ + char *RunBeforeJob; /* Run program before Job */ + char *RunAfterJob; /* Run program after Job */ + char *WriteBootstrap; /* Where to write bootstrap Job updates */ + int replace; /* How (overwrite, ..) */ + utime_t MaxRunTime; /* max run time in seconds */ + utime_t MaxStartDelay; /* max start delay in seconds */ + int PrefixLinks; /* prefix soft links with Where path */ + int PruneJobs; /* Force pruning of Jobs */ + int PruneFiles; /* Force pruning of Files */ + int PruneVolumes; /* Force pruning of Volumes */ + int SpoolAttributes; /* Set to spool attributes in SD */ struct s_res_msgs *messages; /* How and where to send messages */ struct s_res_sch *schedule; /* When -- Automatic schedule */ struct s_res_client *client; /* Who to backup */ struct s_res_fs *fileset; /* What to backup -- Fileset */ struct s_res_store *storage; /* Where is device -- Storage daemon */ - struct s_res_pool *pool; /* Where is media -- Media Pool */ + struct s_res_pool *pool; /* Where is media -- Media Pool */ }; typedef struct s_res_job JOB; @@ -184,7 +185,7 @@ typedef struct s_res_job JOB; * */ struct s_res_fs { - RES hdr; + RES hdr; char **include_array; int num_includes; @@ -192,9 +193,9 @@ struct s_res_fs { char **exclude_array; int num_excludes; int exclude_size; - int have_MD5; /* set if MD5 initialized */ - struct MD5Context md5c; /* MD5 of include/exclude */ - char MD5[50]; /* base 64 representation of MD5 */ + int have_MD5; /* set if MD5 initialized */ + struct MD5Context md5c; /* MD5 of include/exclude */ + char MD5[50]; /* base 64 representation of MD5 */ }; typedef struct s_res_fs FILESET; @@ -202,10 +203,10 @@ typedef struct s_res_fs FILESET; * FileOptions Resource (options for Includes) */ struct s_res_fo { - RES hdr; + RES hdr; - char opts[50]; /* Options string */ - struct s_applyto *applyto; /* applyto strings */ + char opts[50]; /* Options string */ + struct s_applyto *applyto; /* applyto strings */ }; typedef struct s_res_fo FILEOPTIONS; @@ -215,7 +216,7 @@ typedef struct s_res_fo FILEOPTIONS; * */ struct s_res_sch { - RES hdr; + RES hdr; struct s_run *run; }; @@ -226,7 +227,7 @@ typedef struct s_res_sch SCHED; * */ struct s_res_group { - RES hdr; + RES hdr; }; typedef struct s_res_group GROUP; @@ -234,12 +235,12 @@ typedef struct s_res_group GROUP; * Counter Resource */ struct s_res_counter { - RES hdr; + RES hdr; - int32_t MinValue; /* Minimum value */ - int32_t MaxValue; /* Maximum value */ - int Global; /* global/local */ - char *WrapCounter; /* Wrap counter name */ + int32_t MinValue; /* Minimum value */ + int32_t MaxValue; /* Maximum value */ + int Global; /* global/local */ + char *WrapCounter; /* Wrap counter name */ }; typedef struct s_res_counter COUNTER; @@ -248,23 +249,23 @@ typedef struct s_res_counter COUNTER; * */ struct s_res_pool { - RES hdr; + RES hdr; struct s_res_counter counter; /* Counter resources */ - char *pool_type; /* Pool type */ - char *label_format; /* Label format string */ - int use_catalog; /* maintain catalog for media */ - int catalog_files; /* maintain file entries in catalog */ - int use_volume_once; /* write on volume only once */ - int accept_any_volume; /* accept any volume */ - uint32_t max_volumes; /* max number of volumes */ - utime_t VolRetention; /* volume retention period in seconds */ - utime_t VolUseDuration; /* duration volume can be used */ - uint32_t MaxVolJobs; /* Maximum jobs on the Volume */ - uint32_t MaxVolFiles; /* Maximum files on the Volume */ - uint64_t MaxVolBytes; /* Maximum bytes on the Volume */ - int AutoPrune; /* default for pool auto prune */ - int Recycle; /* default for media recycle yes/no */ + char *pool_type; /* Pool type */ + char *label_format; /* Label format string */ + int use_catalog; /* maintain catalog for media */ + int catalog_files; /* maintain file entries in catalog */ + int use_volume_once; /* write on volume only once */ + int accept_any_volume; /* accept any volume */ + uint32_t max_volumes; /* max number of volumes */ + utime_t VolRetention; /* volume retention period in seconds */ + utime_t VolUseDuration; /* duration volume can be used */ + uint32_t MaxVolJobs; /* Maximum jobs on the Volume */ + uint32_t MaxVolFiles; /* Maximum files on the Volume */ + uint64_t MaxVolBytes; /* Maximum bytes on the Volume */ + int AutoPrune; /* default for pool auto prune */ + int Recycle; /* default for media recycle yes/no */ }; typedef struct s_res_pool POOL; @@ -273,18 +274,18 @@ typedef struct s_res_pool POOL; * resource structure definitions. */ union u_res { - struct s_res_dir res_dir; - struct s_res_client res_client; - struct s_res_store res_store; - struct s_res_cat res_cat; - struct s_res_job res_job; - struct s_res_fs res_fs; - struct s_res_sch res_sch; - struct s_res_group res_group; - struct s_res_pool res_pool; - struct s_res_msgs res_msgs; + struct s_res_dir res_dir; + struct s_res_client res_client; + struct s_res_store res_store; + struct s_res_cat res_cat; + struct s_res_job res_job; + struct s_res_fs res_fs; + struct s_res_sch res_sch; + struct s_res_group res_group; + struct s_res_pool res_pool; + struct s_res_msgs res_msgs; struct s_res_counter res_counter; - struct s_res_fo res_fo; + struct s_res_fo res_fo; RES hdr; }; @@ -293,17 +294,17 @@ typedef union u_res URES; /* Run structure contained in Schedule Resource */ struct s_run { - struct s_run *next; /* points to next run record */ - int level; /* level override */ + struct s_run *next; /* points to next run record */ + int level; /* level override */ int job_type; - POOL *pool; /* Pool override */ - STORE *storage; /* Storage override */ - MSGS *msgs; /* Messages override */ + POOL *pool; /* Pool override */ + STORE *storage; /* Storage override */ + MSGS *msgs; /* Messages override */ char *since; int level_no; - int minute; /* minute to run job */ - time_t last_run; /* last time run */ - time_t next_run; /* next time to run */ + int minute; /* minute to run job */ + time_t last_run; /* last time run */ + time_t next_run; /* next time to run */ char hour[nbytes_for_bits(24)]; /* bit set for each hour */ char mday[nbytes_for_bits(31)]; /* bit set for each day of month */ char month[nbytes_for_bits(12)]; /* bit set for each month */ diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index 4a6e05187d..4ba3880c67 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -4,8 +4,7 @@ * * Kern Sibbald, November MM * - * This routine is run as a separate thread. There may be more - * work to be done to make it totally reentrant!!!! + * This routine is run as a separate thread. * * Current implementation is Catalog verification only (i.e. no * verification versus tape). diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index 1c9d24fae5..810cd1b416 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -8,7 +8,7 @@ */ /* - Copyright (C) 2001, 2002 Kern Sibbald and John Walker + Copyright (C) 2001-2003 Kern Sibbald and John Walker This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index aa5e8151b3..207e5d9697 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -87,31 +87,31 @@ static struct s_cmds cmds[] = { }; /* Commands received from director that need scanning */ -static char jobcmd[] = "JobId=%d Job=%127s SDid=%d SDtime=%d Authorization=%100s"; -static char storaddr[] = "storage address=%s port=%d\n"; -static char sessioncmd[] = "session %s %ld %ld %ld %ld %ld %ld\n"; -static char restorecmd[] = "restore replace=%c where=%s\n"; +static char jobcmd[] = "JobId=%d Job=%127s SDid=%d SDtime=%d Authorization=%100s"; +static char storaddr[] = "storage address=%s port=%d\n"; +static char sessioncmd[] = "session %s %ld %ld %ld %ld %ld %ld\n"; +static char restorecmd[] = "restore replace=%c where=%s\n"; static char restorecmd1[] = "restore replace=%c where=\n"; -static char verifycmd[] = "verify level=%20s\n"; +static char verifycmd[] = "verify level=%20s\n"; /* Responses sent to Director */ -static char errmsg[] = "2999 Invalid command\n"; -static char no_auth[] = "2998 No Authorization\n"; -static char OKinc[] = "2000 OK include\n"; -static char OKest[] = "2000 OK estimate files=%ld bytes=%ld\n"; -static char OKexc[] = "2000 OK exclude\n"; -static char OKlevel[] = "2000 OK level\n"; -static char OKbackup[] = "2000 OK backup\n"; -static char OKbootstrap[] = "2000 OK bootstrap\n"; -static char OKverify[] = "2000 OK verify\n"; -static char OKrestore[] = "2000 OK restore\n"; -static char OKsession[] = "2000 OK session\n"; -static char OKstore[] = "2000 OK storage\n"; -static char OKjob[] = "2000 OK Job " FDHOST "," DISTNAME "," DISTVER; -static char OKsetdebug[] = "2000 OK setdebug=%d\n"; -static char BADjob[] = "2901 Bad Job\n"; -static char EndRestore[] = "2800 End Job TermCode=%d JobFiles=%u JobBytes=%" lld "\n"; -static char EndBackup[] = "2801 End Backup Job TermCode=%d JobFiles=%u ReadBytes=%" lld " JobBytes=%" lld "\n"; +static char errmsg[] = "2999 Invalid command\n"; +static char no_auth[] = "2998 No Authorization\n"; +static char OKinc[] = "2000 OK include\n"; +static char OKest[] = "2000 OK estimate files=%ld bytes=%ld\n"; +static char OKexc[] = "2000 OK exclude\n"; +static char OKlevel[] = "2000 OK level\n"; +static char OKbackup[] = "2000 OK backup\n"; +static char OKbootstrap[] = "2000 OK bootstrap\n"; +static char OKverify[] = "2000 OK verify\n"; +static char OKrestore[] = "2000 OK restore\n"; +static char OKsession[] = "2000 OK session\n"; +static char OKstore[] = "2000 OK storage\n"; +static char OKjob[] = "2000 OK Job " FDHOST "," DISTNAME "," DISTVER; +static char OKsetdebug[] = "2000 OK setdebug=%d\n"; +static char BADjob[] = "2901 Bad Job\n"; +static char EndRestore[] = "2800 End Job TermCode=%d JobFiles=%u JobBytes=%" lld "\n"; +static char EndBackup[] = "2801 End Backup Job TermCode=%d JobFiles=%u ReadBytes=%" lld " JobBytes=%" lld "\n"; /* Responses received from Storage Daemon */ static char OK_end[] = "3000 OK end\n"; diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index f5d06e3325..206cf33f27 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -234,7 +234,7 @@ void do_restore(JCR *jcr) } strcat(ofile, fn); /* copy rest of name */ /* Fixup link name */ - if (type == FT_LNK || type == FT_LNKSAVED) { + if (type == FT_LNKSAVED || (type == FT_LNK && jcr->prefix_links)) { if (lp[0] == '/') { /* if absolute path */ strcpy(lname, jcr->where); } diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h index 31b8e55f78..38e84430fe 100755 --- a/bacula/src/findlib/find.h +++ b/bacula/src/findlib/find.h @@ -76,14 +76,14 @@ #define FT_FIFO 17 /* Raw fifo device */ /* Options saved in "flag" of ff packet */ -#define FO_MD5 0x01 /* Do MD5 checksum */ -#define FO_GZIP 0x02 /* Do Zlib compression */ -#define FO_NO_RECURSION 0x04 /* no recursion in directories */ -#define FO_MULTIFS 0x08 /* multiple file systems */ -#define FO_SPARSE 0x10 /* do sparse file checking */ -#define FO_IF_NEWER 0x20 /* replace if newer */ -#define FO_NOREPLACE 0x40 /* never replace */ -#define FO_READFIFO 0x80 /* read data from fifo */ +#define FO_MD5 0x001 /* Do MD5 checksum */ +#define FO_GZIP 0x002 /* Do Zlib compression */ +#define FO_NO_RECURSION 0x004 /* no recursion in directories */ +#define FO_MULTIFS 0x008 /* multiple file systems */ +#define FO_SPARSE 0x010 /* do sparse file checking */ +#define FO_IF_NEWER 0x020 /* replace if newer */ +#define FO_NOREPLACE 0x040 /* never replace */ +#define FO_READFIFO 0x080 /* read data from fifo */ /* * Options saved in "options" of include list @@ -102,7 +102,6 @@ #define OPT_read_fifo 0x80 /* read data from fifo (named pipe) */ - struct s_included_file { struct s_included_file *next; int options; /* backup options */ diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 6fea571fc9..7eb33aef14 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -160,6 +160,7 @@ struct s_jcr { int32_t compress_buf_size; /* Length of compression buffer */ POOLMEM *where; /* Root where to restore */ int replace; /* Replace options */ + int prefix_links; /* Prefix links with Where path */ int buf_size; /* length of buffer */ void *ff; /* Find Files packet */ char stored_addr[MAX_NAME_LENGTH]; /* storage daemon address */