Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ndmp.tex « main « en « manuals - github.com/bareos/bareos-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: af9d6561c302dc0523e6bea00f2703e15b77ecc8 (plain)
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
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
\index[general]{NDMP!Overview}

\section{NDMP Basics}

NDMP
\begin{itemize}
    \item is the abbreviation for Network Data Management Protocol.
    \item is a protocol that transports data between Network Attached Storages (NAS) and backup devices.
    \item is widely used by storage product vendors and OS vendors like NetApp, Isilon, EMC, Oracle.
    \item information is available at \url{http://www.ndmp.org/}.
    \item version is currently (2016) NDMP Version 4.
    \item uses TCP/IP and XDR (External Data Representation) for the communication.
\end{itemize}



The Bareos NDMP implementation is based on the NDMJOB NDMP reference implementation of Traakan, Inc., Los Altos, CA which has a BSD style license (2 clause one) with some enhancements.
% Technical details can be found in README.NDMP in the bareos sourcecode.


In NDMP, there are different components (called \bquote{agents}) involved in doing backups.
The most important agents are:

\begin{description}
  \item[Data Management Agent (DMA)]
  is the part that controls the NDMP backup or recover operation.
    %does the administration of the backup in NDMP and commands the Primary and Secondary Storage Systems to do a backup or restore operation.

  \item[Data Agent] (or Primary Storage System)
  is the part that reads the data from the Filesystem during Backup and writes data to the Filesystem during recover.
    %is the Storage System that will be backed up, e.g. a NAS Server that is NDMP enabled.

  \item[Tape Agent] (or Secondary Storage System)
  is the part that writes NDMP blocks to the Tape during backup and reads them during recover.
    %is the Storage System that the backup data will be stored on.

  \item[Robot Agent]
  is the part that controls the media changer. It loads/unloads tapes and gets the inventory of the Changer. The use of a robot agent is optional. It is possible to run backups on a single tape drive.
\end{description}

All elements involved talk to each other via the NDMP protocol which is usually transported via TCP/IP port 10000.


The \DataManagementAgent is part of the Backup Application.

The \DataAgent is part of the (NAS)-System being backed up and recovered.

The \TapeAgent and \RobotAgent can
\begin{itemize}
    \item run on the system being backed up
    \item run as part of the backup application
    \item or even run independently on a third system
\end{itemize}

This flexibility leads to different topologies how NDMP backups can be done.

\subsection{NDMP Topologies}

When looking at the different topologies, the location of the \RobotAgent is not specially considered,
as the data needed to control the robot is minimal compared to the backup data.

So the parts considered are
\begin{itemize}
  \item the \DataManagementAgent controlling the operation
  \item the \DataAgent as source of the backup data and
  \item the \TapeAgent as destination of the backup data
\end{itemize}



The \DataManagementAgent always controls both \DataAgent and \TapeAgent over the Network via NDMP.

The \TapeAgent can either
\begin{itemize}
    \item run on a separate system
    \item run on the same system
\end{itemize}
as the Data Agent.


\subsubsection{NDMP 3-way Backup: Data Agent and Tape Agent running on different systems}

\begin{verbatim}
   --+--------------- NETWORK ----+-------------------+----
     |    -->---->---->-->-->-->\ | //==>==>==>==>\\  |
     |   /                      | | ||      (2)   ||  |
     |   |                      | | ||            ||  |
/----------\                 /----------\     /----------\
|          |                 |          |     |          |
|   DMA    |        DISK====>|   DATA   |     |   Tape   |====>TAPE DRIVE
|          |             (1) |   Agent  |     |   Agent  | (3)
\----------/                 \----------/     \----------/
\end{verbatim}


The data path consists of three ways
\begin{itemize}
    \item From Disk to Data Agent (1)
    \item From Data Agent over the Network to the Tape Agent (2)
    \item From Tape Agent to the Tape (3)
\end{itemize}

and is called NDMP 3-way Backup.


\subsubsection{NDMP 2-way Backup: Data Agent and Tape Agent running on the same system}


\begin{verbatim}
   --+--------------- NETWORK ----+---------
     |    -->---->---->-->-->-->\ |
     |   /                      | |
     |   |                      | |
/----------\                 /----------\
|          |                 | Data     |
|   DMA    |        DISK====>| Agent    |
|          |             (1) |          |
\----------/                 |    Tape  | (2)
                             |    Agent |====>TAPE DRIVE
                             \----------/
\end{verbatim}


\DataAgent and \TapeAgent are both part of the same process on the system,
so the data path consists of two ways:
\begin{itemize}
    \item From Disk to Data Agent (1)
    \item From Tape Agent to the Tape (2)
\end{itemize}
and is called NDMP 2-way Backup, also sometimes referred as NDMP local backup.


\subsubsection{Properties of the different NDMP Backup topologies}


NDMP 3-way backup:
\begin{itemize}
  \item  The data can be send to a different location over the network
  \item  No need to attach a tape drive to the NAS system.
  \item The backup speed is usually slower than with 2-way backup as the data is being sent over the network and processed multiple times.
\end{itemize}



NDMP 2-way backup:
\begin{itemize}
  \item The data is directly copied from the NAS system to the Tape
  \item Usually the fastest way to do a NDMP backup
  \item tape drives need to be attached to the NAS System
\end{itemize}



\section{NDMP Backup in Bareos}

Bareos offers two types of NDMP integration:

\begin{description}
    \item[NDMP\_NATIVE]
    \item[NDMP\_BAREOS]
\end{description}

In both cases,
\begin{itemize}
    \item \bareosDir acts as \DataManagementAgent.
    \item The \DataAgent is part of the storage system
and must be provided by the storage vendor.
\end{itemize}

The main difference is which \TapeAgent is used.

When using NDMP\_BAREOS, the \bareosSd acts as \TapeAgent.

When using NDMP\_NATIVE, the \TapeAgent must be provided by some other systems.
Some storage vendors provide it with there storages, or offer it as an option,
e.g. Isilon with their \bquote{Isilon Backup Accelerator}.


\begin{center}
\begin{tabular}{l | c | c}
\hline
                             & NDMP\_NATIVE    & NDMP\_BAREOS \\
\hline
\DataManagementAgent         & \bareosDir      & \bareosDir \\
\TapeAgent                   & external        & \bareosSd \\
requires external \TapeAgent & \bcheckmark     &             \\
backup to tape (and VTL)     & \bcheckmark     & \bcheckmark \\
backup to other \linkResourceDirective{Sd}{Device}{Device Type}
                             &                 & \bcheckmark \\
2-way backup                 & \bcheckmark     &             \\
3-way backup                 & untested        & \bcheckmark \\
Full Backups                 & \bcheckmark     & \bcheckmark \\
Differential Backups         & \bcheckmark     & \bcheckmark \\
Incremental Backups          & \cmlink{sec:NdmpBackupLevel} (8) & \cmlink{sec:NdmpBackupLevel} (8)\\
Single File Restore          & \bcheckmark     & \bcheckmark \\
DAR                          & \bcheckmark     & \\
DDAR                         & \bcheckmark     & \\
\ilink{Copy and Migration jobs}{MigrationChapter}
                             &                 & \bcheckmark \\
\hline
\end{tabular}
\end{center}



\section{NDMP\_BAREOS}
\label{sec:NdmpBareos}

Bareos implements the \DataManagementAgent inside of the \bareosDir
and a \TapeAgent in the \bareosSd.

The \TapeAgent in the \bareosSd emulates a NDMP tape drive that has an infinite tape.
Because of the infinite tape, no \RobotAgent is required and therefore not implemented.
The blocks being written to the NDMP tape are wrapped into a normal Bareos backup stream
and then stored into the volumes managed by Bareos.

There is always a pair of storage resource definitions:
\begin{itemize}
    \item a conventional Bareos storage resource and
    \item a NDMP storage resource
\end{itemize}

These two are linked together.
Data that is received by the \TapeAgent inside of the \bareosSd is then stored as Bareos backup stream inside of the paired conventional Bareos storage resource.

On restore, the data is read by the conventional resource, and then recovered as NDMP stream from the NDMP resource.

\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\linewidth]{\idir ndmp-backup}
\caption{Relationship between Bareos and NDMP components}
\end{figure}%


\subsection{Example Setup for NDMP\_BAREOS backup}
\index[general]{NDMP!Example!NDMP\_BAREOS}

This example starts from a clean default Bareos installation.

\subsubsection{Enable NDMP on your storage appliance}

The storage appliance needs to be configured to allow NDMP connections. Therefore  usually the
NDMP service needs to be enabled and configured with a username and password.

\subsubsection{Bareos Director: Configure NDMP Client Resource}

Add a Client resource to the \bareosDir configuration
and configure it to access your NDMP storage system (Primary Storage System/\DataAgent).

\begin{itemize}
    \item \linkResourceDirective{Dir}{Client}{Protocol} must be either NDMPv2, NDMPv3 or NDMPv4.
    \item \linkResourceDirective{Dir}{Client}{Port} is set to the NDMP Port (usually 10000).
    \item \linkResourceDirective{Dir}{Client}{Username} and \linkResourceDirective{Dir}{Client}{Password} are used for the authentication against the NDMP Storage System.
    \item \linkResourceDirective{Dir}{Client}{Auth Type} is either Cleartext or MD5. NDMP supports both.
\end{itemize}

In our example we connect to a Isilon storage appliance emulator:
\begin{bconfig}{}
Client {
  Name = ndmp-client
  Address = isilon.example.com
  Port = 10000            # Default port for NDMP
  Protocol = NDMPv4       # Need to specify protocol before password as protocol determines password encoding used
  Auth Type = Clear       # Cleartext Authentication
  Username = "ndmpadmin"  # username of the NDMP user on the DATA AGENT e.g. storage box being backuped.
  Password = "secret"     # password of the NDMP user on the DATA AGENT e.g. storage box being backuped.
}
\end{bconfig}

Verify, that you can access your Primary Storage System via Bareos:

\begin{bconsole}{verify connection to NDMP Primary Storage System}
*<input>status client=ndmp-client</input>

Data Agent isilon.example.com NDMPv4
  Host info
    hostname   isilonsim-1
    os_type    Isilon OneFS
    os_vers    v7.1.1.5
    hostid     005056ad8483ba43cc55a711cd384506e3c1

  Server info
    vendor     Isilon
    product    Isilon NDMP
    revision   2.2
    auths      (2) NDMP4_AUTH_TEXT NDMP4_AUTH_MD5

  Connection types
    addr_types (2) NDMP4_ADDR_TCP NDMP4_ADDR_LOCAL

  Backup type info of tar format
    attrs      0x7fe
    set        FILESYSTEM=/ifs
    set        FILES=
    set        EXCLUDE=
    set        PER_DIRECTORY_MATCHING=N
    set        HIST=f
    set        DIRECT=N
    set        LEVEL=0
    set        UPDATE=Y
    set        RECURSIVE=Y
    set        ENCODING=UTF-8
    set        ENFORCE_UNIQUE_NODE=N
    set        PATHNAME_SEPARATOR=/
    set        DMP_NAME=
    set        BASE_DATE=0
    set        NDMP_UNICODE_FH=N

  Backup type info of dump format
    attrs      0x7fe
    set        FILESYSTEM=/ifs
    set        FILES=
    set        EXCLUDE=
    set        PER_DIRECTORY_MATCHING=N
    set        HIST=f
    set        DIRECT=N
    set        LEVEL=0
    set        UPDATE=Y
    set        RECURSIVE=Y
    set        ENCODING=UTF-8
    set        ENFORCE_UNIQUE_NODE=N
    set        PATHNAME_SEPARATOR=/
    set        DMP_NAME=
    set        BASE_DATE=0
    set        NDMP_UNICODE_FH=N

  File system /ifs
    physdev    OneFS
    unsupported 0x0
    type       NFS
    status
    space      12182519808 total, 686768128 used, 11495751680 avail
    inodes     17664000 total, 16997501 used
    set        MNTOPTS=
    set        MNTTIME=00:00:00 00:00:00
\end{bconsole}

This output shows that the access to the storage appliance was successful.



\subsubsection{Bareos Storage Daemon: Configure NDMP}
\label{sec:ndmp-sd-configure}

\subsubsubsection{Enabling NDMP}

To enable the NDMP \TapeAgent inside of the \bareosSd,
set \linkResourceDirective{Sd}{Storage}{NDMP Enable}=yes:

\begin{bconfig}{enable NDMP in \bareosSd}
#
# Default SD config block: enable the NDMP protocol,
# otherwise it won't listen on port 10000.
#
Storage {
   Name = ....
   ...
   NDMP Enable = yes
}
\end{bconfig}

\subsubsubsection{Add a NDMP resource}

%The NDMP service in the \bareosSd also needs access credentials.

Additionally, we need to define the access credentials for our NDMP TAPE AGENT (Secondary Storage) inside of this Storage Daemon.
%The NDMP Storage definition in the Director configuration will has the matching login information.

These are configured by adding a NDMP resource to \file{bareos-sd.conf}:

\begin{bconfig}{}
#
# This resource gives the DMA in the Director access to the Bareos SD via the NDMP protocol.
# This option is used via the NDMP protocol to open the right TAPE AGENT connection to your
# Bareos SD via the NDMP protocol. The initialization of the SD is done via the native protocol
# and is handled via the PairedStorage keyword.
#
Ndmp {
  Name = bareos-dir-isilon
  Username = ndmpadmin
  Password = test
  AuthType = Clear
}
\end{bconfig}

Username and Password can be anything, but they will have to match the settings in the \bareosDir NDMP Storage resource we configure next.

Now restart the \bareosSd.
If everything is correct, the \bareosSd starts and listens now on the usual port (9103) and additionally on port 10000 (ndmp).

\begin{commands}{}
<command>netstat</command> <parameter>-lntp | grep bareos-sd</parameter>
tcp        0      0 0.0.0.0:9103            0.0.0.0:*               LISTEN      10661/bareos-sd
tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN      10661/bareos-sd
\end{commands}{}

\subsubsection{Bareos Director: Configure a Paired Storage}

For NDMP Backups, we always need two storages that are paired together.
The default configuration already has a Storage \resourcename{Dir}{Storage}{File} defined:

\begin{bconfig}{}
Storage {
  Name = File
  Address = bareos
  Password = "pNZ3TvFAL/t+MyOIQo58p5B/oB79SFncdAmLXKHa9U59"
  Device = FileStorage
  Media Type = File
}
\end{bconfig}

We now add a paired storage to the already existing \resourcename{Dir}{}{File} storage:
\begin{bconfig}{}
#
# Same storage daemon but via NDMP protocol.
# We link via the PairedStorage config option the Bareos SD
# instance definition to a NDMP TAPE AGENT.
#
Storage {
  Name = NDMPFile
  Address = bareos
  Port = 10000
  Protocol = NDMPv4
  Auth Type = Clear
  Username = ndmpadmin
  Password = "test"
  Device = FileStorage
  Media Type = File
  PairedStorage = File
}
\end{bconfig}

The settings of Username and Password need to match the settings of the \bareosSd's NDMP resource we added before.
The address will be used by the storage appliance's NDMP Daemon to connect to the \bareosSd via NDMP.
Make sure that the Storage appliance can resolve the name or use an IP address.

Now save the director resource and restart the \bareosDir.
Verify that the configuration is correct:

\begin{bconsole}{verify connection to the \bareosSd}
*<input>status storage=NDMPFile</input>
Connecting to Storage daemon File at bareos:9103

bareos-sd Version: 15.2.2 (16 November 2015) x86_64-redhat-linux-gnu redhat Red Hat Enterprise Linux Server release 7.0 (Maipo)
Daemon started 14-Jan-16 10:10. Jobs: run=0, running=0.
 Heap: heap=135,168 smbytes=34,085 max_bytes=91,589 bufs=75 max_bufs=77
 Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0 bwlimit=0kB/s

Running Jobs:
No Jobs running.
====

Jobs waiting to reserve a drive:
====

Terminated Jobs:
====

Device status:

Device "FileStorage" (/var/lib/bareos/storage) is not open.
==
====

Used Volume status:
====

====

*
\end{bconsole}

The output looks the same, as if a \bcommand{status storage=File} would have been called.
%  for the paired storage as when the director notices the NDMP
% storage has so called paired storage it will use the native protocol to get the actual status via the
% paired storage definition.

\subsubsection{Bareos Director: Configure NDMP Fileset}
\label{sec:NdmpFileset}

To specify what files and directories from the storage appliance should be backed up,
a Fileset needs to be specified. In our example, we decided to backup \path|/ifs/home| directory.

The specified directory needs to be a filesystem or a subdirectory of a filesystem which can be accessed
by NDMP. Which filesystems are available is showed in the \bcommand{status}{client} output of the NDMP client.

\index[general]{NDMP!Environment variables}
Additionally, NDMP can be configured via NDMP environment variables. These can be specified in the Options
Block of the Fileset with the \configdirective{Meta} keyword. Which variables are available is partly depending on the
NDMP implementation of the Storage Appliance.

\begin{bconfig}{NDMP Fileset}
Fileset {
  Name = "NDMP Fileset"
  Include {
    Options {
        meta = "BUTYPE=DUMP"
        meta = "USE_TBB_IF_AVAILABLE=y"
        meta = "FH_REPORT_FULL_DIRENTS=y"
        meta = "RESTORE_HARDLINK_BY_TABLE=y"
    }
    File = /ifs/home
  }
}
\end{bconfig}

% meta = "ENCODING=ISO_8859_1"

\warning{Normally (\linkResourceDirective{Dir}{Client}{Protocol}=Native) Filesets get handled by the \bareosFd. When connecting directly to a NDMP Clients (\linkResourceDirective{Dir}{Client}{Protocol}=NDMP*), no \bareosFd is involved and therefore most Fileset options can't be used. Instead, parameters are handled via \configdirective{Options - Meta} from \linkResourceDirective{Dir}{FileSet}{Include}.}

\warning{Avoid using multiple \linkResourceDirective{Dir}{FileSet}{Include} \configdirective{File} directives.
The \bareosDir would try to handle them by running multiple NDMP jobs in a single Bareos job.
Even if this is working fine during backup, restore jobs will cause trouble.}

Some NDMP environment variables are set automatically by the DMA in the \bareosDir.
The following environment variables are currently set automatically:
\begin{description}
    \item[FILESYSTEM] is set to the \linkResourceDirective{Dir}{FileSet}{Include} \configdirective{File} directive.
    \item[HIST] = Y \\
        Specifies the file history format:
        \begin{description}
        \item[Y] Specifies the default file history format determined by your NDMP backup settings.
        \item[N] Disables file history. Without file hostory, single file restore is not possible with Bareos.
        \end{description}
        Some NDMP environments (eg. Isilon OneFS) allow additional parameter:
        \begin{description}
        \item[F] Specifies path-based file history. This is the most efficient with Bareos.
            % because it don't require to temporary store information in LMDB
        \item[D] Specifies directory or node file history.
        \end{description}
    \item[LEVEL] is set accordingly to \nameref{sec:NdmpBackupLevel}.
    \item[PREFIX]
    \item[TYPE] is set accordingly to BUTYPE. Default \bquote{DUMP}.
    \item[UPDATE] = Y
\end{description}

\subsubsubsection{Example NDMP Fileset to backup a subset of a NDMP filesystem}

The following fileset is intended to backup all files and directories matching \path|/ifs/home/users/a*|.
It has been tested against Isilon OneFS 7.2.0.1.
See \externalReferenceIsilonNdmpEnvironmentVariables for details about the supported NDMP environment variables.
Excludes are not used in this example.

\begin{bconfig}{NDMP Fileset Isilon Include/Exclude}
Fileset {
  Name = "isilon_fileset_home_a"
  Include {
    Options {
        meta = "BUTYPE=DUMP"
        meta = "USE_TBB_IF_AVAILABLE=y"

        #
        # EXCLUDE
        #
        #meta = "EXCLUDE=[b-z]*"

        #
        # INCLUDE
        #
        meta = "FILES=a*"
    }
    File = /ifs/home/users
  }
}
\end{bconfig}

\subsubsection{Bareos Director: Configure NDMP Jobs}

To do NDMP backups and restores, some special settings need to be configured. We define special Backup and Restore jobs for NDMP.

\begin{bconfig}{NDMP backup job}
Job {
  Name          = "ndmp-backup-job"
  Type          = Backup
  Protocol      = NDMP_BAREOS
  Level         = Incremental
  Client        = ndmp-client
  Backup Format = dump
  FileSet       = "NDMP Fileset"
  Storage       = NDMPFile
  Pool          = Full
  Messages      = Standard
}
\end{bconfig}

\begin{bconfig}{NDMP restore job}
Job {
  Name          = "ndmp-restore-job"
  Type          = Restore
  Protocol      = NDMP_BAREOS
  Client        = ndmp-client
  Backup Format = dump
  FileSet       = "NDMP Fileset"
  Storage       = NDMPFile
  Pool          = Full
  Messages      = Standard
  Where         = /
}
\end{bconfig}

\begin{itemize}
    \item \linkResourceDirective{Dir}{Job}{Backup Format}=dump is used in our example. Other Backup Formats have other advantages/disadvantages.
\end{itemize}


\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\linewidth]{\idir ndmp-cfg}
\caption{NDMP configuration overview}
\label{fig:ndmp-overview}
\end{figure}%


\subsection{Run NDMP Backup}

Now we are ready to do our first NDMP backup:

\begin{bconsole}{run NDMP backup}
*<input>run job=ndmp-backup-job</input>
Using Catalog "MyCatalog"
Run Backup job
JobName:  ndmp-backup-job
Level:    Incremental
Client:   ndmp-client
Format:   dump
FileSet:  NDMP Fileset
Pool:     Full (From Job resource)
Storage:  NDMPFile (From Job resource)
When:     2016-01-14 10:48:04
Priority: 10
OK to run? (yes/mod/no): <input>yes</input>
Job queued. JobId=1
*<input>wait jobid=1</input>
JobId=1
JobStatus=OK (T)
*<input>list joblog jobid=1</input>
 2016-01-14 10:57:53 bareos-dir JobId 1: Start NDMP Backup JobId 1, Job=NDMPJob.2016-01-14_10.57.51_04
 2016-01-14 10:57:53 bareos-dir JobId 1: Created new Volume "Full-0001" in catalog.
 2016-01-14 10:57:53 bareos-dir JobId 1: Using Device "FileStorage" to write.
 2016-01-14 10:57:53 bareos-dir JobId 1: Opening tape drive LPDA-DEJC-ENJL-AHAI-JCBD-LICP-LKHL-IEDK@/ifs/home%0 read/write
 2016-01-14 10:57:53 bareos-sd JobId 1: Labeled new Volume "Full-0001" on device "FileStorage" (/var/lib/bareos/storage).
 2016-01-14 10:57:53 bareos-sd JobId 1: Wrote label to prelabeled Volume "Full-0001" on device "FileStorage" (/var/lib/bareos/storage)
 2016-01-14 10:57:53 bareos-dir JobId 1: Commanding tape drive to rewind
 2016-01-14 10:57:53 bareos-dir JobId 1: Waiting for operation to start
 2016-01-14 10:57:53 bareos-dir JobId 1: Async request NDMP4_LOG_MESSAGE
 2016-01-14 10:57:53 bareos-dir JobId 1: Operation started
 2016-01-14 10:57:53 bareos-dir JobId 1: Monitoring backup
 2016-01-14 10:57:53 bareos-dir JobId 1: LOG_MESSAGE: 'Filetransfer: Transferred 5632 bytes in 0.087 seconds throughput of 63.133 KB/s'
 2016-01-14 10:57:53 bareos-dir JobId 1: LOG_MESSAGE: 'Filetransfer: Transferred 5632 total bytes '
 2016-01-14 10:57:53 bareos-dir JobId 1: LOG_MESSAGE: 'CPU  user=0.016416  sys=0.029437  ft=0.077296  cdb=0.000000'
 2016-01-14 10:57:53 bareos-dir JobId 1: LOG_MESSAGE: 'maxrss=14576  in=13  out=22  vol=155  inv=72'
 2016-01-14 10:57:53 bareos-dir JobId 1: LOG_MESSAGE: '
        Objects (scanned/included):
        ----------------------------
        Regular Files:          (1/1)
        Sparse Files:           (0/0)
        Stub Files:             (0/0)
        Directories:            (2/2)
        ADS Entries:            (0/0)
        ADS Containers:         (0/0)
        Soft Links:             (0/0)
        Hard Links:             (0/0)
        Block Device:           (0/0)
        Char Device:            (0/0)
        FIFO:                   (0/0)
        Socket:                 (0/0)
        Whiteout:               (0/0)
        Unknown:                (0/0)'
 2016-01-14 10:57:53 bareos-dir JobId 1: LOG_MESSAGE: '
        Dir Depth (count)
        ----------------------------
        Total Dirs:             2
        Max Depth:              1

        File Size (count)
        ----------------------------
        == 0                    0
        <= 8k                   1
        <= 64k                  0
        <= 1M                   0
        <= 20M                  0
        <= 100M                 0
        <= 1G                   0
         > 1G                   0
        -------------------------
        Total Files:            1
        Total Bytes:            643
        Max Size:               643
        Mean Size:              643'
 2016-01-14 10:57:53 bareos-dir JobId 1: LOG_MESSAGE: '
        File History
        ----------------------------
        Num FH_HIST_FILE messages:              0
        Num FH_HIST_DIR  messages:              6
        Num FH_HIST_NODE messages:              3'
 2016-01-14 10:57:54 bareos-dir JobId 1: Async request NDMP4_NOTIFY_MOVER_HALTED
 2016-01-14 10:57:54 bareos-dir JobId 1: DATA: bytes 2053KB  MOVER: written 2079KB record 33
 2016-01-14 10:57:54 bareos-dir JobId 1: Operation done, cleaning up
 2016-01-14 10:57:54 bareos-dir JobId 1: Waiting for operation to halt
 2016-01-14 10:57:54 bareos-dir JobId 1: Commanding tape drive to NDMP9_MTIO_EOF 2 times
 2016-01-14 10:57:54 bareos-dir JobId 1: Commanding tape drive to rewind
 2016-01-14 10:57:54 bareos-dir JobId 1: Closing tape drive LPDA-DEJC-ENJL-AHAI-JCBD-LICP-LKHL-IEDK@/ifs/home%0
 2016-01-14 10:57:54 bareos-dir JobId 1: Operation halted, stopping
 2016-01-14 10:57:54 bareos-dir JobId 1: Operation ended OKAY
 2016-01-14 10:57:54 bareos-sd JobId 1: Elapsed time=00:00:01, Transfer rate=2.128 M Bytes/second
 2016-01-14 10:57:54 bareos-dir JobId 1: Bareos bareos-dir 15.2.2 (16Nov15):
  Build OS:               x86_64-redhat-linux-gnu redhat Red Hat Enterprise Linux Server release 7.0 (Maipo)
  JobId:                  1
  Job:                    ndmp-backup-job.2016-01-14_10.57.51_04
  Backup Level:           Full
  Client:                 "ndmp-client" 
  FileSet:                "NDMP Fileset" 2016-01-14 10:57:51
  Pool:                   "Full" (From Job resource)
  Catalog:                "MyCatalog" (From Client resource)
  Storage:                "NDMPFile" (From Job resource)
  Scheduled time:         14-Jan-2016 10:57:51
  Start time:             14-Jan-2016 10:57:53
  End time:               14-Jan-2016 10:57:54
  Elapsed time:           1 sec
  Priority:               10
  NDMP Files Written:     3
  SD Files Written:       1
  NDMP Bytes Written:     2,102,784 (2.102 MB)
  SD Bytes Written:       2,128,987 (2.128 MB)
  Rate:                   2102.8 KB/s
  Volume name(s):         Full-0001
  Volume Session Id:      4
  Volume Session Time:    1452764858
  Last Volume Bytes:      2,131,177 (2.131 MB)
  Termination:            Backup OK
\end{bconsole}

We have successfully created our first NDMP backup.

Let us have a look what files are in our backup:

\begin{bconsole}{list the files of the backup job}
*<input>list files jobid=1</input>
 /@NDMP/ifs/home%0
 /ifs/home/
 /ifs/home/admin/
 /ifs/home/admin/.zshrc
\end{bconsole}

The real backup data is stored in the file \path|/@NDMP/ifs/home%0|
(we will refer to it as \bquote{NDMP main backup file} or \bquote{main backup file} later on).
One NDMP main backup file is created for every directory specified in the used Fileset.
The other files show the file history and are hardlinks to the backup file.



\subsection{Run NDMP Restore}

Now that we have a NDMP backup, we of course also want to restore some data from the backup.
If the backup we just did saved the Filehistory, we are able to select single files for restore.
Otherwise, we will only be able to restore the whole backup.


\subsubsection{Full Restore}

Either select all files or the main backup file (\path|/@NDMP/ifs/home%0|).
If file history is not included in the backup job, than only the main backup file is available.

\subsubsection{Restore files to original path}

\begin{bconsole}{}
*<input>restore jobid=1</input>
You have selected the following JobId: 1

Building directory tree for JobId(s) 1 ...
2 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 /ifs/home/admin/.zshrc</input>
$ <input>done</input>
Bootstrap records written to /var/lib/bareos/bareos-dir.restore.1.bsr

The job will require the following
   Volume(s)                 Storage(s)                SD Device(s)
===========================================================================

    Full-0001                 File                      FileStorage

Volumes marked with "*" are online.


1 file selected to be restored.

The defined Restore Job resources are:
     1: RestoreFiles
     2: ndmp-restore-job
Select Restore Job (1-2): <input>2</input>
Defined Clients:
     1: bareos-fd
     2: ndmp-client
Select the Client (1-2): <input>2</input>
Run Restore job
JobName:         ndmp-backup-job
Bootstrap:       /var/lib/bareos/bareos-dir.restore.1.bsr
Where:           /
Replace:         Always
FileSet:         NDMP Fileset
Backup Client:   ndmp-client
Restore Client:  ndmp-client
Format:          dump
Storage:         File
When:            2016-01-14 11:04:46
Catalog:         MyCatalog
Priority:        10
Plugin Options:  *None*
OK to run? (yes/mod/no): <input>yes</input>
Job queued. JobId=2
*<input>wait jobid=2</input>
JobId=2
JobStatus=OK (T)
*<input>list joblog jobid=2</input>
14-Jan 11:04 bareos-dir JobId 2: Start Restore Job ndmp-backup-job.2016-01-14_11.04.53_05
14-Jan 11:04 bareos-dir JobId 2: Using Device "FileStorage" to read.
14-Jan 11:04 bareos-dir JobId 2: Opening tape drive KKAE-IMLO-NHJD-GOCO-GJCO-GEHB-BODL-ADNG@/ifs/home read-only
14-Jan 11:04 bareos-dir JobId 2: Commanding tape drive to rewind
14-Jan 11:04 bareos-dir JobId 2: Waiting for operation to start
14-Jan 11:04 bareos-sd JobId 2: Ready to read from volume "Full-0001" on device "FileStorage" (/var/lib/bareos/storage).
14-Jan 11:04 bareos-sd JobId 2: Forward spacing Volume "Full-0001" to file:block 0:194.
14-Jan 11:04 bareos-dir JobId 2: Async request NDMP4_LOG_MESSAGE
14-Jan 11:04 bareos-dir JobId 2: Operation started
14-Jan 11:04 bareos-dir JobId 2: Monitoring recover
14-Jan 11:04 bareos-dir JobId 2: DATA: bytes 0KB  MOVER: read 0KB record 0
14-Jan 11:04 bareos-dir JobId 2: LOG_MESSAGE: 'Filetransfer: Transferred 1048576 bytes in 0.135 seconds throughput of 7557.139 KB/s'
14-Jan 11:04 bareos-dir JobId 2: OK: /admin/.zshrc
14-Jan 11:04 bareos-dir JobId 2: LOG_MESSAGE: '
        Objects:
        ----------------------------
        Regular Files:          (1)
        Stub Files:             (0)
        Directories:            (0)
        ADS Entries:            (0)
        Soft Links:             (0)
        Hard Links:             (0)
        Block Device:           (0)
        Char Device:            (0)
        FIFO:                   (0)
        Socket:                 (0)
        Unknown:                (0)'
14-Jan 11:04 bareos-dir JobId 2: LOG_MESSAGE: '
        File Size (count)
        ----------------------------
        == 0                    0
        <= 8k                   1
        <= 64k                  0
        <= 1M                   0
        <= 20M                  0
        <= 100M                 0
        <= 1G                   0
         > 1G                   0
        -------------------------
        Total Files:            1
        Total Bytes:            643
        Max Size:               643
        Mean Size:              643'
14-Jan 11:04 bareos-dir JobId 2: Async request NDMP4_NOTIFY_MOVER_PAUSED
14-Jan 11:04 bareos-dir JobId 2: DATA: bytes 1024KB  MOVER: read 2079KB record 32
14-Jan 11:04 bareos-dir JobId 2: Mover paused, reason=NDMP9_MOVER_PAUSE_EOF
14-Jan 11:04 bareos-dir JobId 2: End of tapes
14-Jan 11:04 bareos-dir JobId 2: DATA: bytes 1024KB  MOVER: read 2079KB record 32
14-Jan 11:04 bareos-dir JobId 2: Operation done, cleaning up
14-Jan 11:04 bareos-dir JobId 2: Waiting for operation to halt
14-Jan 11:04 bareos-dir JobId 2: Commanding tape drive to rewind
14-Jan 11:04 bareos-dir JobId 2: Closing tape drive KKAE-IMLO-NHJD-GOCO-GJCO-GEHB-BODL-ADNG@/ifs/home
14-Jan 11:04 bareos-dir JobId 2: Operation halted, stopping
14-Jan 11:04 bareos-dir JobId 2: Operation ended OKAY
14-Jan 11:04 bareos-dir JobId 2: LOG_FILE messages: 1 OK, 0 ERROR, total 1 of 1
14-Jan 11:04 bareos-dir JobId 2: Bareos bareos-dir 15.2.2 (16Nov15):
  Build OS:               x86_64-redhat-linux-gnu redhat Red Hat Enterprise Linux Server release 7.0 (Maipo)
  JobId:                  2
  Job:                    ndmp-backup-job.2016-01-14_11.04.53_05
  Restore Client:         ndmp-client
  Start time:             14-Jan-2016 11:04:55
  End time:               14-Jan-2016 11:04:57
  Elapsed time:           2 secs
  Files Expected:         1
  Files Restored:         1
  Bytes Restored:         1,048,576
  Rate:                   524.3 KB/s
  SD termination status:  OK
  Termination:            Restore OK
\end{bconsole}

\subsubsection{Restore files to different path}
\label{sec:ndmp-where}

The restore location is determined by the \linkResourceDirective{Dir}{Job}{Where} setting of the restore job.
In NDMP, this parameter works in a special manner, the prefix can be either \bquote{relative} to the filesystem or \bquote{absolute}.
If a prefix is set in form of a directory (like \directory{/bareos-restores}), it will be a relative prefix and will be added between the filesystem and the filename. This is needed to make sure that the data is restored in a different directory, but  into the same filesystem.
If the prefix is set with a leading caret (\textasciicircum), it will be an absolute prefix and will be put at the front of the restore path. This is needed if the restored data should be stored into a different filesystem.

Example:

\begin{tabular}{l | l | l}
\hline
original file name &  where &  restored file \\
\hline
\path|/ifs/home/admin/.zshrc| & \path|/bareos-restores|           & \path|/ifs/home/bareos-restores/admin/.zshrc| \\
\path|/ifs/home/admin/.zshrc| & \textasciicircum\path|/ifs/data/bareos-restores| & \path|/ifs/data/bareos-restores/admin/.zshrc| \\
\hline
\end{tabular}




\subsection{NDMP Copy Jobs}
\index[general]{Copy!NDMP}
\index[general]{NDMP!Copy jobs}

To be able to do copy jobs, we need to have a second storage resource where we can copy the data to.
Depending on your requirements, this resource can be added to the existing \bareosSd (e.g. \resourcename{Sd}{Storage}{autochanger-0} for tape based backups) or to an additional \bareosSd.

We set up an additional \bareosSd on a host named \host{bareos-sd2.example.com}
with the default \resourcename{Sd}{Storage}{FileStorage} device.

When this is done, add a second storage resource \resourcename{Dir}{Storage}{File2} to the \file{bareos-dir.conf}:
\begin{bconfig}{Storage resource File2}
Storage {
  Name = File2
  Address = bareos-sd2.example.com
  Password = <secretpassword>
  Device = FileStorage
  Media Type = File
}
\end{bconfig}

Copy Jobs copy data from one pool to another (see \nameref{MigrationChapter}).
So we need to define a pool where the copies will be written to:

Add a Pool that the copies will run to:
\begin{bconfig}{Pool resource Copy}
#
# Copy Destination Pool
#
Pool {
  Name = Copy
  Pool Type = Backup
  Recycle = yes                       # Bareos can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 365 days         # How long should the Full Backups be kept? (#06)
  Maximum Volume Bytes = 50G          # Limit Volume size to something reasonable
  Maximum Volumes = 100               # Limit number of Volumes in Pool
  Label Format = "Copy-"              # Volumes will be labeled "Full-<volume-id>"
  Storage = File2                     # Pool belongs to Storage File2
}
\end{bconfig}

Then we need to define the just defined pool as the \linkResourceDirective{Dir}{Pool}{Next Pool} of the pool
that actually holds the data to be copied.

In our case this is the \resourcename{Dir}{Pool}{Full} Pool:
\begin{bconfig}{add Next Pool setting}
#
# Full Pool definition
#
Pool {
  Name = Full
  [...]
  Next Pool = Copy   # <- this line needs to be added!
}
\end{bconfig}


Finally, we need to define a Copy Job that will select the jobs that are in the \resourcename{Dir}{Pool}{Full} pool
and copy them over to the \resourcename{Dir}{Pool}{Copy} pool 
reading the data via the \resourcename{Dir}{Storage}{File} Storage
and writing the data via the \resourcename{Dir}{Storage}{File2} Storage:

\begin{bconfig}{NDMP copy job}
Job {
   Name = NDMPCopy
   Type = Copy
   Messages = Standard
   Selection Type = PoolUncopiedJobs
   Pool = Full
   Storage = NDMPFile
}
\end{bconfig}

After restarting the director and storage daemon, we can run the Copy job:

\begin{bconsole}{run copy job}
*<input>run job=NDMPCopy</input>
Run Copy job
JobName:       NDMPCopy
Bootstrap:     *None*
Pool:          Full (From Job resource)
NextPool:      Copy (From unknown source)
Write Storage: File2 (From Storage from Run NextPool override)
JobId:         *None*
When:          2016-01-21 09:19:49
Catalog:       MyCatalog
Priority:      10
OK to run? (yes/mod/no): <input>yes</input>
Job queued. JobId=74
*<input>wait jobid=74</input>
JobId=74
JobStatus=OK (T)
*<input>list joblog jobid=74</input>
21-Jan 09:19 bareos-dir JobId 74: The following 1 JobId was chosen to be copied: 73
21-Jan 09:19 bareos-dir JobId 74: Automatically selected Catalog: MyCatalog
21-Jan 09:19 bareos-dir JobId 74: Using Catalog "MyCatalog"
21-Jan 09:19 bareos-dir JobId 75: Copying using JobId=73 Job=NDMPJob.2016-01-21_09.18.50_49
21-Jan 09:19 bareos-dir JobId 75: Bootstrap records written to /var/lib/bareos/bareos-dir.restore.20.bsr
21-Jan 09:19 bareos-dir JobId 74: Job queued. JobId=75
21-Jan 09:19 bareos-dir JobId 74: Copying JobId 75 started.
21-Jan 09:19 bareos-dir JobId 74: Bareos bareos-dir 15.2.2 (16Nov15):
  Build OS:               x86_64-redhat-linux-gnu redhat Red Hat Enterprise Linux Server release 7.0 (Maipo)
  Current JobId:          74
  Current Job:            NDMPCopy.2016-01-21_09.19.50_50
  Catalog:                "MyCatalog" (From Default catalog)
  Start time:             21-Jan-2016 09:19:52
  End time:               21-Jan-2016 09:19:52
  Elapsed time:           0 secs
  Priority:               10
  Termination:            Copying -- OK

21-Jan 09:19 bareos-dir JobId 75: Start Copying JobId 75, Job=NDMPCopy.2016-01-21_09.19.52_51
21-Jan 09:19 bareos-dir JobId 75: Using Device "FileStorage" to read.
21-Jan 09:19 bareos-dir JobId 76: Using Device "FileStorage2" to write.
21-Jan 09:19 bareos-sd JobId 75: Ready to read from volume "Full-0001" on device "FileStorage" (/var/lib/bareos/storage).
21-Jan 09:19 bareos-sd JobId 76: Volume "Copy-0004" previously written, moving to end of data.
21-Jan 09:19 bareos-sd JobId 76: Ready to append to end of Volume "Copy-0004" size=78177310
21-Jan 09:19 bareos-sd JobId 75: Forward spacing Volume "Full-0001" to file:block 0:78177310.
21-Jan 09:19 bareos-sd JobId 75: End of Volume at file 0 on device "FileStorage" (/var/lib/bareos/storage), Volume "Full-0001"
21-Jan 09:19 bareos-sd JobId 75: End of all volumes.
21-Jan 09:19 bareos-sd JobId 76: Elapsed time=00:00:01, Transfer rate=64.61 K Bytes/second
21-Jan 09:19 bareos-dir JobId 75: Bareos bareos-dir 15.2.2 (16Nov15):
  Build OS:               x86_64-redhat-linux-gnu redhat Red Hat Enterprise Linux Server release 7.0 (Maipo)
  Prev Backup JobId:      73
  Prev Backup Job:        NDMPJob.2016-01-21_09.18.50_49
  New Backup JobId:       76
  Current JobId:          75
  Current Job:            NDMPCopy.2016-01-21_09.19.52_51
  Backup Level:           Incremental
  Client:                 ndmp-client
  FileSet:                "NDMP Fileset"
  Read Pool:              "Full" (From Job resource)
  Read Storage:           "NDMPFile" (From Job resource)
  Write Pool:             "Copy" (From Job Pool's NextPool resource)
  Write Storage:          "File2" (From Storage from Pool's NextPool resource)
  Next Pool:              "Copy" (From Job Pool's NextPool resource)
  Catalog:                "MyCatalog" (From Default catalog)
  Start time:             21-Jan-2016 09:19:54
  End time:               21-Jan-2016 09:19:54
  Elapsed time:           0 secs
  Priority:               10
  SD Files Written:       1
  SD Bytes Written:       64,614 (64.61 KB)
  Rate:                   0.0 KB/s
  Volume name(s):         Copy-0004
  Volume Session Id:      43
  Volume Session Time:    1453307753
  Last Volume Bytes:      78,242,384 (78.24 MB)
  SD Errors:              0
  SD termination status:  OK
  Termination:            Copying OK
\end{bconsole}

Now we successfully copied over the NDMP job.

\warning{\bcommand{list}{jobs} will only show the number of main backup files as JobFiles. However, with \bcommand{list}{files jobid=...} all files are visible.}

\subsubsection{Restore to NDMP Primary Storage System}

Unfortunately, we are not able to restore the copied data to our NDMP storage. If we try we get this message:

\begin{bmessage}{}
21-Jan 09:21 bareos-dir JobId 77: Fatal error: Read storage File2 doesn't point to storage definition with paired storage option.
\end{bmessage}

To be able to do NDMP operations from the storage that was used to store the copies,
we need to define a NDMP storage that is paired with it.
The definition is very similar to our \resourcename{Dir}{Storage}{NDMPFile} Storage,
as we want to restore the data to the same NDMP Storage system:

\begin{bconfig}{add paired Storage resource for File2}
Storage {
  Name = NDMPFile2
  Address = bareos-sd2.example.com
  Port = 10000
  Protocol = NDMPv4
  Auth Type = Clear
  Username = ndmpadmin
  Password = "test"
  Device = FileStorage2
  Media Type = File
  PairedStorage = File2
}
\end{bconfig}

Also we have to configure NDMP on the \bareosSd \host{bareos-sd2.example.com}.
For this follow the instruction from \nameref{sec:ndmp-sd-configure}.

After this, a restore from \host{bareos-sd2.example.com} directly to the NDMP Primary Storage System is possible.



\subsection{Limitations}

This list the specific limitiations of the NDMP\_BAREOS protocol.
For limitation for all Bareos NDMP implementation, see \nameref{sec:NdmpCommonLimitations}.

\subsubsection{NDMP Job limitations when scanning in volumes}
\label{sec:ndmp-filehistory}
\index[general]{NDMP!File History}

For NDMP jobs, all data is stored into a single big file. The file and directory information (File History in NDMP Terms) is stored as hardlinks to this big file.

\limitation*{NDMP}{File information are not available in the Bareos backup stream}{%
As hardlink information is only stored in the Bareos database, but not int the backup stream itself, it is not possible to recover the file history information from the NDMP stream with \command{bscan}.

As storing the database dump for disaster recovery and storing the bootstrap file offsite is recommended  anyway (see \nameref{sec:before-disaster}), this should be not a big problem in correctly setup environments.

For the same reason, the information about the number of files of a job (e.g. JobFiles with \bcommand{list}{jobs} command) is limited to the number of NDMP backup files in copied jobs.
}

\subsubsection{Restore always transfers the full main backup file to the Primary Storage System}

The \NdmpBareos implementation do not support NDMP \bquote{Direct Access Restore} (DAR).

On restore, the full main backup file (\path|@NDMP/...%.|)
is always transfered back to the Primary Storage System,
together with a description, what files to restore.

The reason for this is that the Primary Storage System handles the backup data by itself.
Bareos will not modify the backup data it receives from the Primary Storage System.


\section{NDMP\_NATIVE}
\label{sec:NdmpNative}

The NDMP\_NATIVE protocol is implemented since Bareos \sinceVersion{dir}{NDMP NATIVE}{17.2.3}.

Bareos implements the \DataManagementAgent inside of the \bareosDir
and is the only Bareos Daemon involved in the backups.

When using NDMP\_NATIVE, the \TapeAgent must be provided by some other systems.
Some storage vendors provide it with there storages, or offer it as an option,
e.g. Isilon with there \bquote{Isilon Backup Accelerator}.

\subsection{Example Setup for NDMP\_NATIVE backup}
\index[general]{NDMP!Example!NDMP\_NATIVE}

\subsubsection{Configure a NDMP Client}

This defines the connection to the NDMP Data Agent.

\begin{bareosConfigResource}{bareos-dir}{Client}{isilon}
Client {
  Name = isilon
  Address = isilon.example.com
  Port = 10000
  Protocol = NDMPv4
  Auth Type = MD5
  Username = "ndmpadmin"
  Password = "secret"
  Maximum Concurrent Jobs = 1
}
\end{bareosConfigResource}

Verify, that you can access your Primary Storage System (\TapeAgent) via Bareos:

\begin{bconsole}{status ndmp client}
*<input>status client=isilon</input>

Data Agent isilon.example.com NDMPv4
  Host info
    hostname   isilon
    os_type    Isilon OneFS
    os_vers    v7.2.1.4
    hostid     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

  Server info
    vendor     Isilon
    product    Isilon NDMP
    revision   2.2.1
    auths      (2) NDMP4_AUTH_TEXT NDMP4_AUTH_MD5

  Connection types
    addr_types (2) NDMP4_ADDR_TCP NDMP4_ADDR_LOCAL

  Backup type info of tar format
    attrs      0x7fe
    set        FILESYSTEM=/ifs
    set        FILES=
    set        EXCLUDE=
    set        PER_DIRECTORY_MATCHING=N
    set        HIST=f
    set        DIRECT=N
    set        LEVEL=0
    set        UPDATE=Y
    set        RECURSIVE=Y
    set        ENCODING=UTF-8
    set        ENFORCE_UNIQUE_NODE=N
    set        PATHNAME_SEPARATOR=/
    set        DMP_NAME=
    set        BASE_DATE=0
    set        NDMP_UNICODE_FH=N

  Backup type info of dump format
    attrs      0x7fe
    set        FILESYSTEM=/ifs
    set        FILES=
    set        EXCLUDE=
    set        PER_DIRECTORY_MATCHING=N
    set        HIST=f
    set        DIRECT=N
    set        LEVEL=0
    set        UPDATE=Y
    set        RECURSIVE=Y
    set        ENCODING=UTF-8
    set        ENFORCE_UNIQUE_NODE=N
    set        PATHNAME_SEPARATOR=/
    set        DMP_NAME=
    set        BASE_DATE=0
    set        NDMP_UNICODE_FH=N

  File system /ifs
    physdev    OneFS
    unsupported 0x0
    type       NFS
    status
    space      224681156345856 total, 126267678720 used, 224554888667136 avail
    inodes     324102912000 total, 323964781836 used
    set        MNTOPTS=
    set        MNTTIME=00:00:00 00:00:00
\end{bconsole}



\subsubsection{Configure a NDMP Fileset}

This determines what filesystem to backup and configures the NDMP environment to use in the meta options for it.

\begin{bareosConfigResource}{bareos-dir}{Fileset}{isilon}
Fileset {
    Name = "isilon"
    Include {
        Options {
            meta = "HIST=F"
            meta = "DIRECT=Y"
            meta = "RECURSIVE=Y"
            meta = "BUTYPE=DUMP"
        }
    File = /ifs/home
    }
}
\end{bareosConfigResource}


The setting of \configline{"DIRECT = Y"} is required for Direct Access Recovery.

For more information, see \nameref{sec:NdmpFileset}.



\subsubsection{Configure a NDMP Storage}

This defines now to connect to the Tape and Robot Agents and what devices to use.

As we do not yet now the device names, we can put a placeholder string in
\linkResourceDirective{Dir}{Storage}{Device} and
\linkResourceDirective{Dir}{Storage}{NDMP Changer Device}:

\begin{bareosConfigResource}{bareos-dir}{Storage}{isilon}
Storage {
  Name = isilon
  Address = isilon.example.com
  Port = 10000
  Protocol = NDMPv4
  Auth Type = MD5
  Username = "ndmpadmin"
  Password = "secret"
  Maximum Concurrent Jobs = 1
  Autochanger = yes
  MediaType = NDMP-Tape

  Device = unknown               # use "status storage" to determine the tape device
  NDMP Changer Device = unknown  # use "status storage" to determine the changer device
}
\end{bareosConfigResource}

Verify that the connection to the NDMP Tape Agent and Robot Agent work,
by running the \bcommand{status}{storage} command.

The \TapeAgent will return information about the available tape drives.
The \RobotAgent will return information about the available tape changer device.


\begin{bconsole}{status ndmp storage (Tape Agent and Robot Agent)}
*<input>status storage=isilon</input>
Tape Agent isilon.bareos.com NDMPv4
  Host info
    hostname   isilon
    os_type    Isilon OneFS
    os_vers    v7.2.1.4
    hostid     abcdefg

  Server info
    vendor     Isilon
    product    Isilon NDMP
    revision   2.2.1
    auths      (2) NDMP4_AUTH_TEXT NDMP4_AUTH_MD5

  Connection types
    addr_types (2) NDMP4_ADDR_TCP NDMP4_ADDR_LOCAL

  tape HP Ultrium 5-SCSI I30Z
    device     HP-TLD-004-01
      attr       0x4
      set        EXECUTE_CDB=t
      set        SERIAL_NUMBER=123456

  tape HP Ultrium 5-SCSI I30Z
    device     HP-TLD-004-02
      attr       0x4
      set        EXECUTE_CDB=t
      set        SERIAL_NUMBER=1234567

Robot Agent isilon.bareos.com NDMPv4
  Host info
    hostname   isilon
    os_type    Isilon OneFS
    os_vers    v7.2.1.4
    hostid     001517db7e38f40dbb4dfc0b823f29a31e09

  Server info
    vendor     Isilon
    product    Isilon NDMP
    revision   2.2.1
    auths      (2) NDMP4_AUTH_TEXT NDMP4_AUTH_MD5

  scsi QUANTUM Scalar i6000 605A
    device     mc001
      set        SERIAL_NUMBER=VL002CX1252BVE01177
\end{bconsole}

The interesting parts of the output is the device information
both of the \TapeAgent and \RobotAgent.

As each NDMP backup or recovery operation always involves exactly one tape and at one robot agent.

We now know the device names and can configure what robot and what tape to use when this storage is used by bareos by updating the \resourcename{Sd}{Storage}{isilon} resource:

\begin{bareosConfigResource}{bareos-dir}{Storage}{isilon}
Storage {
  Name = isilon
  Address = isilon.example.com
  Port = 10000
  Protocol = NDMPv4
  Auth Type = MD5
  Username = "ndmpadmin"
  Password = "secret"
  Maximum Concurrent Jobs = 1
  Autochanger = yes
  MediaType = NDMP-Tape

  Device = HP-TLD-004-01
  NDMP Changer Device = mc001
}
\end{bareosConfigResource}



\subsubsection{Configure a Pool for the NDMP Tapes}

\begin{bareosConfigResource}{bareos-dir}{Pool}{NDMP-Tape}
Pool {
  Name = NDMP-Tape
  Pool Type = Backup
  Recycle = yes                       # Bareos can automatically recycle Volumes
  Auto Prune = yes                    # Prune expired volumes
  Volume Retention = 365 days         # How long should the Full Backups be kept?
}
\end{bareosConfigResource}



\subsubsection{Configure NDMP Jobs}

To be able to do scheduled backups, we need to configure a backup job that will use the NDMP client and NDMP storage resources:

\begin{bareosConfigResource}{bareos-dir}{Job}{ndmp-native-backup-job}
Job {
   Name = ndmp-native-backup-job
   type = backup
   protocol = NDMP_NATIVE
   level = incremental
   client = isilon
   storage = isilon
   backup format = dump
   messages = Standard
   Pool = NDMP-Tape
   save file history = yes
   FileSet = isilon
}
\end{bareosConfigResource}


As we also need to be able to do a restore of the backuped data, we also need to define an adequate restore job:

\begin{bareosConfigResource}{bareos-dir}{Job}{ndmp-native-restore-job}
Job{
   Name = ndmp-restore
   type = restore
   protocol = NDMP_NATIVE
   client = isilon
   backup format = dump
   fileset = isilon
   storage  = isilon
   pool = NDMP-Tape
   Messages = Standard
   where = /
}
\end{bareosConfigResource}




\subsection{Label Tapes}

Before we can really start do do backups, first we need to label the tapes that should be used.

First we check if our robot has tapes with barcodes by running status slots:

\begin{bconsole}{status storage=isilon slots}
*<input>status slots</input>
 Slot |   Volume Name    |   Status  |  Media Type    |         Pool             |
------+------------------+-----------+----------------+--------------------------|
    1@|                ? |         ? |              ? |                        ? |
    2@|                ? |         ? |              ? |                        ? |
    3@|                ? |         ? |              ? |                        ? |
    4@|                ? |         ? |              ? |                        ? |
[...]
  251*|           BT0001 |         ? |              ? |                        ? |
  252*|           BT0002 |         ? |              ? |                        ? |
  253*|           BT0003 |         ? |              ? |                        ? |
  254*|           BT0004 |         ? |              ? |                        ? |
  255*|           BT0005 |         ? |              ? |                        ? |
  256*|           BT0006 |         ? |              ? |                        ? |
  257*|           BT0007 |         ? |              ? |                        ? |
[...]
\end{bconsole}


Now we can label these tapes and add them to the pool that we have created for NDMP Tapes:

\begin{bconsole}{label barcodes}
*<input>label storage=isilon barcodes slots=251-257</input>
Automatically selected Storage: isilon
Select Drive:
     1: Drive 0
     2: Drive 1
Select drive (1-12): 1
get ndmp_vol_list...
The following Volumes will be labeled:
Slot  Volume
==============
 251  BT0001
 252  BT0002
 253  BT0003
 254  BT0004
 255  BT0005
 256  BT0006
 257  BT0007
Do you want to label these Volumes? (yes|no): yes
Defined Pools:
     1: Scratch
     2: NDMP-Tape
     3: Incremental
     4: Full
     5: Differential
Select the Pool (1-5): 2
ndmp_send_label_request: VolumeName=BT0001 MediaType=NDMP-Tape PoolName=NDMP-Tape drive=0
Catalog record for Volume "BT0001", Slot 251 successfully created.
ndmp_send_label_request: VolumeName=BT0002 MediaType=NDMP-Tape PoolName=NDMP-Tape drive=0
Catalog record for Volume "BT0002", Slot 252 successfully created.
ndmp_send_label_request: VolumeName=BT0003 MediaType=NDMP-Tape PoolName=NDMP-Tape drive=0
Catalog record for Volume "BT0003", Slot 253 successfully created.
ndmp_send_label_request: VolumeName=BT0004 MediaType=NDMP-Tape PoolName=NDMP-Tape drive=0
Catalog record for Volume "BT0004", Slot 254 successfully created.
ndmp_send_label_request: VolumeName=BT0005 MediaType=NDMP-Tape PoolName=NDMP-Tape drive=0
Catalog record for Volume "BT0005", Slot 255 successfully created.
ndmp_send_label_request: VolumeName=BT0006 MediaType=NDMP-Tape PoolName=NDMP-Tape drive=0
Catalog record for Volume "BT0006", Slot 256 successfully created.
ndmp_send_label_request: VolumeName=BT0007 MediaType=NDMP-Tape PoolName=NDMP-Tape drive=0
Catalog record for Volume "BT0007", Slot 257 successfully created.
\end{bconsole}

We have now 7 volumes in our NDMP-Tape Pool that were labeled and can be used for NDMP Backups.


\subsection{Run NDMP\_NATIVE Backup}

\begin{bconsole}{run backup job}
*<input>run job=ndmp-native-backup-job yes</input>
JobId 1: Start NDMP Backup JobId 1, Job=ndmp.2017-04-07_01.40.31_10
JobId 1: Using Data  host isilon.bareos.com
JobId 1: Using Tape  host:device  isilon.bareos.com:HP-TLD-004-01
JobId 1: Using Robot host:device  isilon.bareos.com:mc001
JobId 1: Using Tape record size 64512
JobId 1: Found volume for append: BT0001
JobId 1: Commanding robot to load slot @4146 into drive @256
JobId 1: robot moving @4146 to @256
JobId 1: robot move OK @4146 to @256
JobId 1: Opening tape drive HP-TLD-004-01 read/write
JobId 1: Commanding tape drive to rewind
JobId 1: Checking tape label, expect 'BT0001'
JobId 1: Reading label
JobId 1: Commanding tape drive to rewind
JobId 1: Commanding tape drive to NDMP9_MTIO_FSF 1 times
JobId 1: Waiting for operation to start
JobId 1: Operation started
JobId 1: Monitoring backup
JobId 1: DATA: bytes 3703831KB  MOVER: written 3703644KB record 58788
JobId 1: LOG_MESSAGE: 'End of medium reached.'
JobId 1: DATA: bytes 4834614KB  MOVER: written 4834053KB record 76731
JobId 1: Mover paused, reason=NDMP9_MOVER_PAUSE_EOM
JobId 1: Operation requires next tape
JobId 1: At EOM, not writing filemarks
JobId 1: Commanding tape drive to rewind
JobId 1: Closing tape drive HP-TLD-004-01
JobId 1: Commanding robot to unload drive @256 to slot @4146
JobId 1: robot moving @256 to @4146
JobId 1: robot move OK @256 to @4146
JobId 1: Found volume for append: BT0002
JobId 1: Commanding robot to load slot @4147 into drive @256
JobId 1: robot moving @4147 to @256
JobId 1: robot move OK @4147 to @256
JobId 1: Opening tape drive HP-TLD-004-01 read/write
JobId 1: Commanding tape drive to rewind
JobId 1: Checking tape label, expect 'BT0002'
JobId 1: Reading label
JobId 1: Commanding tape drive to rewind
JobId 1: Commanding tape drive to NDMP9_MTIO_FSF 1 times
JobId 1: Operation resuming
JobId 1: DATA: bytes 6047457KB  MOVER: written 6047244KB record 95988
JobId 1: LOG_MESSAGE: 'End of medium reached.'
JobId 1: DATA: bytes 9668679KB  MOVER: written 9668106KB record 153462
JobId 1: Mover paused, reason=NDMP9_MOVER_PAUSE_EOM
JobId 1: Operation requires next tape
JobId 1: At EOM, not writing filemarks
JobId 1: Commanding tape drive to rewind
JobId 1: Closing tape drive HP-TLD-004-01
JobId 1: Commanding robot to unload drive @256 to slot @4147
JobId 1: robot moving @256 to @4147
JobId 1: robot move OK @256 to @4147
JobId 1: Found volume for append: BT0003
JobId 1: Commanding robot to load slot @4148 into drive @256
JobId 1: robot moving @4148 to @256
JobId 1: robot move OK @4148 to @256
JobId 1: Opening tape drive HP-TLD-004-01 read/write
JobId 1: Commanding tape drive to rewind
JobId 1: Checking tape label, expect 'BT0003'
JobId 1: Reading label
JobId 1: Commanding tape drive to rewind
JobId 1: Commanding tape drive to NDMP9_MTIO_FSF 1 times
JobId 1: Operation resuming
JobId 1: LOG_MESSAGE: 'Filetransfer: Transferred 10833593344 bytes in 87.187 seconds throughput of 121345.079 KB/s'
JobId 1: LOG_MESSAGE: 'Filetransfer: Transferred 10833593344 total bytes '
JobId 1: LOG_MESSAGE: 'CPU  user=0.528118  sys=54.575536  ft=87.182576  cdb=0.000000'
JobId 1: LOG_MESSAGE: 'maxrss=171972  in=1323908  out=17  vol=199273  inv=5883'
JobId 1: LOG_MESSAGE: '
        Objects (scanned/included):
        ----------------------------
        Regular Files:          (2765/2765)
        Sparse Files:           (0/0)
        Stub Files:             (0/0)
        Directories:            (447/447)
        ADS Entries:            (0/0)
        ADS Containers:         (0/0)
        Soft Links:             (0/0)
        Hard Links:             (0/0)
        Block Device:           (0/0)
        Char Device:            (0/0)
        FIFO:                   (0/0)
        Socket:                 (0/0)
        Whiteout:               (0/0)
        Unknown:                (0/0)'
JobId 1: LOG_MESSAGE: '
        Dir Depth (count)
        ----------------------------
        Total Dirs:             447
        Max Depth:              10

        File Size (count)
        ----------------------------
        == 0                    14
        <= 8k                   1814
        <= 64k                  658
        <= 1M                   267
        <= 20M                  10
        <= 100M                 0
        <= 1G                   0
         > 1G                   2
        -------------------------
        Total Files:            2765
        Total Bytes:            10827843824
        Max Size:               5368709120
        Mean Size:              3916037'
JobId 1: LOG_MESSAGE: '
        File History
        ----------------------------
        Num FH_HIST_FILE messages:              3212
        Num FH_HIST_DIR  messages:              0
        Num FH_HIST_NODE messages:              0'
JobId 1: Async request NDMP4_NOTIFY_MOVER_HALTED
JobId 1: DATA: bytes 10581729KB  MOVER: written 10581732KB record 167964
JobId 1: Operation done, cleaning up
JobId 1: Waiting for operation to halt
JobId 1: Commanding tape drive to NDMP9_MTIO_EOF 2 times
JobId 1: Commanding tape drive to rewind
JobId 1: Closing tape drive HP-TLD-004-01
JobId 1: Commanding robot to unload drive @256 to slot @4148
JobId 1: robot moving @256 to @4148
JobId 1: robot move OK @256 to @4148
JobId 1: Operation halted, stopping
JobId 1: Operation ended OKAY
JobId 1:  ERR-CONN NDMP4_CONNECT_CLOSE  exchange-failed
JobId 1: media #1 BT0001+1/4834053K@4146
JobId 1:          valid label=Y filemark=Y n_bytes=Y slot=Y
JobId 1:          media used=Y written=Y eof=N eom=Y io_error=N
JobId 1:          label read=Y written=N io_error=N mismatch=N
JobId 1:          fm_error=N nb_determined=Y nb_aligned=N
JobId 1:          slot empty=N bad=N missing=N
JobId 1: media #2 BT0002+1/4834053K@4147
JobId 1:          valid label=Y filemark=Y n_bytes=Y slot=Y
JobId 1:          media used=Y written=Y eof=N eom=Y io_error=N
JobId 1:          label read=Y written=N io_error=N mismatch=N
JobId 1:          fm_error=N nb_determined=Y nb_aligned=N
JobId 1:          slot empty=N bad=N missing=N
JobId 1: media #3 BT0003+1/913626K@4148
JobId 1:          valid label=Y filemark=Y n_bytes=Y slot=Y
JobId 1:          media used=Y written=Y eof=N eom=N io_error=N
JobId 1:          label read=Y written=N io_error=N mismatch=N
JobId 1:          fm_error=N nb_determined=Y nb_aligned=N
JobId 1:          slot empty=N bad=N missing=N
JobId 1: Media: BT0001+1/4834053K@251
JobId 1: Media: BT0002+1/4834053K@252
JobId 1: Media: BT0003+1/913626K@253
JobId 1: ndmp_fhdb_lmdb.c:675 Now processing lmdb database
JobId 1: ndmp_fhdb_lmdb.c:679 Processing lmdb database done
JobId 1: Bareos bareos-dir 17.2.3:
  Build OS:               x86_64-unknown-linux-gnu redhat Red Hat Enterprise Linux Server release 6.8 (Santiago)
  JobId:                  1
  Job:                    ndmp.2017-04-07_01.40.31_10
  Backup Level:           Full
  Client:                 "isilon"
  FileSet:                "isilon" 2017-04-07 01:40:31
  Pool:                   "NDMP-Tape" (From Job resource)
  Catalog:                "MyCatalog" (From Client resource)
  Storage:                "isilon" (From Job resource)
  Scheduled time:         07-Apr-2017 01:40:31
  Start time:             07-Apr-2017 01:40:33
  End time:               07-Apr-2017 01:42:03
  Elapsed time:           1 min 30 secs
  Priority:               10
  NDMP Files Written:     3,212
  NDMP Bytes Written:     10,835,690,496 (10.83 GB)
  Rate:                   120396.6 KB/s
  Volume name(s):         BT0001|BT0002|BT0003
  Volume Session Id:      0
  Volume Session Time:    0
  Last Volume Bytes:      935,553,024 (935.5 MB)
  Termination:            Backup OK
\end{bconsole}



\subsection{Run NDMP\_NATIVE Restore}

Now we want to restore some files from the backup we just did:

\begin{bconsole}{run ndmp restore job}
*<input>restore</input>
[...]

cwd is: /
: mark /ifs/home/testdata/git/bareos/src/console/bconsole
1 file marked.
: mark /ifs/home/testdatrandom5G-2
1 file marked.
$ done
Connecting to Director bareos:9101
1000 OK: bareos-dir Version: 17.2.3
Enter a period to cancel a command.
list joblog jobid=2
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
JobId 2: Start Restore Job ndmp-restore.2017-04-07_01.48.23_13
JobId 2: Namelist add: node:6033532893, info:5464882688, name:"/ifs/home/testdata/random5G-2"
JobId 2: Namelist add: node:6033077461, info:40076288, name:"/ifs/home/testdata/git/bareos/src/console/bconsole"
JobId 2: Record size is 64512
JobId 2: Media: BT0001+1/4834053K@251
JobId 2: Media: BT0002+1/4834053K@252
JobId 2: Media: BT0003+1/913626K@253
JobId 2: Logical slot for volume BT0001 is 251
JobId 2: Physical(NDMP) slot for volume BT0001 is 4146
JobId 2: Media Index of volume BT0001 is 1
JobId 2: Logical slot for volume BT0002 is 252
JobId 2: Physical(NDMP) slot for volume BT0002 is 4147
JobId 2: Media Index of volume BT0002 is 2
JobId 2: Logical slot for volume BT0003 is 253
JobId 2: Physical(NDMP) slot for volume BT0003 is 4148
JobId 2: Media Index of volume BT0003 is 3
JobId 2: Commanding robot to load slot @4146 into drive @256
JobId 2: robot moving @4146 to @256
JobId 2: robot move OK @4146 to @256
JobId 2: Opening tape drive HP-TLD-004-01 read-only
JobId 2: Commanding tape drive to rewind
JobId 2: Checking tape label, expect 'BT0001'
JobId 2: Reading label
JobId 2: Commanding tape drive to rewind
JobId 2: Commanding tape drive to NDMP9_MTIO_FSF 1 times
JobId 2: Waiting for operation to start
JobId 2: Operation started
JobId 2: Monitoring recover
JobId 2: DATA: bytes 0KB  MOVER: read 0KB record 0
JobId 2: DATA: bytes 11KB  MOVER: read 11KB record 622
JobId 2: Mover paused, reason=NDMP9_MOVER_PAUSE_SEEK
JobId 2: Operation requires a different tape
JobId 2: Commanding tape drive to rewind
JobId 2: Closing tape drive HP-TLD-004-01
JobId 2: Commanding robot to unload drive @256 to slot @4146
JobId 2: robot moving @256 to @4146
JobId 2: robot move OK @256 to @4146
JobId 2: Commanding robot to load slot @4147 into drive @256
JobId 2: robot moving @4147 to @256
JobId 2: robot move OK @4147 to @256
JobId 2: Opening tape drive HP-TLD-004-01 read-only
JobId 2: Commanding tape drive to rewind
JobId 2: Checking tape label, expect 'BT0002'
JobId 2: Reading label
JobId 2: Commanding tape drive to rewind
JobId 2: Commanding tape drive to NDMP9_MTIO_FSF 1 times
JobId 2: Operation resuming
JobId 2: DATA: bytes 79884KB  MOVER: read 79884KB record 85979
JobId 2: DATA: bytes 201740KB  MOVER: read 201740KB record 87914
JobId 2: DATA: bytes 321548KB  MOVER: read 321548KB record 89815
JobId 2: DATA: bytes 440332KB  MOVER: read 440332KB record 91701
JobId 2: DATA: bytes 556044KB  MOVER: read 556044KB record 93538
JobId 2: DATA: bytes 674828KB  MOVER: read 674828KB record 95423
JobId 2: DATA: bytes 796684KB  MOVER: read 796684KB record 97357
JobId 2: DATA: bytes 915468KB  MOVER: read 915468KB record 99243
JobId 2: DATA: bytes 1036300KB  MOVER: read 1036300KB record 101161
JobId 2: DATA: bytes 1157132KB  MOVER: read 1157132KB record 103079
JobId 2: DATA: bytes 1277964KB  MOVER: read 1277964KB record 104997
JobId 2: DATA: bytes 1398796KB  MOVER: read 1398796KB record 106915
JobId 2: DATA: bytes 1518604KB  MOVER: read 1518604KB record 108816
JobId 2: DATA: bytes 1622028KB  MOVER: read 1622028KB record 110458
JobId 2: DATA: bytes 1741836KB  MOVER: read 1741836KB record 112360
JobId 2: DATA: bytes 1859596KB  MOVER: read 1859596KB record 114229
JobId 2: DATA: bytes 1981452KB  MOVER: read 1981452KB record 116163
JobId 2: DATA: bytes 2094092KB  MOVER: read 2094092KB record 117951
JobId 2: DATA: bytes 2207756KB  MOVER: read 2207756KB record 119755
JobId 2: DATA: bytes 2328588KB  MOVER: read 2328588KB record 121673
JobId 2: DATA: bytes 2448396KB  MOVER: read 2448396KB record 123575
JobId 2: DATA: bytes 2569228KB  MOVER: read 2569228KB record 125493
JobId 2: DATA: bytes 2689036KB  MOVER: read 2689036KB record 127395
JobId 2: DATA: bytes 2810892KB  MOVER: read 2810892KB record 129329
JobId 2: DATA: bytes 2926604KB  MOVER: read 2926604KB record 131165
JobId 2: DATA: bytes 3043340KB  MOVER: read 3043340KB record 133018
JobId 2: DATA: bytes 3163148KB  MOVER: read 3163148KB record 134920
JobId 2: DATA: bytes 3279884KB  MOVER: read 3279884KB record 136773
JobId 2: DATA: bytes 3400716KB  MOVER: read 3400716KB record 138691
JobId 2: DATA: bytes 3518476KB  MOVER: read 3518476KB record 140560
JobId 2: DATA: bytes 3636236KB  MOVER: read 3636236KB record 142429
JobId 2: DATA: bytes 3757068KB  MOVER: read 3757068KB record 144347
JobId 2: DATA: bytes 3877900KB  MOVER: read 3877900KB record 146265
JobId 2: DATA: bytes 3994636KB  MOVER: read 3994636KB record 148118
JobId 2: DATA: bytes 4116492KB  MOVER: read 4116492KB record 150053
JobId 2: DATA: bytes 4237324KB  MOVER: read 4237324KB record 151971
JobId 2: DATA: bytes 4331317KB  MOVER: read 4331317KB record 153462
JobId 2: Mover paused, reason=NDMP9_MOVER_PAUSE_SEEK
JobId 2: Operation requires a different tape
JobId 2: Commanding tape drive to rewind
JobId 2: Closing tape drive HP-TLD-004-01
JobId 2: Commanding robot to unload drive @256 to slot @4147
JobId 2: robot moving @256 to @4147
JobId 2: robot move OK @256 to @4147
JobId 2: Commanding robot to load slot @4148 into drive @256
JobId 2: robot moving @4148 to @256
JobId 2: robot move OK @4148 to @256
JobId 2: Opening tape drive HP-TLD-004-01 read-only
JobId 2: Commanding tape drive to rewind
JobId 2: Checking tape label, expect 'BT0003'
JobId 2: Reading label
JobId 2: Commanding tape drive to rewind
JobId 2: Commanding tape drive to NDMP9_MTIO_FSF 1 times
JobId 2: Operation resuming
JobId 2: DATA: bytes 4424716KB  MOVER: read 4424716KB record 154945
JobId 2: DATA: bytes 4544524KB  MOVER: read 4544524KB record 156847
JobId 2: DATA: bytes 4663308KB  MOVER: read 4663308KB record 158732
JobId 2: DATA: bytes 4781068KB  MOVER: read 4781068KB record 160601
JobId 2: DATA: bytes 4902924KB  MOVER: read 4902924KB record 162536
JobId 2: DATA: bytes 5022732KB  MOVER: read 5022732KB record 164437
JobId 2: DATA: bytes 5138444KB  MOVER: read 5138444KB record 166274
JobId 2: OK: /testdata/git/bareos/src/console/bconsole
JobId 2: OK: /testdata/random5G-2
JobId 2: LOG_MESSAGE: 'Filetransfer: Transferred 5368721181 bytes in 223.436 seconds throughput of 23464.803 KB/s'
JobId 2: LOG_MESSAGE: '
        Objects:
        ----------------------------
        Regular Files:          (2)
        Stub Files:             (0)
        Directories:            (0)
        ADS Entries:            (0)
        Soft Links:             (0)
        Hard Links:             (0)
        Block Device:           (0)
        Char Device:            (0)
        FIFO:                   (0)
        Socket:                 (0)
        Unknown:                (0)'
JobId 2: LOG_MESSAGE: '
        File Size (count)
        ----------------------------
        == 0                    0
        <= 8k                   1
        <= 64k                  0
        <= 1M                   0
        <= 20M                  0
        <= 100M                 0
        <= 1G                   0
         > 1G                   1
        -------------------------
        Total Files:            2
        Total Bytes:            5368716925
        Max Size:               5368709120
        Mean Size:              2684358462'
JobId 2: Async request NDMP4_NOTIFY_MOVER_HALTED
JobId 2: DATA: bytes 5242893KB  MOVER: read 5242893KB record 167932
JobId 2: Operation done, cleaning up
JobId 2: Waiting for operation to halt
JobId 2: Commanding tape drive to rewind
JobId 2: Closing tape drive HP-TLD-004-01
JobId 2: Commanding robot to unload drive @256 to slot @4148
JobId 2: robot moving @256 to @4148
JobId 2: robot move OK @256 to @4148
JobId 2: Operation halted, stopping
JobId 2: Operation ended OKAY
JobId 2:  ERR-CONN NDMP4_CONNECT_CLOSE  exchange-failed
JobId 2: LOG_FILE messages: 2 OK, 0 ERROR, total 2 of 2
JobId 2: media #1 BT0001+1/4834053K@4146
JobId 2:          valid label=Y filemark=Y n_bytes=Y slot=Y
JobId 2:          media used=Y written=N eof=N eom=N io_error=N
JobId 2:          label read=Y written=N io_error=N mismatch=N
JobId 2:          fm_error=N nb_determined=N nb_aligned=N
JobId 2:          slot empty=N bad=N missing=N
JobId 2: media #2 BT0002+1/4834053K@4147
JobId 2:          valid label=Y filemark=Y n_bytes=Y slot=Y
JobId 2:          media used=Y written=N eof=N eom=N io_error=N
JobId 2:          label read=Y written=N io_error=N mismatch=N
JobId 2:          fm_error=N nb_determined=N nb_aligned=N
JobId 2:          slot empty=N bad=N missing=N
JobId 2: media #3 BT0003+1/911610K@4148
JobId 2:          valid label=Y filemark=Y n_bytes=Y slot=Y
JobId 2:          media used=Y written=N eof=N eom=N io_error=N
JobId 2:          label read=Y written=N io_error=N mismatch=N
JobId 2:          fm_error=N nb_determined=Y nb_aligned=N
JobId 2:          slot empty=N bad=N missing=N
JobId 2: Bareos bareos-dir 17.2.3:
  Build OS:               x86_64-unknown-linux-gnu redhat Red Hat Enterprise Linux Server release 6.8 (Santiago)
  JobId:                  2
  Job:                    ndmp-restore.2017-04-07_01.48.23_13
  Restore Client:         isilon
  Start time:             07-Apr-2017 01:48:25
  End time:               07-Apr-2017 01:52:11
  Elapsed time:           3 mins 46 secs
  Files Expected:         2
  Files Restored:         1
  Bytes Restored:         5,368,722,944
  Rate:                   23755.4 KB/s
\end{bconsole}
\hide{$}

\subsection{Limitations}

\limitation*{NDMP\_NATIVE}{Only use the first tape drive will be used}{%
A NDMP job only uses a single tape drive. Currently, a Bareos job always uses the first defined tape drive of the \TapeAgent.}



\section{NDMP Common}

This section contains additional information about the Bareos NDMP implementation that are valid for all Bareos NDMP protocols.

\subsection{NDMP Backup Level}
\label{sec:NdmpBackupLevel}
\index[general]{NDMP!Level}

The trailing number in the main backup file (after the \path|%| character)
indicates the NDMP backup level:

\begin{tabular}{c | l}
\hline
Level & Description \\
\hline
0 & Full NDMP backup. \\
1 & Differential or first Incremental backup.\\
2-9 & second to ninth Incremental backup.\\
\hline
\end{tabular}

\paragraph{Differential Backups}
 are supported.
The NDMP backup level will be 1,
visible as trailing number in the backup file (\path|/@NDMP/ifs/home%1|).

\paragraph{Incremental Backups}
 are supported.
The NDMP backup level will increment with each run, until a Full (0) or Differential (1) will be made.
The maximum backup level will be 9.
Additional Incremental backups will result in a failed job and the message:
\begin{bmessage}{}
 2016-01-21 13:35:51 bareos-dir JobId 12: Fatal error: NDMP dump format doesn't support more than 8 incrementals, please run a Differential or a Full Backup
\end{bmessage}


\subsection{NDMP Debugging}

To debug the NDMP backups, these settings can be adapted:

\begin{itemize}
\item \linkResourceDirective{Dir}{Director}{NDMP Snooping}
\item \linkResourceDirective{Dir}{Director}{NDMP Log Level}
\item \linkResourceDirective{Dir}{Client}{NDMP Log Level}
\item \linkResourceDirective{Sd}{Storage}{NDMP Snooping}
\item \linkResourceDirective{Sd}{Storage}{NDMP Log Level}
\end{itemize}

This will create a lot of debugging output that will help to find the problem during NDMP backups.


\subsection{Bareos NDMP Common Limitations}
\label{sec:NdmpCommonLimitations}

\subsubsection{NDMP Fileset limitations}

\limitation*{NDMP}{A NDMP fileset should only contain a single File directive and Meta options}{%
Using multiple \linkResourceDirective{Dir}{FileSet}{Include} \configdirective{File} directives should be avoided.
The \bareosDir would try to handle them by running multiple NDMP jobs in a single Bareos job.
Even if this is working fine during backup, restore jobs will cause trouble.

Normally (\linkResourceDirective{Dir}{Client}{Protocol}=Native) Filesets get handled by the \bareosFd. When connecting directly to a NDMP Clients (\linkResourceDirective{Dir}{Client}{Protocol}=NDMP*), no \bareosFd is involved and therefore most Fileset options can't be used. Instead, parameters are handled via \configdirective{Options - Meta} from \linkResourceDirective{Dir}{FileSet}{Include}.
}

\subsubsection{Single file restore on incremental backups}

\limitation*{NDMP}{No single file restore on merged backups}{%
Unfortunately, it is currently (bareos-15.2.2) not possible to restore a chain of Full and Incremental backups at once.
The workaround for that problem is to restore the full backup and each incremental each in a single restore operation.
}

\subsubsection{Temporary memory mapped database}

\limitation*{NDMP}{64-bit system recommended}{%
The \bareosDir uses a memory mapped database (LMBD) to temporarily store NDMP file information.
On some 32-bit systems the default \linkResourceDirective{Dir}{Job}{File History Size} requires a larger memory area than available.
In this case, you either have to lower the \linkResourceDirective{Dir}{Job}{File History Size}
or preferably run the \bareosDir on a 64-bit system.
}

\subsection{Tested Environments}

Bareos NDMP support have been tested against:

\begin{tabular}{l | l | l | l | l | l | l}
\hline
Vendor     & Product                       & NDMP Subsystem       & Bareos version & \TapeAgent     & Features & Remarks \\
\hline
Isilon     & Isilon OneFS v7.2.1.4         & Isilon NDMP 2.2.1    & bareos-17.2.3  & Isilon Backup Accelerator & & Protocol: \NdmpNative\\

Isilon     & Isilon OneFS v7.2.0.1         & Isilon NDMP 2.2      & bareos-16.2.6  & \bareosSd &        & \\
Isilon     & Isilon OneFS v7.1.1.5         & Isilon NDMP 2.2      & bareos-15.2.2  & \bareosSd &          & \\
NetApp     &                               & Release 8.2.3 7-Mode & bareos-15.2.2  & \bareosSd &          & \\
Oracle/Sun & ZFS Storage Appliance, OS 8.3 &                      & bareos-15.2.2  & \bareosSd &          & \\
\hline
\end{tabular}