This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
/
howto.tex
781 lines (674 loc) · 28.2 KB
/
howto.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
\section{Use a dummy device to test the backup}
\label{testbackup}
If your are testing your configuration, but don't want to store the backup data,
it is possible to use a dummy FIFO device to test your configuration, see \ilink{Stored configuration}{SetupFifo}.
Obviously, it can not be used to do a restore.
\footnotesize
\begin{verbatim}
Device {
Name = NULL
Media Type = NULL
Device Type = Fifo
Archive Device = /dev/null
LabelMedia = yes
Random Access = no
AutomaticMount = no
RemovableMedia = no
MaximumOpenWait = 60
AlwaysOpen = no
}
\end{verbatim}
\normalsize
\section{Backup Of Third Party Databases}
\index[general]{Backup Of Third Party Databases}
\index[general]{Database!Backup Of Third Party}
\label{BackupOtherDBs}
If you are running a database in production mode on your machine, Bareos will
happily backup the files, but if the database is in use while Bareos is
reading it, you may back it up in an unstable state.
The best solution is to shutdown your database before backing it up, or use
some tool specific to your database to make a valid live copy perhaps by
dumping the database in ASCII format.
\subsection{Backup Of MSSQL Databases with Bareos Plugin}
\index[general]{MSSQL Backup}
\index[general]{Database!MSSQL}
\label{MSSQL}
\sinceVersion{general}{MSSQL}{13.2}
\subsubsection {Preparation}
If you like to use the MSSQL-Plugin to backing up your Databases you need to consider some things:
\begin{itemize}
\item {\bf Database Mode}\\
The database need to run in {\bf Full Recovery Mode}. Otherwise you are not able to use differential and incremental backups or to use point in time recovery.\\
\warning{If you set the databases into the mentionend mode you have to consider some maintance facts. The database doesn't shrink or delete the logs unanttended, so you have to shrink them manual once a week and you have to truncate the logs once in a month.}
\item {\bf Security and Access}\\
For connections you can use a SQL-User or a integrated systemaccount (Windows NT user). Both connection types are supported.
\begin{itemize}
\item Standard Security \\
You have to provide user credentials within your options which do belong to user with the sufficent right performing restores and backups from the database. This way stands for an extra backup/restore user.
\item Trusted Security \\
You use a systemaccount which have the sufficent rights to performing backups and restores on a database. This systemaccount have to be same account like the {\bf bareos-filedeamon} runs on.
\end{itemize}
\item{\bf Permissions and Roles}
\begin{itemize}
\item Server-Role\\
The user should be in the groups {\bf sysadmin} and {\bf dbcreator}.
\item Database permissions\\
The user have to be a {\bf backupoperator} and {\bf dbowner} of the database which you like to backup.
\end{itemize}
\end{itemize}
There is no difference for the rights and roles between using a systemaccount (trusted security method) or a extra backup user (standard security method).
Please keep in mind if you use the trusted security method you have to use the same system account like the bareos-filedeamon runs on.
\subsubsection{MSSQL Plugin Installation}
\label{MssqlPluginInstallation}
\paragraph{Bareos Windows-Installer}
Install the bareos fileadaemon on the MSSQL server computer and install also the component "Bareos FileDameon Plugins".
Make sure, that you install the file daemon {\bf without the "compatible" option}.\\
\paragraph{Manual install}
After downloading the plugin you need to copy it into \path|C:\Program Files\Bareos\Plugins|.
Then you need to define the plugin directory and which plugin the {\bf bareos-filedaemon} should use.
You have to edit the {\bf bareos-filedaemon} ressource in \path|C:\Program Data\bareos-fd.conf| as followed.\\
\begin{bconfig}{MSSQL plugin configuration}
FileDaemon {
Name = mssqlserver-fd
Maximum Concurrent Jobs = 20
# remove comment in next line to load plugins from specified directory
Plugin Directory = "C:/Program Files/Bareos/Plugins"
# if compatible is set to yes, we are compatible with bacula
# if you want to use new bareos features, please set compatible to no
Plugin Names = "mssqlvdi"
compatible = no
}
\end{bconfig}
%\warning{The Bareos filedaemon and Bareos director have to be the same version.}
\subsubsection{Plugin Test}
\begin{bconsole}{status client=mssqlserver-fd}
*<input>status client=mssqlserver-fd</input>
Connecting to Client mssqlserver-fd at 192.168.10.101:9102
mssqlserver-fd Version: 13.2.2 (12 November 2013) VSS Linux Cross-compile Win64
Daemon started 18-Nov-13 11:51. Jobs: run=0 running=0.
Microsoft Windows Server 2012 Standard Edition (build 9200), 64-bit
Heap: heap=0 smbytes=20,320 max_bytes=20,522 bufs=71 max_bufs=73
Sizeof: boffset_t=8 size_t=8 debug=0 trace=1 bwlimit=0kB/s
Plugin Info:
Plugin : mssqlvdi-fd.dll
Description: Bareos MSSQL VDI Windows File Daemon Plugin
Version : 1, Date: July 2013
Author : Zilvinas Krapavickas
License : Bareos AGPLv3
Usage :
mssqlvdi:
instance=<instance name>:
database=<database name>:
username=<database username>:
password=<database password>:
norecovery=<yes|no>:
replace=<yes|no>:
recoverafterrestore=<yes|no>:
stopbeforemark=<log sequence number specification>:
stopatmark=<log sequence number specification>:
stopat=<timestamp>
examples:
timestamp: 'Apr 15, 2020 12:00 AM'
log sequence number: 'lsn:15000000040000037'
\end{bconsole}
\subsubsection{Configure the FileSet}
\index[general]{Backupconfiguration}
\label{filesetconfig}
To use the plugin you need to configure it in the fileset as a plugin ressource. For each database instance you need to define a exclusive backup job and fileset.
\begin{bconfig}{MSSQL FileSet}
Fileset {
Name = "Mssql"
Enable VSS = no
Include {
Options {
Signature = MD5
}
Plugin = "mssqlvdi:instance=default:database=myDatabase:username=bareos:password=bareos"
}
}
\end{bconfig}
In this example we use the standard security method for the connection.
Used options in the plugin string are:
\begin{description}
\item[mssqlvdi]
This is the reference to the MSSQL plugin.
\item[instance] Defines the instance within the database server.
\item[database] Defines the database that should get backuped.
\item[username and password] Username and Password are required, when the connection is done using a MSSQL user. If the systemaccount the bareos-fd runs with has succifient permissions, this is not required.
\end{description}
It is recommend to define an additional restore job.
For every database seperat job and FileSet are required.
\subsubsection{Run Backups}
Here you can see an example for a backup:
\begin{bconsole}{run MSSQL backup job}
*<input>run job=MSSQLBak</input>
Using Catalog "MyCatalog"
Run Backup job
JobName: MSSQLBak
Level: Full
Client: mssqlserver-fd
Format: Native
FileSet: Mssql
Pool: File (From Job resource)
Storage: File (From Job resource)
When: 2013-11-21 09:48:27
Priority: 10
OK to run? (yes/mod/no): <input>yes</input>
Job queued. JobId=7
You have no messages.
*<input>mess</input>
21-Nov 09:48 bareos-dir JobId 7: Start Backup JobId 7, Job=MSSQLBak.2013-11-21_09.48.30_04
21-Nov 09:48 bareos-dir JobId 7: Using Device "FileStorage" to write.
21-Nov 09:49 bareos-sd JobId 7: Volume "test1" previously written, moving to end of data.
21-Nov 09:49 bareos-sd JobId 7: Ready to append to end of Volume "test1" size=2300114868
21-Nov 09:49 bareos-sd JobId 7: Elapsed time=00:00:27, Transfer rate=7.364 M Bytes/second
21-Nov 09:49 bareos-dir JobId 7: Bareos bareos-dir 13.4.0 (01Oct13):
Build OS: x86_64-pc-linux-gnu debian Debian GNU/Linux 7.0 (wheezy)
JobId: 7
Job: MSSQLBak.2013-11-21_09.48.30_04
Backup Level: Full
Client: "mssqlserver-fd" 13.2.2 (12Nov13) Microsoft Windows Server 2012 Standard Edition (build 9200), 64-bit,Cross-compile,Win64
FileSet: "Mssql" 2013-11-04 23:00:01
Pool: "File" (From Job resource)
Catalog: "MyCatalog" (From Client resource)
Storage: "File" (From Job resource)
Scheduled time: 21-Nov-2013 09:48:27
Start time: 21-Nov-2013 09:49:13
End time: 21-Nov-2013 09:49:41
Elapsed time: 28 secs
Priority: 10
FD Files Written: 1
SD Files Written: 1
FD Bytes Written: 198,836,224 (198.8 MB)
SD Bytes Written: 198,836,435 (198.8 MB)
Rate: 7101.3 KB/s
Software Compression: None
VSS: no
Encryption: no
Accurate: no
Volume name(s): test1
Volume Session Id: 1
Volume Session Time: 1384961357
Last Volume Bytes: 2,499,099,145 (2.499 GB)
Non-fatal FD errors: 0
SD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Backup OK
\end{bconsole}
At least you gain a full backup which contains the follow:
\footnotesize
\begin{verbatim}
@MSSQL/
@MSSQL/default/
@MSSQL/default/myDatabase/
@MSSQL/default/myDatabase/db-full
\end{verbatim}
\normalsize
So if you perform your first full backup your are capable to perfom differntial and incremental backups.\\
Differntial FileSet example:
\footnotesize
\begin{verbatim}
/@MSSQL/
/@MSSQL/default/
/@MSSQL/default/myDatabase/
/@MSSQL/default/myDatabase/db-full
/@MSSQL/default/myDatabase/db-diff
\end{verbatim}
\normalsize
Incremental FileSet example:
\footnotesize
\begin{verbatim}
*@MSSQL/
*default/
*myDatabase/
*db-diff
*db-full
*log-2013-11-21 17:32:20
\end{verbatim}
\normalsize
\subsubsection{Restores}
If you want to perfom a restore of a full backup without differentials or incrementals you have some options which helps you to restore even the corrupted database still exist. But you have to specifiy the options like plugin, instance and database during every backup.
\begin{description}
\item[replace=\textless yes|no\textgreater]
With this option you can replace the database if it still exist.
\item[instance]
Defines the server instance whithin the database is running.
\item[database]
Defines the database you want to backup.
\end{description}
Example for a full restore:
\begin{bconsole}{restore MSSQL database}
*<input>restore client=mssqlserver-fd</input>
Using Catalog "MyCatalog"
First you select one or more JobIds that contain files
to be restored. You will be presented several methods
of specifying the JobIds. Then you will be allowed to
select which files from those JobIds are to be restored.
To select the JobIds, you have the following choices:
1: List last 20 Jobs run
2: List Jobs where a given File is saved
3: Enter list of comma separated JobIds to select
4: Enter SQL list command
5: Select the most recent backup for a client
6: Select backup for a client before a specified time
7: Enter a list of files to restore
8: Enter a list of files to restore before a specified time
9: Find the JobIds of the most recent backup for a client
10: Find the JobIds for a backup for a client before a specified time
11: Enter a list of directories to restore for found JobIds
12: Select full restore to a specified Job date
13: Cancel
Select item: (1-13): <input>5</input>
Automatically selected FileSet: Mssql
+-------+-------+----------+-------------+---------------------+------------+
| JobId | Level | JobFiles | JobBytes | StartTime | VolumeName |
+-------+-------+----------+-------------+---------------------+------------+
| 8 | F | 1 | 198,836,224 | 2013-11-21 09:52:28 | test1 |
+-------+-------+----------+-------------+---------------------+------------+
You have selected the following JobId: 8
Building directory tree for JobId(s) 8 ...
1 files inserted into the tree.
You are now entering file selection mode where you add (mark) and
remove (unmark) files to be restored. No files are initially added, unless
you used the "all" keyword on the command line.
Enter "done" to leave this mode.
cwd is: /
$ <input>mark *</input>
1 file marked.
$ <input>done</input>
Bootstrap records written to /var/lib/bareos/bareos-dir.restore.4.bsr
The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================
test1 File FileStorage
Volumes marked with "*" are online.
1 file selected to be restored.
The defined Restore Job resources are:
1: RestoreMSSQL
2: RestoreFiles
Select Restore Job (1-2): <input>1</input>
Using Catalog "MyCatalog"
Run Restore job
JobName: RestoreMSSQL
Bootstrap: /var/lib/bareos/bareos-dir.restore.4.bsr
Where: /tmp
Replace: Always
FileSet: Mssql
Backup Client: mssqlserver-fd
Restore Client: mssqlserver-fd
Format: Native
Storage: File
When: 2013-11-21 17:12:05
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no): <input>mod</input>
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Restore Client
6: Backup Format
7: When
8: Priority
9: Bootstrap
10: Where
11: File Relocation
12: Replace
13: JobId
14: Plugin Options
Select parameter to modify (1-14): <input>14</input>
Please enter Plugin Options string: <input>mssqlvdi:instance=default:database=myDatabase:replace=yes</input>
Run Restore job
JobName: RestoreMSSQL
Bootstrap: /var/lib/bareos/bareos-dir.restore.4.bsr
Where: /tmp
Replace: Always
FileSet: Mssql
Backup Client: mssqlserver-fd
Restore Client: mssqlserver-fd
Format: Native
Storage: File
When: 2013-11-21 17:12:05
Catalog: MyCatalog
Priority: 10
Plugin Options: mssqlvdi:instance=default:database=myDatabase:replace=yes
OK to run? (yes/mod/no): <input>yes</input>
Job queued. JobId=10
You have messages.
*<input>mess</input>
21-Nov 17:12 bareos-dir JobId 10: Start Restore Job RestoreMSSQL.2013-11-21_17.12.26_11
21-Nov 17:12 bareos-dir JobId 10: Using Device "FileStorage" to read.
21-Nov 17:13 damorgan-sd JobId 10: Ready to read from volume "test1" on device "FileStorage" (/storage).
21-Nov 17:13 damorgan-sd JobId 10: Forward spacing Volume "test1" to file:block 0:2499099145.
21-Nov 17:13 damorgan-sd JobId 10: End of Volume at file 0 on device "FileStorage" (/storage), Volume "test1"
21-Nov 17:13 damorgan-sd JobId 10: End of all volumes.
21-Nov 17:13 bareos-dir JobId 10: Bareos bareos-dir 13.4.0 (01Oct13):
Build OS: x86_64-pc-linux-gnu debian Debian GNU/Linux 7.0 (wheezy)
JobId: 10
Job: RestoreMSSQL.2013-11-21_17.12.26_11
Restore Client: mssqlserver-fd
Start time: 21-Nov-2013 17:12:28
End time: 21-Nov-2013 17:13:21
Files Expected: 1
Files Restored: 1
Bytes Restored: 198,836,224
Rate: 3751.6 KB/s
FD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Restore OK
\end{bconsole}
\paragraph{Restore a Backup Chain}
If you like to restore a specific state or a whole chain consists of full, incremental and differential backups you need to use the "norecovery=yes" option. After this the database is in "recovery mode". You can also use a option which put the database right after the restore back into the right mode. If you like to restore certains point with protocols or
"LSN" it it not recommend to work with this option.
\begin{description}
\item[norecovery=\textless yes|no\textgreater]
This option must be set to yes, if the database server should not do a automatic recovery after the backup. Instead, additional manual maintenace operations are possible.
\item[recoverafterrestore=\textless yes|no\textgreater]
With this command the database is right after backup in the correct mode. If you not use this you have to use the followed tsql statement:
\footnotesize
\begin{verbatim}
Restore DATABASE yourDatabase WITH RECOVERY
GO
\end{verbatim}
\normalsize
\item[stopbeforemark=\textless log sequence number specification\textgreater]
used for point in time recovery.
\item[stopatmark=\textless log sequence number specification\textgreater]
used for point in time recovery.
\item[stopat=\textless timestamp\textgreater]
used for point in time recovery.
\end{description}
Followed is a example for a restore of full, differential and incremental backup with a replace of the original database:
\begin{bconsole}{restore MSSQL database chain}
*<input>restore client=mssqlserver-fd</input>
First you select one or more JobIds that contain files
to be restored. You will be presented several methods
of specifying the JobIds. Then you will be allowed to
select which files from those JobIds are to be restored.
To select the JobIds, you have the following choices:
1: List last 20 Jobs run
2: List Jobs where a given File is saved
3: Enter list of comma separated JobIds to select
4: Enter SQL list command
5: Select the most recent backup for a client
6: Select backup for a client before a specified time
7: Enter a list of files to restore
8: Enter a list of files to restore before a specified time
9: Find the JobIds of the most recent backup for a client
10: Find the JobIds for a backup for a client before a specified time
11: Enter a list of directories to restore for found JobIds
12: Select full restore to a specified Job date
13: Cancel
Select item: (1-13): <input>5</input>
Automatically selected FileSet: Mssql
+-------+-------+----------+-------------+---------------------+------------+
| JobId | Level | JobFiles | JobBytes | StartTime | VolumeName |
+-------+-------+----------+-------------+---------------------+------------+
| 8 | F | 1 | 198,836,224 | 2013-11-21 09:52:28 | test1 |
| 11 | D | 1 | 2,555,904 | 2013-11-21 17:19:45 | test1 |
| 12 | I | 1 | 720,896 | 2013-11-21 17:29:39 | test1 |
+-------+-------+----------+-------------+---------------------+------------+
You have selected the following JobIds: 8,11,12
Building directory tree for JobId(s) 8,11,12 ...
3 files inserted into the tree.
You are now entering file selection mode where you add (mark) and
remove (unmark) files to be restored. No files are initially added, unless
you used the "all" keyword on the command line.
Enter "done" to leave this mode.
cwd is: /
$ <input>mark *</input>
3 files marked.
$ <input>lsmark</input>
*@MSSQL/
*default/
*myDatabase/
*db-diff
*db-full
*log-2013-11-21 17:32:20
$ <input>done</input>
Bootstrap records written to /var/lib/bareos/bareos-dir.restore.6.bsr
The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================
test1 File FileStorage
Volumes marked with "*" are online.
1 file selected to be restored.
The defined Restore Job resources are:
1: RestoreMSSQL
2: RestoreFiles
Select Restore Job (1-2): <input>1</input>
Run Restore job
JobName: RestoreMSSQL
Bootstrap: /var/lib/bareos/bareos-dir.restore.6.bsr
Where: /tmp
Replace: Always
FileSet: Mssql
Backup Client: mssqlserver-fd
Restore Client: mssqlserver-fd
Format: Native
Storage: File
When: 2013-11-21 17:34:23
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no): <input>mod</input>
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Restore Client
6: Backup Format
7: When
8: Priority
9: Bootstrap
10: Where
11: File Relocation
12: Replace
13: JobId
14: Plugin Options
Select parameter to modify (1-14): <input>14</input>
Please enter Plugin Options string: <input>mssqlvdi:instance=default:database=myDatabase:replace=yes:norecovery=yes</input>
Run Restore job
JobName: RestoreMSSQL
Bootstrap: /var/lib/bareos/bareos-dir.restore.6.bsr
Where: /tmp
Replace: Always
FileSet: Mssql
Backup Client: mssqlserver-fd
Restore Client: mssqlserver-fd
Format: Native
Storage: File
When: 2013-11-21 17:34:23
Catalog: MyCatalog
Priority: 10
Plugin Options: mssqlvdi:instance=default:database=myDatabase:replace=yes:norecovery=yes
OK to run? (yes/mod/no): <input>yes</input>
Job queued. JobId=14
21-Nov 17:34 bareos-dir JobId 14: Start Restore Job RestoreMSSQL.2013-11-21_17.34.40_16
21-Nov 17:34 bareos-dir JobId 14: Using Device "FileStorage" to read.
21-Nov 17:35 damorgan-sd JobId 14: Ready to read from volume "test1" on device "FileStorage" (/storage).
21-Nov 17:35 damorgan-sd JobId 14: Forward spacing Volume "test1" to file:block 0:2499099145.
21-Nov 17:35 damorgan-sd JobId 14: End of Volume at file 0 on device "FileStorage" (/storage), Volume "test1"
21-Nov 17:35 damorgan-sd JobId 14: End of all volumes.
21-Nov 17:35 bareos-dir JobId 14: Bareos bareos-dir 13.4.0 (01Oct13):
Build OS: x86_64-pc-linux-gnu debian Debian GNU/Linux 7.0 (wheezy)
JobId: 14
Job: RestoreMSSQL.2013-11-21_17.34.40_16
Restore Client: mssqlserver-fd
Start time: 21-Nov-2013 17:34:42
End time: 21-Nov-2013 17:35:36
Files Expected: 1
Files Restored: 3
Bytes Restored: 202,113,024
Rate: 3742.8 KB/s
FD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Restore OK
\end{bconsole}
\hide{$}
\subsection{Backup of a PostgreSQL Database}
\index[general]{PostgreSQL Backup}
\index[general]{Database!PostgreSQL!Backup}
\label{backup-postgresql}
In this section, we describe different methods how to do a full backup of the PostgreSQL database.
\subsubsection{Backup of a PostgreSQL Database by using the RunBeforeJob directive}
\index[general]{RunScript!Example}
One method to backup a PostgreSQL database is to call a \configdirective{RunBeforeJob} script to dump the database into a file and than backup it as a normal file.
After the backup, the file can be removed by a \configdirective{RunAfterJob} script.
The RunBeforeJob directive is configured inside a Job Resource, e.g.:
\begin{bconfig}{RunBeforeJob job resource for a PostgreSQL backup}
Job {
Name = "BackupDatabase"
JobDefs = "DefaultJob"
Level = Full
FileSet="Database"
# This creates a dump of our database in the local filesystem
RunBeforeJob = "pg_dumpall -U postgres > /var/lib/bareos/postgresql_dump.sql"
# This deletes the dump in our local filesystem
RunAfterJob = "rm /var/lib/bareos/postgresql_dump.sql"
}
\end{bconfig}
The corresponding FileSet configuration should look something like this, e.g.:
\begin{bconfig}{FileSet for a PostgreSQL dump file}
FileSet {
Name = "Database"
Include {
Options {
signature = MD5
compression = gzip
}
# database dump file
File = "/var/lib/bareos/postgresql_dump.sql"
}
}
\end{bconfig}
\subsubsection{Backup of a PostgreSQL Databases by using the bpipe plugin}
\index[general]{bpipe!PostgreSQL backup}
Instead of creating a temporary database dump file,
the bpipe plugin can be used.
For general information about bpipe, see the \ilink{bpipe plugin}{bpipe} section.
The bpipe plugin is configured inside the Include section of a File Set, e.g.:
\begin{bconfig}{bpipe directive for PostgreSQL backup}
FileSet {
Name = "postgresql-all"
Include {
Plugin = "bpipe:/POSTGRESQL/dump.sql:pg_dumpall -U postgres:psql -U postgres"
Options {
signature = MD5
compression = gzip
}
}
}
\end{bconfig}
This causes the File Daemon to call bpipe plugin, which will write its data into the "pseudo" file \file{/POSTGRESQL/dump.sql} by
calling the program \command{pg_dumpall -U postgres} to read the data during backup. The \command{pg_dumpall} command outputs all
the data for the database, which will be read by the plugin and stored in the backup. During restore, the data that was backed up will
be sent to the program specified in the last field, which in this case is psql. When psql is called, it will read the data sent to it by
the plugin then write it back to the same database from which it came from.
This can also be used, to backup a database that is running on a remote host:
\begin{bconfig}{bpipe directive to backup a PostgreSQL database that is running on a remote host}
FileSet {
Name = "postgresql-remote"
Include {
Plugin = "bpipe:/POSTGRESQL/dump.sql:pg_dumpall -h <hostname> -U <username> -W <password>:psql -h <hostname> -U <username> -W <password>"
Options {
signature = MD5
compression = gzip
}
}
}
\end{bconfig}
\subsection{Backup of a MySQL Database}
\index[general]{MySQL Backup}
\index[general]{Database!MySQL!Backup}
\label{backup-mysql}
In this section, we describe different methods to do a full backup of a MySQL database.
\subsubsection{Backup of a MySQL Database by using the RunBeforeJob directive}
\index[general]{RunScript!Example}
One method to backup a MySQL database is to call a \configdirective{RunBeforeJob} script
to dump the database into a file and than backup it as a normal file.
After the backup, the file can be removed by a \configdirective{RunAfterJob} script.
The RunBeforeJob directive is configured inside a Job Resource, e.g.:
\begin{bconfig}{RunBeforeJob job resource for a MySQL backup}
Job {
Name = "BackupDatabase"
JobDefs = "DefaultJob"
Level = Full
FileSet="Database"
# This creates a dump of our database in the local filesystem
RunBeforeJob = "mysqldump --user=<username> --password=<password> --opt --all-databases > /var/lib/bareos/mysql_dump.sql"
# This deletes the dump in our local filesystem
RunAfterJob = "rm /var/lib/bareos/mysql_dump.sql"
}
\end{bconfig}
The correspondig FileSet configuration should look something like this, e.g.:
\begin{bconfig}{RunBeforeJob fileset MySQL dump}
FileSet {
Name = "Database"
Include {
Options {
signature = MD5
compression = gzip
}
# database dump file
File = "/var/lib/bareos/mysql_dump.sql"
}
}
\end{bconfig}
\subsubsection{Backup of a MySQL Databases by using the bpipe plugin}
\index[general]{bpipe!MySQL backup}
Instead of creating a temporary database dump file,
the bpipe plugin can be used.
For general information about bpipe, see the \ilink{bpipe plugin}{bpipe} section.
The bpipe plugin is configured inside the Include section of a File Set, e.g.:
\begin{bconfig}{bpipe fileset for MySQL backup}
FileSet {
Name = "mysql-all"
Include = {
Plugin = "bpipe:/MYSQL/dump.sql:mysqldump --user=<user> --password=<password> --opt --all-databases:mysql --user=<user> --password=<password>"
Options {
signature = MD5
compression = gzip
}
}
}
\end{bconfig}
This can also be used, to backup a database that is running on a remote host:
\begin{bconfig}{bpipe directive to backup a MySQL database that is running on a remote host}
FileSet{
Name = "mysql-all"
Include {
Plugin = "bpipe:/MYSQL/dump.sql:mysqldump --host=<hostname> --user=<user> --password=<password> --opt --all-databases:mysql --host=<hostname> --user=<user> --password=<password>"
Options {
signature = MD5
compression = gzip
}
}
}
\end{bconfig}
If you do not want a direct restore of your data in your plugin directive, as shown in the examples above,
there is the possibility to restore the dump to the filesystem first, which offers you more control over the restore process, e.g.:
\begin{bconfig}{bpipe directive to backup a MySQL database and restore the dump to the filesystem first}
FileSet{
Name = "mysql-all"
Include {
Plugin = "bpipe:/MYSQL/dump.sql:mysqldump --host=<hostname> --user=<user> --password=<password> --opt --all-databases:/usr/lib/bareos/scripts/bpipe-restore.sh"
Options {
signature = MD5
compression = gzip
}
}
}
\end{bconfig}
A very simple corresponding shell script (bpipe-restore.sh) to the method above might look like the following one:
\begin{bconfig}{bpipe shell script for a restore to filesystem}
#!/bin/bash
cat - > /tmp/dump.sql
exit 0
\end{bconfig}