1.. _section-alwaysincremental:
2
3Always Incremental Backup Scheme
4================================
5
6:index:`\ <single: Always Incremental>`\
7
8Always Incremental Backups are available since Bareos :sinceVersion:`16.2.4: Always Incremental`.
9
10Conventional Backup Scheme Drawbacks
11------------------------------------
12
13:index:`\ <single: Retention>`\
14
15To better understand the advantages of the Always Incremental Backup scheme, we first analyze the way that the conventional Incremental - Differential - Full Backup Scheme works.
16
17The following figure shows the jobs available for restore over time. Red are full backups, green are differential backups and blue are incremental Backups. When you look for a data at the horizontal axis, you see what backup jobs are available for a restore at this given time.
18
19.. image:: /include/images/inc-diff-full-jobs_available.*
20
21
22
23The next figure shows the amount of data being backed up over the network from that client over time:
24
25.. image:: /include/images/inc-diff-full-jobdata.*
26
27
28
29Depending on the retention periods, old jobs are removed to save space for newer backups:
30
31.. image:: /include/images/inc-diff-full-jobs_available-zoom.*
32
33
34
35The problem with this way of removing jobs is the fact that jobs are removed from the system which existing jobs depend on.
36
37Always Incremental Concept
38--------------------------
39
40The Always Incremental Backup Scheme does only incremental backups of clients, which reduces the amount of data transferred over the network to a minimum.
41
42.. limitation:: Always Incremental Backup: Only suitable for file based backups.
43
44   Always Incremental backups are only suitable for file based backups. Other data can not be combined on the server side (e.g. vmware plugings, NDMP, ...)
45
46
47
48
49The Always Incremental Backup Scheme works as follows:
50
51Client Backups are always run as incremental backups. This would usually lead to an unlimited chain of incremental backups that are depend on each other.
52
53To avoid this problem, existing incremental backups older than a configurable age are consolidated into a new backup.
54
55These two steps are then executed every day:
56
57-  Incremental Backup from Client
58
59-  Consolidation of the jobs older than maximum configure age
60
61Deleted files will be in the backup forever, if they are not detected as deleted using :config:option:`dir/job/Accurate`\  backup.
62
63The Always Incremental Backup Scheme does not provide the option to have other longer retention periods for the backups.
64
65For Longterm Storage of data longer than the Always Incremental Job Retention, there are two options:
66
67-  A copy job can be configured that copies existing full backups into a longterm pool.
68
69-  A virtual Full Job can be configured that creates a virtual full backup into a longterm pool consolidating all existing backups into a new one.
70
71The implementation with copy jobs is easy to implement and automatically copies all jobs that need to be copied in a single configured resource. The disadvantage of the copy job approach is the fact that at a certain point in time, the data that is copied for long term archive is already "always incremental job retention" old, so that the data in the longterm storage is not the current data that is available from the client.
72
73The solution using virtual full jobs to create longterm storage has the disadvantage, that for every backup job the a new longterm job needs to be created.
74
75The big advantage is that the current data will be transferred into the longterm storage.
76
77The way that bareos determines on what base the next incremental job will be done, would choose the longterm storage job to be taken as basis for the next incremental backup which is not what is intended. Therefore, the jobtype of the longterm job is updated to "archive", so that it is not taken as base for then next incrementals and the always incremental job will stand alone.
78
79How to configure in Bareos
80--------------------------
81
82Always Incremental Backup Job
83~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84
85To configure a job to use Always Incremental Backup Scheme, following configuration is required:
86
87.. code-block:: bareosconfig
88   :caption: bareos-dir.d/job/example.conf
89
90   Job {
91       ...
92       Accurate = yes
93       Always Incremental = yes
94       Always Incremental Job Retention = <timespec>
95       Always Incremental Keep Number = <number>
96       ...
97   }
98
99:config:option:`dir/job/Accurate = yes`\
100   is required to detect deleted files and prevent that they are kept in the consolidated backup jobs.
101
102:config:option:`dir/job/AlwaysIncremental = yes`\
103   enables the Always Incremental feature.
104
105:config:option:`dir/job/AlwaysIncrementalJobRetention`\
106   set the age where incrementals of this job will be kept, older jobs will be consolidated.
107
108:config:option:`dir/job/AlwaysIncrementalKeepNumber`\
109   sets the number of incrementals that will be kept without regarding the age. This should make sure that a certain history of a job will be kept even if the job is not executed for some time.
110
111:config:option:`dir/job/AlwaysIncrementalMaxFullAge`\
112   is described later, see :ref:`section-AlwaysIncrementalMaxFullAge`.
113
114Consolidate Job
115~~~~~~~~~~~~~~~
116
117.. code-block:: bareosconfig
118   :caption: bareos-dir.d/job/Consolidate.conf
119
120   Job {
121       Name = "Consolidate"
122       Type = "Consolidate"
123       Accurate = "yes"
124       JobDefs = "DefaultJob"
125   }
126
127:config:option:`dir/job/Type = Consolidate`\
128   configures a job to be a consolidate job. This type have been introduced with the Always Incremental feature. When used, it automatically trigger the consolidation of incremental jobs that need to be consolidated.
129
130:config:option:`dir/job/Accurate = yes`\
131   let the generated virtual backup job keep the accurate information.
132
133:config:option:`dir/job/MaxFullConsolidations`\
134   is described later, see :ref:`section-MaxFullConsolidations`.
135
136The :config:option:`dir/job = Consolidate`\  job evaluates all jobs configured with :config:option:`dir/job/AlwaysIncremental = yes`\ . When a job is selected for consolidation, all job runs are taken into account, independent of the pool and storage where they are located.
137
138The always incremental jobs need to be executed during the backup window (usually at night), while the consolidation jobs should be scheduled during the daytime when no backups are executed.
139
140
141
142.. warning::
143
144   All Bareos job resources have some required directives, e.g. :config:option:`dir/job/Client`\ .
145   Even so, none other than the mentioned directives are evaluated by a :config:option:`dir/job/Type = Consolidate`\ ,
146   they still have to be defined.
147   Normally all required directives are already set in :config:option:`dir/job/JobDefs = DefaultJob`\ .
148   If not, you have to add them. You can use arbitrary, but valid values.
149
150Storages and Pools
151~~~~~~~~~~~~~~~~~~
152
153For the Always Incremental Backup Scheme at least two storages are needed. See :ref:`section-MultipleStorageDevices` how to setup multiple storages.
154
155.. code-block:: bareosconfig
156   :caption: bareos-dir.d/pool/AI-Incremental.conf
157
158   Pool {
159     Name = AI-Incremental
160     Pool Type = Backup
161     Recycle = yes                       # Bareos can automatically recycle Volumes
162     Auto Prune = yes                    # Prune expired volumes
163     Volume Retention = 360 days         # How long should jobs be kept?
164     Maximum Volume Bytes = 50G          # Limit Volume size to something reasonable
165     Label Format = "AI-Incremental-"
166     Volume Use Duration = 23h
167     Storage = File1
168     Next Pool = AI-Consolidated         # consolidated jobs go to this pool
169   }
170
171.. code-block:: bareosconfig
172   :caption: bareos-dir.d/pool/AI-Consolidated.conf
173
174   Pool {
175     Name = AI-Consolidated
176     Pool Type = Backup
177     Recycle = yes                       # Bareos can automatically recycle Volumes
178     Auto Prune = yes                    # Prune expired volumes
179     Volume Retention = 360 days         # How long should jobs be kept?
180     Maximum Volume Bytes = 50G          # Limit Volume size to something reasonable
181     Label Format = "AI-Consolidated-"
182     Volume Use Duration = 23h
183     Storage = File2
184     Next Pool = AI-Longterm             # copy jobs write to this pool
185   }
186
187.. code-block:: bareosconfig
188   :caption: bareos-dir.d/pool/AI-Longterm.conf
189
190   Pool {
191     Name = AI-Longterm
192     Pool Type = Backup
193     Recycle = yes                       # Bareos can automatically recycle Volumes
194     Auto Prune = yes                    # Prune expired volumes
195     Volume Retention = 10 years         # How long should jobs be kept?
196     Maximum Volume Bytes = 50G          # Limit Volume size to something reasonable
197     Label Format = "AI-Longterm-"
198     Volume Use Duration = 23h
199     Storage = File1
200   }
201
202:config:option:`dir/pool = AI-Longterm`\  is optional and will be explained in :ref:`section-AlwaysIncrementalLongTermStorage`.
203
204
205.. warning::
206
207   Please note that the :config:option:`dir/pool/Volume Retention` should be
208   set to a **very high** value. This means that the value needs to be higher
209   than the maximum time that a job might be kept on a volume during the always
210   incremental backup scheme.  The value needs to be more than
211   :config:option:`dir/job/AlwaysIncrementalMaxFullAge`.
212
213   We suggest to set :config:option:`dir/pool/Volume Retention` to one year or
214   2-3 times the :config:option:`dir/job/AlwaysIncrementalMaxFullAge`.
215   This makes sure that the jobs being stored on the volumes are not pruned
216   prematurely.
217
218   When performing the always incremental scheme, the jobs are **never** pruned
219   by the volume pruning mechanism. The jobs are pruned from the volumes after
220   they have been successfully consolidated, so that the volume pruning
221   mechanism should **not trigger at all**.
222
223How it works
224------------
225
226The following configuration extract shows how a client backup is configured for always incremental Backup. The Backup itself is scheduled every night to run as incremental backup, while the consolidation is scheduled to run every day.
227
228.. code-block:: bareosconfig
229   :caption: bareos-dir.d/job/BackupClient1.conf
230
231   Job {
232       Name = "BackupClient1"
233       JobDefs = "DefaultJob"
234
235       # Always incremental settings
236       AlwaysIncremental = yes
237       AlwaysIncrementalJobRetention = 7 days
238
239       Accurate = yes
240
241       Pool = AI-Incremental
242       Full Backup Pool = AI-Consolidated
243   }
244
245.. code-block:: bareosconfig
246   :caption: bareos-dir.d/job/Consolidate.conf
247
248   Job {
249       Name = "Consolidate"
250       Type = "Consolidate"
251       Accurate = "yes"
252       JobDefs = "DefaultJob"
253   }
254
255The following image shows the available backups for each day:
256
257.. image:: /include/images/always-incremental.*
258
259
260
261-  The backup cycle starts with a full backup of the client.
262
263-  Every day a incremental backup is done and is additionally available.
264
265-  When the age of the oldest incremental reaches :config:option:`dir/job/AlwaysIncrementalJobRetention`\ , the consolidation job consolidates the oldest incremental with the full backup before to a new full backup.
266
267This can go on more or less forever and there will be always an incremental history of :config:option:`dir/job/AlwaysIncrementalJobRetention`\ .
268
269The following plot shows what happens if a job is not run for a certain amount of time.
270
271.. image:: /include/images/always-incremental-with-pause-7days-retention-no-keep.*
272
273
274
275As can be seen, the nightly consolidation jobs still go on consolidating until the last incremental is too old and then only one full backup is left. This is usually not what is intended.
276
277For this reason, the directive :config:option:`dir/job/AlwaysIncrementalKeepNumber`\  is available which sets the minimum number of incrementals that should be kept even if they are older than :config:option:`dir/job/AlwaysIncrementalJobRetention`\ .
278
279Setting :config:option:`dir/job/AlwaysIncrementalKeepNumber`\  to 7 in our case leads to the following result:
280
281.. image:: /include/images/always-incremental-with-pause-7days-retention-7days-keep.*
282
283
284
285:config:option:`dir/job/AlwaysIncrementalKeepNumber`\  incrementals are always kept, and when the backup starts again the consolidation of old incrementals starts again.
286
287Enhancements for the Always Incremental Backup Scheme
288-----------------------------------------------------
289
290Besides the available backups at each point in time which we have considered until now, the amount of data being moved during the backups is another very important aspect.
291
292We will have a look at this aspect in the following pictures:
293
294The basic always incremental scheme
295~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296
297The basic always incremental scheme does an incremental backup from the client daily which is relatively small and as such is very good.
298
299During the consolidation, each day the full backup is consolidated with the oldest incremental backup, which means that more or less the full amount of data being stored on the client is moved. Although this consolidation only is performed locally on the storage daemon without client interaction, it is still an enormous amount of data being touched and can take an considerable amount of time.
300
301If all clients use the "always incremental" backup scheme, this means that the complete data being stored in the backup system needs to be moved every day!
302
303This is usually only feasible in relatively small environments.
304
305The following figure shows the Data Volume being moved during the normal always incremental scheme.
306
307-  The red bar shows the amount of the first full backup being copied from the client.
308
309-  The blue bars show the amount of the daily incremental backups. They are so little that the can be barely seen.
310
311-  The green bars show the amount of data being moved every day during the consolidation jobs.
312
313.. image:: /include/images/always-incremental-jobdata.*
314
315
316
317.. _section-AlwaysIncrementalMaxFullAge:
318
319Always Incremental Max Full Age
320~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321
322To be able to cope with this problem, the directive :config:option:`dir/job/AlwaysIncrementalMaxFullAge`\  was added. When :config:option:`dir/job/AlwaysIncrementalMaxFullAge`\  is configured, in daily operation the Full Backup is left untouched while the incrementals are consolidated as usual. Only if the Full Backup is older than :config:option:`dir/job/AlwaysIncrementalMaxFullAge`\ , the full backup will also be part of
323the consolidation.
324
325Depending on the setting of the :config:option:`dir/job/AlwaysIncrementalMaxFullAge`\ , the amount of daily data being moved can be reduced without losing the advantages of the always incremental Backup Scheme.
326
327:config:option:`dir/job/AlwaysIncrementalMaxFullAge`\  must be larger than :config:option:`dir/job/AlwaysIncrementalJobRetention`\ .
328
329The resulting interval between full consolidations when running daily backups and daily consolidations is :config:option:`dir/job/AlwaysIncrementalMaxFullAge`\  - :config:option:`dir/job/AlwaysIncrementalJobRetention`\ .
330
331
332
333.. figure:: /include/images/always-incremental-jobdata-AlwaysIncrementalMaxFullAge_21_days.*
334   :alt: Data Volume being moved with "Always Incremental Max Full Age"
335
336   Data Volume being moved with "Always Incremental Max Full Age"
337
338
339
340.. figure:: /include/images/always-incremental-jobs_available-AlwaysIncrementalMaxFullAge_21_days.*
341   :alt: Jobs Available with "Always Incremental Max Full Age"
342
343   Jobs Available with "Always Incremental Max Full Age"
344
345.. _section-MaxFullConsolidations:
346
347Max Full Consolidations
348~~~~~~~~~~~~~~~~~~~~~~~
349
350When the :config:option:`dir/job/AlwaysIncrementalMaxFullAge`\  of many clients is set to the same value, it is probable that all full backups will reach the :config:option:`dir/job/AlwaysIncrementalMaxFullAge`\  at once and so consolidation jobs including the full backup will be started for all clients at once. This would again mean that the whole data being stored from all clients will be moved in one day.
351
352The following figure shows the amount of data being copied by the virtual jobs that do the consolidation when having 3 identically configured backup jobs:
353
354.. image:: /include/images/jobdata_multiple_clients.*
355
356
357
358As can be seen, virtual jobs including the full are triggered for all three clients at the same time.
359
360This is of course not desirable so the directive :config:option:`dir/job/MaxFullConsolidations`\  was introduced.
361
362:config:option:`dir/job/MaxFullConsolidations`\  needs to be configured in the :config:option:`dir/job/Type = Consolidate`\  job:
363
364.. code-block:: bareosconfig
365   :caption: bareos-dir.d/job/Consolidate.conf
366
367   Job {
368       Name = "Consolidate"
369       Type = "Consolidate"
370       Accurate = "yes"
371       JobDefs = "DefaultJob"
372
373       Max Full Consolidations = 1
374   }
375
376If :config:option:`dir/job/MaxFullConsolidations`\  is configured, the consolidation job will not start more than the specified Consolidations that include the Full Backup.
377
378This leads to a better load balancing of full backup consolidations over different days. The value should configured so that the consolidation jobs are completed before the next normal backup run starts.
379
380The number of always incremental jobs, the interval that the jobs are triggered and the setting of :config:option:`dir/job/AlwaysIncrementalMaxFullAge`\  influence the value that makes sense for :config:option:`dir/job/MaxFullConsolidations`\ .
381
382
383
384.. figure:: /include/images/jobdata_multiple_clients_maxfullconsilidate.*
385   :alt: Data Volume being moved with Max Full Consolidations = 1
386
387   Data Volume being moved with Max Full Consolidations = 1
388
389
390
391.. figure:: /include/images/jobs_available_multiple_clients_maxfullconsolidate.*
392   :alt: Jobs Available with Max Full Consolidations = 1
393
394   Jobs Available with Max Full Consolidations = 1
395
396.. _section-AlwaysIncrementalLongTermStorage:
397
398Long Term Storage of Always Incremental Jobs
399--------------------------------------------
400
401What is missing in the always incremental backup scheme in comparison to the traditional "Incremental Differential Full" scheme is the option to store a certain job for a longer time.
402
403When using always incremental, the usual maximum age of data stored during the backup cycle is :config:option:`dir/job/AlwaysIncrementalJobRetention`\ .
404
405Usually, it is desired to be able to store a certain backup for a longer time, e.g. monthly a backup should be kept for half a year.
406
407There are two options to achieve this goal.
408
409Copy Jobs
410~~~~~~~~~
411
412The configuration of archiving via copy job is simple, just configure a copy job that copies over the latest full backup at that point in time.
413
414As all full backups go into the :config:option:`dir/pool = AI-Consolidated`\ , we just copy all uncopied backups in the :config:option:`dir/pool = AI-Consolidated`\  to a longterm pool:
415
416.. code-block:: bareosconfig
417   :caption: bareos-dir.d/job/CopyLongtermFull.conf
418
419   Job {
420     Name = "CopyLongtermFull"
421     Schedule = LongtermFull
422     Type = Copy
423     Level = Full
424     Pool = AI-Consolidated
425     Selection Type = PoolUncopiedJobs
426     Messages = Standard
427   }
428
429As can be seen in the plot, the copy job creates a copy of the current full backup that is available and is already 7 days old.
430
431.. image:: /include/images/always-incremental-copy-job-archiving.*
432
433
434
435The other disadvantage is, that it copies all jobs, not only the virtual full jobs. It also includes the virtual incremental jobs from this pool.
436
437Virtual Full Jobs
438~~~~~~~~~~~~~~~~~
439
440The alternative to Copy Jobs is creating a virtual Full Backup Job when the data should be stored in a long-term pool.
441
442.. code-block:: bareosconfig
443   :caption: bareos-dir.d/job/VirtualLongtermFull.conf
444
445   Job {
446     Name = "VirtualLongtermFull"
447     Client = bareos-fd
448     FileSet = SelfTest
449     Schedule = LongtermFull
450     Type = Backup
451     Level = VirtualFull
452     Pool = AI-Consolidated
453     Messages = Standard
454
455     Priority = 13                 # run after  Consolidate
456     Run Script {
457           console = "update jobid=%i jobtype=A"
458           Runs When = After
459           Runs On Client = No
460           Runs On Failure = No
461     }
462   }
463
464To make sure the longterm :config:option:`dir/job/Level = VirtualFull`\  is not taken as base for the next incrementals, the job type of the copied job is set to :config:option:`dir/job/Type = Archive`\  with the :config:option:`dir/job/RunScript`\ .
465
466As can be seen on the plot, the :config:option:`dir/job/Level = VirtualFull`\  archives the current data, i.e. it consolidates the full and all incrementals that are currently available.
467
468.. image:: /include/images/always-incremental-virtualfull-job-archiving.*
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483