summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakbackup
blob: ed3842af6ddabae9dc6706a8be3f9701d146e026 (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
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
#!/usr/bin/perl
#
#  Copyright (C) 2001 by Sebastien DUPONT <sdupont@mandrakesoft.com>
#  Redistribution of this file is permitted under the terms of the GNU
#  Public License (GPL)
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2, or (at your option)
#  any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#________________________________________________________________
#
#  Description:
#
#   Drakbacup is use to backup your system.
#   During the configuration you can select 
# 	- System files, 
# 	- Users files, 
# 	- Other files.
# 	or All your system ...  and Other (like windows Partitions)
#
#   Drakbacup allow you to backup your system on:
# 	- Harddrive.
# 	- NFS.
# 	- CDROM (CDRW), DVDROM (with autoboot, rescue and autoinstall.).
# 	- FTP.
# 	- Rsync.
# 	- Webdav.
# 	- Tape.
#
#   Drakbacup allow you to Restore your system on
#   choosen directory.
#
#   Per default all backup will be stored on your
#   /var/drakbackup directory
#
#   configuration file:
# 	/etc/drakconf/drakbackup/drakbakup.conf
#
#________________________________________________________________
#
#  backup files formats:
#	
#	no incremental backup:
#			backup_sys_date_hour.tar.*
#			backup_user_toto_date_hour.tar.*
#			backup_other_date_hour.tar.*
#
#	first incremental backup: (if backup_base* does not exist )
#
#			backup_base_sys_date_hour.tar.*
#			backup_base_user_toto_date_hour.tar.*
#			backup_base_other_date_hour.tar.*
#			
#	other incremental backup: (if backup_base* already exist )
#
#			backup_incr_sys_date_hour.tar.*
#			backup_incr_user_toto_date_hour.tar.*
#			backup_incr_other_date_hour.tar.*
#
#________________________________________________________________
# 
# REQUIRE:      cron if daemon
#               cdrecord & mkisofs
#		ftp || perl Net::FTP
#		ssh-askpass
#
# PBS persistants:
#		selection des sources a inclure dans le backup cd. 
#		et dans le restore_step_user
#
#
# WARNING:      ne pas ecraser les fichiers /etc/passwd fstab 
#               after a other install
#
#
# TODO:
#		during restore step catch the most recent date
#		and put in list all backup between the fisrt date 
#		and the select date.
#		1bis - refaire en clist.
#		3 - add port for ftp backup.
#		4 - change NET::FTP to ftp cmds.  
#		5 - add icons (win & lin) on adv_what_all.
#	        6 - calcul disk space.
#		   use quota.
#               7 - ssh & rsync -> expect or .identity.pub/authorized_keys 
#		8 - write on cd
#		9 - cd writer detection  -> cdrw: /sys/dev/cdrom/info  /scsi/host0/bus0/target4/lun0 
#		10- total backup.( all partitions wanted, windows partitions for example!)
#		    dump use for total backup.
#		11- send mail with results.
#		12- custom deamon
#		13- placer README dans $save_path -> prevenir des danger de supprimer la premier version
#		    explain configuration file variables (mainly for non X users)
#		13bis -  option mode update tar u ....
#		14- webdav
#	        15- backend : --resore_all, --restore_sys, --restore_users
#			  --build_cd_autoinst 	
#			  --backup_now --backup_default_now
#		16- tape device support
#		17- cpio use !!
#		18- boot floppy disk (with dialog)
#		19- build autoboot with backup and install cd 
#		20- use .backupignore like on CVS
#
#		               
# DONE TODAY:
#________________________________________________________________


use Gtk;
use lib qw(/usr/lib/libDrakX );
use interactive;
use standalone;
use my_gtk qw(:helpers :wrappers);
use common;
use strict;
use Time::localtime;

my $in = 'interactive'->vnew('', 'default');
$::isEmbedded = ($::XID, $::CCPID) = "@ARGV" =~ /--embedded (\w+) (\w+)/;


if ("@ARGV" =~ /--help|-h/) {
    print q(Backup and monitoring application

--list           : list of files or directories to backup.
--default        : save default directories.
--build_cd       : build restore iso with the currents backups files
                       & rescue options.
--build_floppy   : build restore floppy.
--save_dir       : by default the backup files are saved in 
                       in /var/backup directory so write other directory
	               to change to change it.
--conf_file      : to read other configuration file. 
);
    exit(0);
}

# Backend Options.
my $default = 0;
my $build_cd = 0;
my $build_floppy = 0;
my $mode = 0;
my $conf_file = 0;
my @list_arg = ();
my $central_widget;
my $previous_widget;
my $current_widget;
my $interactive;
my $up_box;
my $advanced_box;
my $box;
my $box2;
my $backup_choice = 0;
my $cfg_file_exist = 0;
my @user_and_path_list;
my @all_user_list;
my $list_other;
my $label_cfg_file;
my $DEBUG = 0;
my $restore_sys = 1; 
my $restore_user = 1; 
my $restore_other = 1; 
my $restore_step_sys_date = "";
my @user_backuped = ();
my @sys_backuped = ();
my $sys_backuped = 0;
my $other_backuped = 0;
my @user_list_to_restore= ();
my $retore_box2;
my $cd_devive_entry;
my $custom_help;
my $button_box;
my $button_box_tmp;
my $next_widget;
my $system_state;
my $restore_state;
my $save_path_entry;
my $restore_find_path_entry;
my $pbar;
my $pbar1;
my $pbar2;
my $pbar3;
my $the_time;
my @user_list_to_restore2 = ();
my @data_backuped = ();
my $box_tail; 
my $label_tail;
my @user_list_to_build_on_cd = (); 
my $restore_path = "/";
my $restore_other_path = 0;
my $restore_other_src;
my $path_to_find_restore;
my $other_media_hd;
my $backup_bef_restore = 0;
my $table;

# config. FILES -> Default PATH  & Global variables.
my @sys_files = ("/etc");
my @user_list;
my @list_other = () ;
my $cfg_file = "/etc/drakxtools/drakbackup/drakbackup.conf";
my $save_path = "/var/drakbackup";
my $restore_path = "/tmp";
my $comp_mode = 0;
my $backup_sys = 1;
my $backup_user = 1;
my $backup_daemon = 1;
my $backup_sys_versions = 0;
my $backup_user_versions = 0;
my $backup_other_versions = 0;
my $what_no_browser = 1;
my $cdrw = 0;
my $net_proto= '';
my $host_path = '';
my $login_user = '';
my $net_daemon = 0;
my $hd_daemon = 0;
my $cd_daemon = 0;
my $hd_quota = 0;
my $where_net_ftp = 0;
my $where_net_ssh = 0;
my $where_net = 0;
my $where_hd = 1;
my $where_cd = 0;
my $where_tape = 0;
my $cd_time = 650;
my $when_space;
my $cd_with_install_boot = 0;
my $cd_devive = '';
my $host_name = '';
my $backupignore = 0; 
my $auth_choice = 0;
my $remember_pass = 0;
my $passwd_user= '';
my $save_device_tape = ();
my $cdrw_erase = 0;
my $no_critical_sys = 1;


foreach (@ARGV) {
    /--default/ and $default = 1, $mode=-1;
    /--build_cd/ and $build_cd = 1, $mode=-1;
    /--build_floppy/ and $build_floppy = 1, $mode=-1;
    /--conf_file/ and $mode = 0, next;
    /--list/ and $mode = 1, next;
    /--debug/ and $DEBUG = 1, next;
    $mode == 1 and push @list_arg, $_;
}

$build_floppy || $build_cd || $default || @list_arg || $conf_file ? backend_mod() : interactive_mode();

sub read_passwd {
    my @tmp1;
    my @tmp2;
    @user_and_path_list = map { (split(':', $_))[0] . ":" . (split(':', $_))[5] } grep {( split(':', $_))[2] > 500} split ('\n', cat_('/etc/passwd'));  
    $DEBUG and print "user_and_path_list: ".$_."\n" foreach (@user_and_path_list);
    @user_list = ();
    @all_user_list = ();
    push @user_and_path_list, 'root:/root';
    push @user_list, (split(':', $_))[0] foreach (@user_and_path_list);
    push @all_user_list, (split(':', $_))[0] foreach (@user_and_path_list);
    @tmp1 = sort @user_list;
    @user_list = @tmp1;
    @tmp2 = sort @all_user_list;
    @all_user_list = @tmp2;
}

sub the_time {
    $the_time = "_";
    $the_time .= localtime->year() + 1900;
    $the_time .= localtime->mon() +1;
    $the_time .= localtime->mday();
    $the_time .= "_";
    if (localtime->hour() <= 10 ) { $the_time .= "0"; }
    $the_time .= localtime->hour();
    if (localtime->min() <= 10 ) { $the_time .= "0"; }
    $the_time .= localtime->min();

    
}

sub save_conf_file {
    my @cfg_list = ( "SYS_FILES=@sys_files\n",
		     "HOME_FILES=@user_list\n", 
		     "OTHER_FILES=@list_other\n",
		     "PATH_TO_SAVE=$save_path\n",
		     "HOST_PATH=$host_path\n",
		     "NET_PROTO=$net_proto\n",
		     "CD_TIME=$cd_time\n",
		     "DAEMON_TIME_SPACE=$when_space\n",
		     "CDRW_DEVICE=$cd_devive\n",
		     "LOGIN=$login_user\n",
		     "TAPE_DEVICE=$save_device_tape\n",
		     "HOST_NAME=$host_name\n"
		     );
    $no_critical_sys and push @cfg_list, "NO_CRITICAL_SYS\n" ; 
    $no_critical_sys or push @cfg_list, "CRITICAL_SYS\n" ; 
    $backup_sys_versions and push @cfg_list, "SYS_INCREMENTAL_BACKUPS\n" ; 
    $backup_user_versions and push @cfg_list, "USER_INCREMENTAL_BACKUPS\n" ; 
    $backup_other_versions  and push @cfg_list, "OTHER_INCREMENTAL_BACKUPS\n" ; 
    $cdrw_erase and push @cfg_list, "CDRW_ERASE\n" ; 
    $where_net_ftp and push @cfg_list, "USE_NET_FTP\n" ; 
    $where_net_ssh and push @cfg_list, "USE_NET_SSH\n" ; 
    $remember_pass and push @cfg_list, "LOGIN=$login_user\n" ; 
    $remember_pass and push @cfg_list, "PASSWD=$passwd_user\n" ;
    $remember_pass and push @cfg_list, "REMEMBER_PASS\n" ;
    $auth_choice or push @cfg_list, "AUTH_CHOICE=0\n" ;
    if ($auth_choice == 1) { push @cfg_list, "AUTH_CHOICE=1\n" ;}
    if ($auth_choice == 2) { push @cfg_list, "AUTH_CHOICE=2\n" ;}
    $cd_with_install_boot and push @cfg_list, "CD_WITH_INSTALL_BOOT\n" ;
    $net_daemon and push @cfg_list, "NET_DAEMON\n" ;
    $hd_daemon and push @cfg_list, "HD_DAEMON\n" ;
    $cd_daemon and push @cfg_list, "CD_DAEMON\n" ;
    $hd_quota and  push @cfg_list, "HD_QUOTA\n" ;
    $where_hd and  push @cfg_list, "USE_HD\n" ;
    $where_cd and  push @cfg_list, "USE_CD\n" ;
    $where_net and  push @cfg_list, "USE_NET\n" ;
    $cdrw and push @cfg_list, "CDRW\n"; 
    $what_no_browser or push @cfg_list, "BROWSER_CACHE\n" ;
    $backup_sys or push @cfg_list,  "NO_SYS_FILES\n";
    if ($comp_mode) {push @cfg_list, "OPTION_COMP=TAR.BZ2\n"} 
    else { push @cfg_list, "OPTION_COMP=TAR.GZ\n"   }
    output_p($cfg_file, @cfg_list);
    save_cron_files();
}

sub read_cron_files {
    if (-f '/etc/cron.hourly/drakbackup') { $when_space = 'hourly'; }
    elsif (-f '/etc/cron.daily/drakbackup') { $when_space = 'daily'; }
    elsif (-f '/etc/cron.weekly/drakbackup') { $when_space = 'weekly';}
    elsif (-f '/etc/cron.monthly/drakbackup') { $when_space = 'monthly';}
    else {$backup_daemon = 0; }
}

sub save_cron_files {
    my @cron_file = ("#!/bin/sh\n", "\n", "/seb/cvs/gi/perl-install/standalone --default" );

    if ($backup_daemon) {
	foreach ('hourly', 'daily', 'weekly', 'monthly'){
	    -f "/etc/cron.$_/drakbackup" and rm_rf("/etc/cron.$_/drakbackup");
	}
	if ( $when_space eq _("hourly"))     { output_p('/etc/cron.hourly/drakbackup',  @cron_file )}
	elsif ( $when_space eq _("daily"))   { output_p('/etc/cron.daily/drakbackup',   @cron_file )}
	elsif ( $when_space eq _("weekly"))  { output_p('/etc/cron.weekly/drakbackup',  @cron_file )}
	elsif ( $when_space eq _("monthly")) { output_p('/etc/cron.monthly/drakbackup', @cron_file )}
    } else {
	foreach ('hourly', 'daily', 'weekly', 'monthly'){
	    -f "/etc/cron.$_/drakbackup" and rm_rf("/etc/cron.$_/drakbackup");
	}
    }
}

sub read_conf_file {
    read_passwd();
    if (-e $cfg_file) {
        open ( CONF_FILE, "<"."$cfg_file") || die;
        while (<CONF_FILE>) {
	    next unless /\S/;
	    next if /^#/;
	    chomp;
	    if (/^SYS_FILES/)      { s/^SYS_FILES=//gi;    @sys_files = split(' ', $_ );	}
	    if (/^HOME_FILES/)     { s/^HOME_FILES=//gi;   @user_list = split(' ', $_ );	}
	    if (/^OTHER_FILES/)    { s/^OTHER_FILES=//gi;  @list_other = split(' ', $_ );	}
	    if (/^PATH_TO_SAVE/)   { s/^PATH_TO_SAVE=//gi; $save_path = $_;	}
	    if (/^NO_SYS_FILES/)   { $backup_sys = 0;}
	    if (/^NO_USER_FILES/)  { $backup_user = 0;}
	    if (/^OPTION_COMP/)    { s/^OPTION_COMP=//gi; /TAR.GZ/ and  $comp_mode = 0; /TAR.BZ2/ and $comp_mode = 1; }
	    if (/^BROWSER_CACHE/)  { $what_no_browser = 0; }
	    if (/^CDRW/)           { $cdrw = 1; }
	    if (/^NET_PROTO/)      { s/^NET_PROTO=//gi; $net_proto = $_; }
	    if (/^HOST_PATH/)      { s/^HOST_PATH=//gi; $host_path = $_; } 
	    if (/^NET_DAEMON/)	   { $net_daemon = 1; }
	    if (/^HD_DAEMON/)	   { $hd_daemon = 1; }
	    if (/^CD_DAEMON/)	   { $cd_daemon = 1; }
	    if (/^HD_QUOTA/)       { $hd_quota = 1;  }
	    if (/^USE_HD/)         { $where_hd = 1;  }
	    if (/^USE_CD/)         { $where_cd = 1;  }
	    if (/^USE_NET/)        { $where_net = 1; }
	    if (/^USE_TAPE/)       { $where_tape = 1; }
	    if (/^CD_TIME/)        { s/^CD_TIME=//gi; $cd_time = $_; }
	    if (/^DAEMON_TIME_SPACE/) { s/^DAEMON_TIME_SPACE=//gi; $when_space = $_; }
	    if (/^CD_WITH_INSTALL_BOOT/) { $cd_with_install_boot = 1; }
	    if (/^CDRW_DEVICE/)    { s/^CDRW_DEVICE=//gi; $cd_devive = $_;}
	    if (/^HOST_NAME/)      { s/^HOST_NAME=//gi; $host_name = $_;} 
	    if (/^AUTH_CHOICE/)    { s/^AUTH_CHOICE=//gi; $auth_choice = $_; }
	    if (/^REMEMBER_PASS/)  { $remember_pass = 1; }
	    if (/^LOGIN/)          { s/^LOGIN=//gi;  $login_user  = $_; $remember_pass = 1; }
	    if (/^PASSWD/)         { s/^PASSWD=//gi; $passwd_user = $_; $remember_pass = 1; }
	    if (/^USE_NET_FTP/)    { $where_net_ftp = 1;  }
	    if (/^USE_NET_SSH/)    { $where_net_ssh = 1;  }
	    if (/^TAPE_DEVICE/)    { s/TAPE_DEVICE=//gi; $save_device_tape = $_;}
	    if (/^CDRW_ERASE/)     { $cdrw_erase = 1;}
	    if (/^SYS_INCREMENTAL_BACKUPS/)   { $backup_sys_versions = 1;}
	    if (/^USER_INCREMENTAL_BACKUPS/)  { $backup_user_versions = 1;}
	    if (/^OTHER_INCREMENTAL_BACKUPS/) { $backup_other_versions = 1;}
	    if (/^NO_CRITICAL_SYS/)  { $no_critical_sys = 1;}
	    if (/^CRITICAL_SYS/)  { $no_critical_sys = 0;}
	}
	read_cron_files();
	$cfg_file_exist = 1;
    } 
    else { $cfg_file_exist = 0; }
    close CONF_FILE;    
}

sub return_path {
    my $name = $_; 
    foreach (@user_and_path_list) {
	if (grep /^$name\:/, $_) {
	    s/^$name\://gi;
	    return $_;
	}
    }
}

sub ftp_client {
    use Net::FTP; 
    my $ftp = Net::FTP->new("$host_name"); 
    $ftp->login("$login_user","$passwd_user"); 
    $ftp->cwd("$host_path"); 
#   $ftp->get("/ce/repertoire/ce.fichier"); 
    $ftp->send("$save_path/*"); 
    $ftp->quit; 
}

sub return_file_date {
    my($more_recent) = @_;
    my $file_date;
    $_ = $more_recent;
    s/backup\_incr\_sys\_//gi;
    s/backup\_base\_sys\_//gi;
    s/backup\_incr\_user\_//gi;
    s/backup\_base\_user\_//gi;
    s/.tar.\w+$//gi;
    s/\_/ /gi;
    my $date = substr($_, 0, 8);
    my $hour = substr($_, 9,  2);
    my $min =  substr($_, 11, 2);
    $file_date = $date . ' ' . $hour . ':' . $min;
    return $file_date;
}

sub build_backup_files {
    my $path_name;
    my $tar_cmd;
    my $more_recent;
    my $tar_cmd_sys;
    my $tar_cmd_user;
    my $tar_cmd_other;
    my $tar_ext;
    my $vartemp;
    my $base_sys_exist = 0;
    my $base_user_exist = 0;
    my $base_other_exist = 0;
    my @list_temp = ();
    my @list_other_;
    my @dir_content = ();
    my $file_date;

    the_time();    
    -d  $save_path or mkdir_p($save_path);
    if ($comp_mode) { $tar_cmd = "tar cv --use-compress-program /usr/bin/bzip2 "; $tar_ext = "tar.bz2" }
    else { $tar_cmd = "tar cvzp "; $tar_ext = "tar.gz"}
    $tar_cmd_sys = $tar_cmd;
    $tar_cmd_user = $tar_cmd;
    $tar_cmd_other = $tar_cmd;
    $no_critical_sys and $tar_cmd_sys .= "--exclude passwd --exclude fstab --exclude group";
    $what_no_browser and $tar_cmd_user .= "--exclude NewCache --exclude Cache --exclude cache";

    @dir_content = all($save_path);
    grep (/backup_base_sys/, @dir_content) and $base_sys_exist = 1;
    grep (/backup_base_other/, @dir_content) and $base_other_exist = 1;

# fixme use incremental backup   
#tar -cvf tarfilename --after-date="sept 1, 2000" /home
# tar -cf archive.tar --newer="`date -r file`" /home
# algo: liste des fichiers du meme nom, on prend le dernier puis on applique le tar ci-dessus.
# faire fonctions qui retourne le plus recent element.

    if ($where_hd) {
	$interactive and progress($pbar, 0.5, _("Backup system files..."));
	if ($backup_sys) { 
	    if ($backup_sys_versions) {
 		if (grep(/backup_incr_sys/, @dir_content)) { 
		    my @more_recent = grep /backup_incr_sys/, @dir_content; 
		    @list_temp = sort  @more_recent;
 		    $more_recent = pop @list_temp;
		    $file_date = return_file_date($more_recent);
 		}
  		else { 
		    my @more_recent = grep /backup_base_sys/, @dir_content; 
		    $more_recent = @more_recent[0];
		    $file_date = return_file_date($more_recent);
 		}
		if (!$base_sys_exist) { 
		    system("$tar_cmd_sys -f $save_path/backup_base_sys$the_time.$tar_ext @sys_files"); }
		else { 
		    system("$tar_cmd_sys -f $save_path/backup_incr_sys$the_time.$tar_ext --after-date='$file_date'  @sys_files"); }
	    } else {
		system("cd $save_path && rm -f backup_sys* backup_base_sys* backup_incr_sys*");
		system("$tar_cmd_sys -f $save_path/backup_sys$the_time.$tar_ext @sys_files");
	    }
	}

	$interactive and progress($pbar, 0.5, _("Backup system files..."));
	$interactive and progress($pbar3, 0.3, _("Hard Disk Backup files..."));

	if (@list_other) {
#	    if ($backup_other_versions) {
#		$base_other_exist or  system("$tar_cmd_other -f $save_path/backup_base_other$the_time.$tar_ext @list_other");
#		$base_other_exist and system("$tar_cmd_other -f $save_path/backup_incr_other$the_time.$tar_ext @list_other");
#	    } else {
#	    system("cd $save_path && rm -f backup_other* backup_base_other* backup_incr_other*");
#	    system("$tar_cmd_other -f $save_path/backup_other$the_time.$tar_ext @list_other");
#	    }
	    system("cd $save_path && rm -f backup_other* ");
	    system("$tar_cmd_other -f $save_path/backup_other$the_time.$tar_ext @list_other");
	    
	    foreach (@list_other) { push @list_other_, $_ . "\n"; }
	    output_p( $save_path . '/list_other', @list_other_);    
	}
	
	$interactive and progress($pbar1, 1, _("Backup User files..."));
	$interactive and progress($pbar3, 0.3, _("Hard Disk Backup Progress..."));
	
	if ($backup_user) {
	    foreach (@user_list) {
		my $user = $_;
		if (grep (/backup_base_user_$user/, @dir_content)) {  $base_user_exist = 1; }
		else { $base_user_exist = 0; }
		$path_name = return_path($user);
		if ($backup_user_versions) {
		    if (grep(/backup_incr_user/, @dir_content)) { 
			my @more_recent = grep /backup_incr_user/, @dir_content; 
			@list_temp = sort  @more_recent;
			$more_recent = pop @list_temp;
			$file_date = return_file_date($more_recent);
		    }
		    else { 
			my @more_recent = grep /backup_base_user/, @dir_content; 
			$more_recent = @more_recent[0];
			$file_date = return_file_date($more_recent);
		    }
		    if (!$base_user_exist) { 
			system("$tar_cmd_user -f $save_path/backup_base_user_$user$the_time.$tar_ext $path_name");}
		    else { 
			system("$tar_cmd_user -f $save_path/backup_incr_user_$user$the_time.$tar_ext --after-date='$file_date' $path_name");}
		} else {
		    system("cd $save_path && rm -f backup_user_$_* backup_base_user_$_* backup_incr_user_$_*");
		    system("$tar_cmd_user -f $save_path/backup_user_$_$the_time.$tar_ext $path_name");
		}
	    }
	}
	$interactive and progress($pbar2, 1, _("Backup Other files..."));
	$interactive and progress($pbar3, 0.4, _("Hard Disk Backup files..."));
    }

    if ($where_net_ssh) {
#  $res = Net::SSLeay::write($ssl, $msg);  # Perl knows how long $msg is
#         die_if_ssl_error("ssl write");
#         shutdown S, 1;  # Half close --> No more output, sends EOF to server
#         $got = Net::SSLeay::read($ssl);         # Perl returns undef on failure
#         die_if_ssl_error("ssl read");
#         print $got;
                
#         Net::SSLeay::free ($ssl);               # Tear down connection
#         Net::SSLeay::CTX_free ($ctx);
#         close S;
    }
    if ($where_net_ftp) { }
    if ($where_cd)      { }
}

sub list_remove {
    my($widget, $list) = @_;
    my @to_remove;
    push @to_remove, $list->child_position($_) foreach($list->selection);
    splice @list_other, $_, 1 foreach(reverse sort @to_remove);
    $list->remove_items($list->selection);
}

sub file_ok_sel { 
    my ( $widget, $file_selection ) = @_;     
    my $file_name = $file_selection->get_filename();
    if(!member($file_name, @list_other)) {
	push(@list_other, $file_name);
	$list_other->add(gtkshow(new Gtk::ListItem($file_name)));
    }
}

sub filedialog_where_hd {
    my $file_dialog;

    $file_dialog = gtksignal_connect(new Gtk::FileSelection(_("File Selection")), destroy => sub { $file_dialog->destroy(); } );
    $file_dialog->ok_button->signal_connect(clicked => sub { 
	$save_path_entry->set_text($file_dialog->get_filename()); 
	$file_dialog->destroy() });
    $file_dialog->cancel_button->signal_connect(clicked => sub { $file_dialog->destroy() });
    $file_dialog->show();
}

sub filedialog_restore_find_path {
    my $file_dialog;

    $file_dialog = gtksignal_connect(new Gtk::FileSelection(_("File Selection")), destroy => sub { $file_dialog->destroy(); } );
    $file_dialog->ok_button->signal_connect(clicked => sub { 
	$restore_find_path_entry->set_text($file_dialog->get_filename()); 
	$file_dialog->destroy() });
    $file_dialog->cancel_button->signal_connect(clicked => sub { $file_dialog->destroy() });
    $file_dialog->show();
}

sub filedialog {
    my $file_dialog;

    $file_dialog = gtksignal_connect(new Gtk::FileSelection(_("File Selection")), destroy => sub { $file_dialog->destroy(); } );
    $file_dialog->ok_button->signal_connect(clicked => \&file_ok_sel, $file_dialog);
    $file_dialog->ok_button->child->set(_("Add"));
    $file_dialog->cancel_button->signal_connect(clicked => sub { $file_dialog->destroy() });
    $file_dialog->cancel_button->child->set(_("Close"));
    $file_dialog->set_filename(_("Select the files or directories and click on 'Add'"));
    $file_dialog->show();
}

################################################  ADVANCED  ################################################  

sub advanced_what_sys {
    my $box_what_sys;
    
    gtkpack($advanced_box,
	    $box_what_sys = gtkpack_(new Gtk::VBox(0, 15),
				     1, _("\nPlease check all options that you need.\n"),
				     1, _("This options can backup and restore all files on your /etc directory.\n"),
				     0, my $check_what_sys = new Gtk::CheckButton( _("Backup your System files. (~ 2Mo)")),
				     0, my $check_what_versions = new Gtk::CheckButton( _("Use incremental backup  (do not replace old backups)") ),
				     0, my $check_what_critical = new Gtk::CheckButton( _("Do not include critical files (passwd, goup, fstab)") ),
				     0, _("With this option you will be able to restore any version\n of your /etc directory."),
				     1, new Gtk::VBox(0, 15),
				     ),
	    );
    foreach ([$check_what_sys, \$backup_sys], [$check_what_critical, \$no_critical_sys]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; })
	}
    gtksignal_connect(gtkset_active($check_what_versions, $backup_sys_versions), toggled => sub {
	$backup_sys_versions = $backup_sys_versions ? 0 : 1;
    });
    $custom_help = "what";
    $current_widget = \&advanced_what_sys;
    $previous_widget =\&advanced_what;
    $central_widget = \$box_what_sys;
    $up_box->show_all();
}

sub advanced_what_user {
    my ($previous_function) = @_,
    my $box_what_user;
    my %check_what_user;
    
    gtkpack($advanced_box,
	    $box_what_user = gtkpack_(new Gtk::VBox(0, 15),
				      0, _("Please check all user that you want to include inb your backup."),
				      0, new Gtk::HSeparator,
				      1, createScrolledWindow( 
						gtkpack__(new Gtk::VBox(0,0),
							map { my $name = $_;
							      my @user_list_tmp;
							      my $b = new Gtk::CheckButton($name); 
							      if (grep /^$name$/, @user_list) {
								  $check_what_user{$_}[1] = 1;
								  gtkset_active($b, 1);
							      } else {
								  $check_what_user{$_}[1] = 0;
								  gtkset_active($b, 0);
							      }
							      $b->signal_connect(toggled => sub { 
								  if ($check_what_user{$name}[1] ) {
								      $check_what_user{$name}[1] = 0;
								      @user_list_tmp = grep(!/^$name$/, @user_list);
								      @user_list = @user_list_tmp;
								  } else { 
								      $check_what_user{$name}[1] = 1;
								      if (!member($name, @user_list) ) {push @user_list, $name;}
								  }
							      });
							      $b } (@all_user_list) 
							),
							       ),
				      0, my $check_what_browser = new Gtk::CheckButton( _(" do not include the browser cache") ),
				      0, my $check_what_user_versions = new Gtk::CheckButton( _("Use Incremental Backups  (do not replace old backups)") ),
				      ),
	    );
    foreach ([$check_what_browser, \$what_no_browser]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; })
	}
    gtksignal_connect(gtkset_active($check_what_user_versions, $backup_user_versions), toggled => sub {
	$backup_user_versions = $backup_user_versions ? 0 : 1;
    });
    $custom_help = "what";
    if ($previous_function) { $previous_widget =\&$previous_function; $next_widget =\&$previous_function; }
    else { $previous_widget =\&advanced_what; }
    $current_widget = \&advanced_what_user;
    $central_widget = \$box_what_user;
    $up_box->show_all();
}

sub advanced_what_other {
    my $box_what_other;
    $list_other = new Gtk::List();
    $list_other->set_selection_mode(-extended);
    $list_other->add(gtkshow(new Gtk::ListItem($_))) foreach (@list_other);
    
    gtkpack($advanced_box,
	    $box_what_other = gtkpack_(new Gtk::VBox(0, 15),
				  1, gtkpack_(new Gtk::HBox(0,4),
					      1, createScrolledWindow($list_other),
					      ),
				  0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -spread),
					    gtksignal_connect(new Gtk::Button(_("Add")), clicked => sub {filedialog()  }),
					    gtksignal_connect(new Gtk::Button(_("Remove Selected")), clicked => \&list_remove, $list_other),
					    ),
				  0, gtkset_sensitive(my $check_what_other_versions = new Gtk::CheckButton( _("Use Incremental Backups  (do not replace old backups)") ), 0),
				       ),
	    );
    gtksignal_connect(gtkset_active($check_what_other_versions, $backup_other_versions), toggled => sub {
	$backup_other_versions = $backup_other_versions ? 0 : 1;
    });

    $custom_help = "what";
    $current_widget = \&advanced_what_other;
    $previous_widget =\&advanced_what;
    $central_widget = \$box_what_other;
    $up_box->show_all();
}

sub advanced_what_entire_sys{
    my $box_what;
    
    my ($pix_user_map, $pix_user_mask) = gtkcreate_png("user");
    my ($pix_other_map, $pix_other_mask) = gtkcreate_png("net_u");
    my ($pix_sys_map, $pix_sys_mask) = gtkcreate_png("bootloader");

    gtkpack($advanced_box,
	    $box_what = gtkpack_(new Gtk::HBox(0, 15),
				 1, new Gtk::VBox(0, 5),
				 1, gtkpack_(new Gtk::VBox(0, 15),	
					  1, new Gtk::VBox(0, 5),
					  1, gtksignal_connect(my $button_what_other = new Gtk::Button(), 
							       clicked => sub { ${$central_widget}->destroy(); message_underdevel(); }),
					  1, gtksignal_connect(my $button_what_all = new Gtk::Button(), 
							       clicked => sub { ${$central_widget}->destroy(); message_underdevel(); }),
					  1, new Gtk::VBox(0, 5),
					  ),
				 1, new Gtk::VBox(0, 5),	
				 ),
	    );
    $button_what_other->add(gtkpack(new Gtk::HBox(0,10),
				  new Gtk::Pixmap($pix_sys_map, $pix_sys_mask),
				  new Gtk::Label(_(" Linux ")),
				  new Gtk::HBox(0, 5)
				  ));
    $button_what_all->add(gtkpack(new Gtk::HBox(0,10),
				   new Gtk::Pixmap($pix_user_map, $pix_user_mask),
				   new Gtk::Label(_(" Windows (FAT32) ")),
				   new Gtk::HBox(0, 5)
				   ));
    $custom_help = "";
    $current_widget = \&advanced_what_entire_sys;
    $previous_widget =\&advanced_what;
    $central_widget = \$box_what;
    $up_box->show_all();
}

sub advanced_what{
    my $box_what;
    
    my ($pix_user_map, $pix_user_mask) = gtkcreate_png("ic82-users-40");
    my ($pix_other_map, $pix_other_mask) = gtkcreate_png("ic82-others-40");
    my ($pix_sys_map, $pix_sys_mask) = gtkcreate_png("ic82-system-40");
    my ($pix_sysp_map, $pix_sysp_mask) = gtkcreate_png("ic82-systemeplus-40");

    gtkpack($advanced_box,
	    $box_what = gtkpack_(new Gtk::HBox(0, 15),
				 1, new Gtk::VBox(0, 5),
				 1, gtkpack_(new Gtk::VBox(0, 15),	
					  1, new Gtk::VBox(0, 5),
					  1, gtksignal_connect(my $button_what_sys = new Gtk::Button(), 
							    clicked => sub { $box_what->destroy(); advanced_what_sys(); }),
					  1, gtksignal_connect(my $button_what_user = new Gtk::Button(), 
							    clicked => sub { ${$central_widget}->destroy(); advanced_what_user();}),
					  1, gtksignal_connect(my $button_what_other = new Gtk::Button(), 
							    clicked => sub { ${$central_widget}->destroy(); advanced_what_other(); }),
					  1, gtksignal_connect(my $button_what_all = new Gtk::Button(), 
							    clicked => sub { ${$central_widget}->destroy(); advanced_what_entire_sys(); }),
					  1, new Gtk::VBox(0, 5),
					  ),
				 1, new Gtk::VBox(0, 5),	
				 ),
	    );
    $button_what_sys->add(gtkpack(new Gtk::HBox(0,10),
				  new Gtk::Pixmap($pix_sys_map, $pix_sys_mask),
				  new Gtk::Label(_(" System ")),
				  new Gtk::HBox(0, 5)
				  ));
    $button_what_user->add(gtkpack(new Gtk::HBox(0,10),
				   new Gtk::Pixmap($pix_user_map, $pix_user_mask),
				   new Gtk::Label(_(" Users ")),
				   new Gtk::HBox(0, 5)
				   ));
    $button_what_other->add(gtkpack(new Gtk::HBox(0,10),
				    new Gtk::Pixmap($pix_other_map, $pix_other_mask),
				    new Gtk::Label(_(" Other ")),
				    new Gtk::HBox(0, 5)
				    ));
    $button_what_all->add(gtkpack(new Gtk::HBox(0,10),
				    new Gtk::Pixmap($pix_sysp_map, $pix_sysp_mask),
				    new Gtk::Label(_(" A Entire System  ")),
				    new Gtk::HBox(0, 5)
				    ));
    $custom_help = "";
    $current_widget = \&advanced_what;
    $previous_widget =\&advanced_box;
    $central_widget = \$box_what;
    $up_box->show_all();
}

sub advanced_where_net_ftp {
    my ($previous_function) = @_,
    my $box_where_net;
    
    gtkpack($advanced_box,
	    $box_where_net = gtkpack_(new Gtk::VBox(0, 15),
	 0, new Gtk::HSeparator,
	 0, my $check_where_net_ftp = new Gtk::CheckButton( _(" Use FTP connexion to backup") ),
	 0, new Gtk::HSeparator,
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("please entrer the host name or IP.")), $where_net_ftp),
		     1, new Gtk::HBox(0,10),
		     0, gtkset_sensitive(my $host_name_entry = new Gtk::Entry(), $where_net_ftp),
		     ),
	 0, gtkpack_(new Gtk::HBox(0,10),
		   0, gtkset_sensitive(new Gtk::Label(_("Please entrer the directory to\n put the backup on this host. ")), $where_net_ftp),
		     1, new Gtk::HBox(0,10),
		     0, gtkset_sensitive(my $host_path_entry = new Gtk::Entry(), $where_net_ftp), 
		     ),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("please entrer your login")), $where_net_ftp),
		     1, new Gtk::HBox(0,10),
		     0, gtkset_sensitive(my $login_user_entry = new Gtk::Entry(), $where_net_ftp),
		     ),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("please entrer your passord")),  $where_net_ftp),
		     1, new Gtk::HBox(0,10),
		     0, gtkset_sensitive(my $passwd_user_entry = new Gtk::Entry(), $where_net_ftp),
		     ),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     1, new Gtk::HBox(0,10),
		     0, gtkset_sensitive(my $check_remember_pass = new Gtk::CheckButton( _(" remember this password")), $where_net_ftp),
		     ),
	 ),
	    );
    $passwd_user_entry->set_visibility(0);
    $passwd_user_entry->set_text( $passwd_user );
    $passwd_user_entry->signal_connect( 'changed', sub { $passwd_user = $passwd_user_entry->get_text()});
    $host_path_entry->set_text( $host_path );
    $host_name_entry->set_text( $host_name );
    $login_user_entry->set_text( $login_user );
    $host_name_entry->signal_connect( 'changed', sub { $host_name = $host_name_entry->get_text()});
    $host_path_entry->signal_connect( 'changed', sub { $host_path = $host_path_entry->get_text()});
    $login_user_entry->signal_connect( 'changed', sub { $login_user = $login_user_entry->get_text()});
    
    foreach ([$check_remember_pass, \$remember_pass]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; })
	}
    gtksignal_connect(gtkset_active($check_where_net_ftp, $where_net_ftp), toggled => sub { 
	$where_net_ftp = $where_net_ftp ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
    });
    $custom_help = "ftp";
    if ($previous_function) { $previous_widget =\&$previous_function; }
    else { $previous_widget =\&advanced_where_net; }
    $current_widget = \&advanced_where_net_ftp;
    $central_widget = \$box_where_net;
    $up_box->show_all();
}

sub advanced_where_net_ssh {
    my ($previous_function) = @_,
    my $box_where_ssh;
    
    gtkpack($advanced_box,
	    $box_where_ssh =  gtkpack_(new Gtk::VBox(0, 15),
	     1, gtkpack(new Gtk::HBox(0, 15),	
			 new Gtk::VBox(0, 15),
			 gtkpack_(new Gtk::VBox(0, 15),	
				     1, new Gtk::VBox(0, 5),
				     1, gtksignal_connect(new Gtk::Button("rsync"),  clicked => sub {
					 ${$central_widget}->destroy();  }),
				     1, gtksignal_connect(new Gtk::Button("WebDav"), clicked => sub { 
					 ${$central_widget}->destroy(); }),
				     1, gtksignal_connect(new Gtk::Button("scp"),   clicked => sub { 
					 ${$central_widget}->destroy();  }),
				     1, new Gtk::VBox(0, 5),
				     ),
			 new Gtk::VBox(0, 15),
			 ),
				       ),
	    );
# test si x11
#print system("xterm -fn 7x14 -bg black -fg white -e ssh-keygen -f ~/.ssh/identity-backup && scp ") . "\n";

    if ($previous_function) { $previous_widget =\&$previous_function; }
    else { $previous_widget =\&advanced_where_net; }
    $custom_help = "ssh";
    $current_widget = \&advanced_where_net_ssh;
    $previous_widget = \&advanced_where_net;
    $central_widget = \$box_where_ssh;
    $up_box->show_all();
}

sub advanced_where_net {
    my ($previous_function) = @_,
    my $box_where_net;
    
    gtkpack($advanced_box,
	    $box_where_net = gtkpack_(new Gtk::HBox(0, 15),
				      1, new Gtk::VBox(0, 5),
				      1, gtkpack_(new Gtk::VBox(0, 15),	
						  1, new Gtk::VBox(0, 5),
						  1, new Gtk::VBox(0,10),
						  1, gtksignal_connect(new Gtk::Button(_(" FTP Connexion")), clicked => sub { 
						      $box_where_net->destroy(); 
						      if ($previous_function ) {
							  advanced_where_net_ftp(\&$previous_function);
						      } else {
							  advanced_where_net_ftp();
						      }}),
						  1, gtksignal_connect(new Gtk::Button(_(" Secure Connexion ")),  clicked => sub {
						      $box_where_net->destroy(); 
						      if ($previous_function ) {
							  advanced_where_net_ssh(\&$previous_function);
						      } else {
							  advanced_where_net_ssh();
						      }}),
						  1, new Gtk::VBox(0, 5),
						  1, new Gtk::VBox(0,10),
						  ),
				      1, new Gtk::VBox(0, 5),	
				      ),
	    );
    if ($previous_function) { $previous_widget =\&$previous_function; }
    else { $previous_widget =\&advanced_where; }
    $custom_help = "";
    $current_widget = \&advanced_where_net;
    $central_widget = \$box_where_net;
    $up_box->show_all();
}

sub advanced_where_cd {
    my ($previous_function) = @_,
    my $box_where_cd;
    my $combo_where_cd_time = new Gtk::Combo();
    $combo_where_cd_time->set_popdown_strings ("650","700", "750", "800");    
 
    gtkpack($advanced_box,
	    $box_where_cd = gtkpack_(new Gtk::VBox(0, 6),
	 0, my $check_where_cd = new Gtk::CheckButton( _(" Use CD/DVDROM to backup")),
	 0, new Gtk::HSeparator,
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("please choose your CD space")), $where_cd),
		     1, new Gtk::VBox(0, 5),
		     0, gtkset_sensitive(gtkset_usize($combo_where_cd_time, 200, 20), $where_cd),
		     ),
	 0, new Gtk::VBox(0, 5),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_(" Please check if you are using CDRW media")), $where_cd),
		     1, new Gtk::VBox(0, 5),
		     0, gtkset_sensitive(my $check_cdrw = new Gtk::CheckButton(), $where_cd),
		     ),
	 0, new Gtk::VBox(0, 5),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please check if you want to erase your CDRW before")), $cdrw && $where_cd),
		     1, new Gtk::VBox(0, 5),
		     0, gtkset_sensitive(my $check_cdrw_erase = new Gtk::CheckButton(), $cdrw && $where_cd),
		     ),
	 0, new Gtk::VBox(0, 5),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_(" Please check if you want to include\n install boot on your CD.")),  $where_cd),
		     1, new Gtk::VBox(0, 5),
		     0, gtkset_sensitive(my $check_cd_with_install_boot = new Gtk::CheckButton(), $where_cd),
		     ),
	 0, new Gtk::VBox(0, 5),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("please enter your CD Writer device name\n ex: 0,1,0")),  $where_cd),
		     1, new Gtk::VBox(0, 5),
		     0, gtkset_usize(gtkset_sensitive($cd_devive_entry = new Gtk::Entry(), $where_cd), 200, 20),
		     ),
	 ),
	    );
    foreach ([$check_cdrw_erase, \$cdrw_erase], [$check_cd_with_install_boot, \$cd_with_install_boot ]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; })
	}
    gtksignal_connect(gtkset_active($check_where_cd, $where_cd), toggled => sub { 
	$where_cd = $where_cd ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
    });
    gtksignal_connect(gtkset_active($check_cdrw, $cdrw), toggled => sub { 
	$cdrw = $cdrw ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
    });
    $custom_help = "";
    $cd_devive_entry->set_text( $cd_devive );
    $cd_devive_entry->signal_connect( 'changed', sub { $cd_devive = $cd_devive_entry->get_text(); });
    $combo_where_cd_time->entry->set_text($cd_time);
    $combo_where_cd_time->entry->signal_connect( 'changed', sub { $cd_time = $combo_where_cd_time->entry->get_text()});	       
    $current_widget = \&advanced_where_cd;
    if ($previous_function) { $previous_widget =\&$previous_function; }
    else { $previous_widget =\&advanced_where; }
    $central_widget = \$box_where_cd;
    $up_box->show_all();
}

sub advanced_where_tape {
    my ($previous_function) = @_,
    my $box_where_tape;
    my $button;
    my $adj = new Gtk::Adjustment 550.0, 1.0, 10000.0, 1.0, 5.0, 0.0;
    my ($pix_fs_map, $pix_fs_mask) = gtkcreate_png("filedialog");
    
gtkpack($advanced_box,
	$box_where_tape = gtkpack_(new Gtk::VBox(0, 6),
		 0, new Gtk::HSeparator,
		 0, my $check_where_tape = new Gtk::CheckButton( _(" Use tape to backup") ),
		 0, new Gtk::HSeparator,
		 0, gtkpack_(new Gtk::HBox(0,10),
			     0, gtkset_sensitive(new Gtk::Label(_("Please entrer device name where backup ")), $where_tape ),
			     1, new Gtk::VBox(0, 6),
			     0, gtkset_usize(gtkset_sensitive(my $save_device_tape_entry = new Gtk::Entry(), $where_tape), 200, 20),
				 ),
		 0, new Gtk::VBox(0, 6),
		 0, gtkpack_(new Gtk::HBox(0,10),
			     0, gtkset_sensitive(new Gtk::Label(_("Please entrer the maximum size\n allowed for Drakbackup ")), $where_tape),
			     1, new Gtk::VBox(0, 6),
			     0, gtkset_usize(gtkset_sensitive(my $spinner = new Gtk::SpinButton( $adj, 0, 0), $where_tape ), 200, 20),
			     ),
		     0, gtkpack_(new Gtk::HBox(0,10),
				 ),
		 ),
	    );
    gtksignal_connect(gtkset_active($check_where_tape, $where_tape), toggled => sub { 
	$where_tape = $where_tape ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
    });
    $custom_help = "";
    $save_device_tape_entry->set_text( $save_device_tape );
    $save_device_tape_entry->signal_connect( 'changed', sub { $save_device_tape = $save_device_tape_entry->get_text()});
    $current_widget = \&advanced_where_tape;
    if ($previous_function) { $previous_widget =\&$previous_function; }
    else { $previous_widget =\&advanced_where; }
    $central_widget = \$box_where_tape;
    $up_box->show_all();
}

sub advanced_where_hd {
    my ($previous_function) = @_,
    my $box_where_hd;
    my $button;
    my $adj = new Gtk::Adjustment 550.0, 1.0, 10000.0, 1.0, 5.0, 0.0;
    my ($pix_fs_map, $pix_fs_mask) = gtkcreate_png("ic82-dossier-32");
    
    gtkpack($advanced_box,
	    $box_where_hd = gtkpack_(new Gtk::VBox(0, 6),
	 0, new Gtk::HSeparator,
	 0, my $check_where_hd = new Gtk::CheckButton( _(" Use Hard Disk to backup") ),
	 0, new Gtk::HSeparator,
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please entrer the directory to save: ")), $where_hd ),
		     1, new Gtk::VBox(0, 6),
		     0, gtkset_usize(gtkset_sensitive($save_path_entry = new Gtk::Entry(), $where_hd), 152, 20),
		     0, gtkset_sensitive($button = gtksignal_connect(new Gtk::Button(),  clicked => sub {
			 filedialog_where_hd();}), $where_hd ),
		     ),
	 0, new Gtk::VBox(0, 6),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please entrer the maximum size\n allowed for Drakbackup ")),  $where_hd ),
		     1, new Gtk::VBox(0, 6),
		     0, gtkset_usize(gtkset_sensitive(my $spinner = new Gtk::SpinButton( $adj, 0, 0), $where_hd ), 200, 20),
		     ),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     1, new Gtk::VBox(0, 6),
		     0, gtkset_sensitive(my $check_where_hd_quota = new Gtk::CheckButton( _(" Use quota for backup files.")), $where_hd ),
		     0, new Gtk::VBox(0, 6),
		     ),
	 ),
	    );
    foreach ([$check_where_hd_quota, \$hd_quota]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; })
	}
    gtksignal_connect(gtkset_active($check_where_hd, $where_hd), toggled => sub { 
	$where_hd = $where_hd ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
    });
    $custom_help = "";
    $button->add(gtkpack(new Gtk::HBox(0,10), new Gtk::Pixmap($pix_fs_map, $pix_fs_mask)));
    $save_path_entry->set_text( $save_path );
    $save_path_entry->signal_connect( 'changed', sub { $save_path = $save_path_entry->get_text()});
    $current_widget = \&advanced_where_hd;
    if ($previous_function) { $previous_widget =\&$previous_function; }
    else { $previous_widget =\&advanced_where; }
    $central_widget = \$box_where_hd;
    $up_box->show_all();
}

sub advanced_where{
    my $box_where;
    my ($pix_net_map, $pix_net_mask) = gtkcreate_png("ic82-network-40");
    my ($pix_cd_map, $pix_cd_mask) = gtkcreate_png("ic82-CD-40");
    my ($pix_hd_map, $pix_hd_mask) = gtkcreate_png("ic82-discdurwhat-40");
    my ($pix_tape_map, $pix_tape_mask) = gtkcreate_png("ic82-tape-40");

    gtkpack($advanced_box,
	    $box_where = gtkpack_(new Gtk::HBox(0, 15),
				  1, new Gtk::VBox(0, 5),
				  1, gtkpack_(new Gtk::VBox(0, 15),	
					  1, new Gtk::VBox(0, 5),
					  1, gtksignal_connect(my $button_where_net = new Gtk::Button(), clicked => sub { 
					      $box_where->destroy(); advanced_where_net(); }),
					  1, gtksignal_connect(my $button_where_cd = new Gtk::Button(),  clicked => sub { 
					      ${$central_widget}->destroy(); advanced_where_cd(); }),
					  1, gtksignal_connect(my $button_where_hd = new Gtk::Button(),  clicked => sub { 
					      ${$central_widget}->destroy(); advanced_where_hd(); }),
					  1, gtksignal_connect(my $button_where_tape = new Gtk::Button(),  clicked => sub { 
					      ${$central_widget}->destroy(); advanced_where_tape(); }),
					  1, new Gtk::VBox(0, 5),
					     ),
				  1, new Gtk::VBox(0, 5),	
				  ),
	    );
    $button_where_net->add(gtkpack(new Gtk::HBox(0,10),
				   new Gtk::Pixmap($pix_net_map, $pix_net_mask),
				   new Gtk::Label(_(" Network ")),
				   new Gtk::HBox(0, 5)
				   ));
    $button_where_cd->add(gtkpack(new Gtk::HBox(0,10),
				  new Gtk::Pixmap($pix_cd_map, $pix_cd_mask),
				  new Gtk::Label(_(" CDROM / DVDROM ")),
				  new Gtk::HBox(0, 5)
				  ));
    $button_where_hd->add(gtkpack(new Gtk::HBox(0,10),
				  new Gtk::Pixmap($pix_hd_map, $pix_hd_mask),
				  new Gtk::Label(_(" HardDrive / NFS ")),
				  new Gtk::HBox(0, 5)
				  ));
    $button_where_tape->add(gtkpack(new Gtk::HBox(0,10),
				  new Gtk::Pixmap($pix_tape_map, $pix_tape_mask),
				  new Gtk::Label(_(" Tape ")),
				  new Gtk::HBox(0, 5)
				  ));
    $custom_help = "";
    $current_widget = \&advanced_where;
    $previous_widget =\&advanced_box;
    $central_widget = \$box_where;
    $up_box->show_all();
}

sub advanced_when{
    my $box_when;
    my $check_where_cd_daemon;
    my $check_where_hd_daemon;
    my $check_where_net_daemon;
    my ($pix_time_map, $pix_time_mask) = gtkcreate_png("ic82-when-40");
    my $combo_when_space = new Gtk::Combo();
    $combo_when_space->set_popdown_strings (_("hourly"),_("daily"),_("weekly"),_("monthly"));    

    gtkpack($advanced_box,
	    $box_when = gtkpack_(new Gtk::VBox(0, 15),
	  0, gtkpack_(new Gtk::HBox(0,10),
		      1, new Gtk::HBox(0,10),
		      1, new Gtk::Pixmap($pix_time_map, $pix_time_mask),
		      0, my $check_when_daemon  = new Gtk::CheckButton( _(" Use daemon")  ), 
		      1, new Gtk::HBox(0,10),
		      ),
	  0, new Gtk::HSeparator,
	  0, gtkpack_(new Gtk::HBox(0,10),
		      0, gtkset_sensitive(new Gtk::Label(_("Please choose interval \nspace between each backup ")),  $backup_daemon),
		      1, new Gtk::HBox(0,10),
		      0, gtkset_sensitive($combo_when_space, $backup_daemon),
		      ),
	  0, new Gtk::HBox(0,10),
	  0, gtkpack_(new Gtk::HBox(0,10),
		   0, gtkset_sensitive(new Gtk::Label(_("Please choose\nmedia to backup. ")), $backup_daemon),
		   1, new Gtk::HBox(0,10),
		   0, gtkpack_(new Gtk::VBox(0,10),
		       0, gtkset_sensitive($check_where_cd_daemon = new Gtk::CheckButton(_(" Use CD/DVDROM with daemon")), $backup_daemon),
		       0, gtkset_sensitive($check_where_hd_daemon = new Gtk::CheckButton( _(" Use Hard Drive with daemon")), $backup_daemon),
		       0, gtkset_sensitive($check_where_net_daemon = new Gtk::CheckButton( _(" Use Network with daemon")), $backup_daemon),
			       ),
		      ),
	  0, new Gtk::HSeparator,
	  1, gtkset_sensitive(new Gtk::Label(_("Please be careful that cron deamon is include on your services. ")),  $backup_daemon),
	  ),
	    );
    foreach ([$check_where_cd_daemon, \$cd_daemon], [$check_where_hd_daemon, \$hd_daemon], [$check_where_net_daemon, \$net_daemon]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; })
	}
    gtksignal_connect(gtkset_active($check_when_daemon, $backup_daemon), toggled => sub { 
	$backup_daemon = $backup_daemon ? 0 : 1;
	${$central_widget}->destroy();
	advanced_when();
    });
    $custom_help = "";
    $combo_when_space->entry->set_text( $when_space );
    $combo_when_space->entry->signal_connect( 'changed', sub { 
	$when_space = $combo_when_space->entry->get_text();  print $when_space."\n";});
    $current_widget = \&advanced_when;
    $previous_widget =\&advanced_box;
    $central_widget = \$box_when;
    $up_box->show_all();
}

sub advanced_options{
    my $box_options;
    my ($pix_options_map, $pix_options_mask) = gtkcreate_png("ic82-moreoption-40");
    
    gtkpack($advanced_box,
	    $box_options = gtkpack_(new Gtk::VBox(0, 15),
				 0, gtkpack_(new Gtk::HBox(0,10),
					     1, new Gtk::VBox(0,10),
					     1, new Gtk::Pixmap($pix_options_map, $pix_options_mask),
					     1, _("Please choose correct options to backup. "),
					     1, new Gtk::VBox(0,10),
					     ),
				 0, new Gtk::HSeparator,
				 0, gtkpack_(new Gtk::VBox(0,10),
					     0, my $check_tar_bz2  = new Gtk::CheckButton( _(" Use Tar and bzip2  ( very slow) [please be careful if you\n (un)select this option all your old backups will be deleted ]") ),
					     0, gtkset_sensitive(my $check_backupignore = new Gtk::CheckButton( _(" Use .backupignore files")), 0),
					     ),
				 ),
	    );
    foreach ([$check_tar_bz2, \$comp_mode], [$check_backupignore, \$backupignore]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; })
	}
    $custom_help = "options";
    $current_widget = \&advanced_options;
    $previous_widget =\&advanced_box;
    $central_widget = \$box_options;
    $up_box->show_all();
}

sub advanced_box{
    my $box_adv;
    my ($pix_hd_map, $pix_hd_mask) = gtkcreate_png("ic82-discdurwhat-40");
    my ($pix_time_map, $pix_time_mask) = gtkcreate_png("ic82-when-40");
    my ($pix_net_map, $pix_net_mask) = gtkcreate_png("ic82-where-40");
    my ($pix_options_map, $pix_options_mask) = gtkcreate_png("ic82-moreoption-40");

    gtkpack($advanced_box,
	    $box_adv = gtkpack_(new Gtk::HBox(0, 15),
				    1, new Gtk::VBox(0, 5),	
				    1, gtkpack_(new Gtk::VBox(0, 15),	
						1, new Gtk::VBox(0, 5),	
						1, gtksignal_connect(my $button_what = new Gtk::Button(), clicked => sub { 
						    ${$central_widget}->destroy(); advanced_what(); }),
						1, gtksignal_connect(my $button_where = new Gtk::Button(), clicked => sub { 
						    ${$central_widget}->destroy();  advanced_where(); }),
						1, gtksignal_connect(my $button_when = new Gtk::Button(), clicked => sub { 
						    ${$central_widget}->destroy();  advanced_when(); }),
						1, gtksignal_connect(my $button_options = new Gtk::Button(), clicked => sub {
						    ${$central_widget}->destroy(); advanced_options();}),
						1, new Gtk::VBox(0, 5),	
						),
				    1, new Gtk::VBox(0, 5),	
				    ),
	    );
    $button_what->add(gtkpack(new Gtk::HBox(0,10),
			      new Gtk::Pixmap($pix_hd_map, $pix_hd_mask),
			      new Gtk::Label(_(" What ")),
			      new Gtk::HBox(0, 5)
			      ));
    $button_where->add(gtkpack(new Gtk::HBox(0,10),
			      new Gtk::Pixmap($pix_net_map, $pix_net_mask),
			      new Gtk::Label(_(" Where ")),
			      new Gtk::HBox(0, 5)
			      ));
    $button_when->add(gtkpack(new Gtk::HBox(0,10),
			      new Gtk::Pixmap($pix_time_map, $pix_time_mask),
			      new Gtk::Label(_(" When ")),
			      new Gtk::HBox(0, 5)
			      ));
    $button_options->add(gtkpack(new Gtk::HBox(0,10),
			      new Gtk::Pixmap($pix_options_map, $pix_options_mask),
			      new Gtk::Label(_(" More Options")),
			      new Gtk::HBox(0, 5)
			      ));
    $custom_help = "";
    $previous_widget =\&interactive_mode_box;
    $current_widget = \&advanced_box;
    $central_widget = \$box_adv;
    $up_box->show_all();
}

################################################  WIZARD  ################################################  

sub wizard_step3 {
    my $box2;    
    my $text = new Gtk::Text(undef, undef);
    system_state();
    gtktext_insert($text, $system_state);
    button_box_restore_main();

    gtkpack($advanced_box,
	    $box2 =  gtkpack_(new Gtk::HBox(0, 15),	
			      1, gtkpack_(new Gtk::VBox(0,10),
					  0, _("         Drakbackup Configuration       "),
					  1, createScrolledWindow($text),
					  ),
			      ),
	    );
    button_box_wizard_end();
    $custom_help = "";
    $central_widget = \$box2;
    $current_widget = \&wizard_step3;
    $previous_widget =\&wizard_step2;
    $up_box->show_all();
}

sub wizard_step2 {
    my $box2;    
    
    gtkpack($advanced_box,
	    $box2 =  gtkpack_(new Gtk::HBox(0, 15),	
			      1, new Gtk::VBox(0, 5),	
			      1, gtkpack_(new Gtk::VBox(0, 15),	
					  1, new Gtk::VBox(0, 5),
					  0, _("Please choose where you want to backup"),
					  0, gtkpack_(new Gtk::HBox(0, 15),	      
						      0, my $check_wizard_hd = new Gtk::CheckButton(_("on Hard Drive")),
						      1, new Gtk::VBox(0, 5),
						      0, gtkset_sensitive(gtksignal_connect(new Gtk::Button(_("Configure it")),
											    clicked => sub {
												${$central_widget}->destroy();
												advanced_where_hd(\&wizard_step2);
											    }), $where_hd ),
									  ),
					  0, gtkpack_(new Gtk::HBox(0, 15),	      
						      0, my $check_wizard_net = new Gtk::CheckButton(_("across Network")),
						      1, new Gtk::VBox(0, 5),
						      0, gtkset_sensitive(gtksignal_connect(new Gtk::Button(_("Configure it")),
											    clicked => sub {
												${$central_widget}->destroy();
												advanced_where_net(\&wizard_step2);
											    }), $where_net ),
						      ),
					  0, gtkpack_(new Gtk::HBox(0, 15),	      
						      0, my $check_wizard_cd = new Gtk::CheckButton(_("on CDROM")),
						      1, new Gtk::VBox(0, 5),	
						      0, gtkset_sensitive(gtksignal_connect(new Gtk::Button(_("Configure it")),
											    clicked => sub {
												${$central_widget}->destroy();
												advanced_where_cd(\&wizard_step2);
											    }), $where_cd ),
						      ),
					  0, gtkpack_(new Gtk::HBox(0, 15),	      
						      0, my $check_wizard_tape = new Gtk::CheckButton(_("on Tape Device")),
						      1, new Gtk::VBox(0, 5),
						      0, gtkset_sensitive(gtksignal_connect(new Gtk::Button(_("Configure it")), 
											    clicked => sub {
												${$central_widget}->destroy();
												advanced_where_tape(\&wizard_step2);
											    }), $where_tape),
						      ),
					  1, new Gtk::VBox(0, 5),
					  ),
			      1, new Gtk::VBox(0, 5),	
			      ),
	    );
    $where_net = $where_net_ssh || $where_net_ftp;
    foreach ([$check_wizard_hd, \$where_hd], 
	     [$check_wizard_cd, \$where_cd], 
	     [$check_wizard_net, \$where_net], 
	     [$check_wizard_tape, \$where_tape]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { 
	    ${$ref} = ${$ref} ? 0 : 1;
	    if (!$where_hd && !$where_cd && !$where_net) {  $next_widget = \&message_noselect_box; }
	    else { $next_widget = \&wizard_step3;   }
	    if(!$where_net) {$where_net_ssh = 0; $where_net_ftp = 0; }
	    else {$where_net_ftp = 1;}
	    ${$central_widget}->destroy();
	    wizard_step2();
	})
	}
    if (!$where_hd && !$where_cd && !$where_net) {  $next_widget = \&message_noselect_box; }
    else { $next_widget = \&wizard_step3;   }
    button_box_wizard();
    $custom_help = "";
    $central_widget = \$box2;
    $current_widget = \&wizard_step2;
    $previous_widget =\&wizard;
    $up_box->show_all();
}

sub wizard   {
    my $box2;    
    
    gtkpack($advanced_box,
	    $box2 =  gtkpack_(new Gtk::HBox(0, 15),	
			      1, new Gtk::VBox(0, 5),	
			      1, gtkpack_(new Gtk::VBox(0, 15),	
					  1, new Gtk::VBox(0, 5),
					  0, _("Please choose that you want to backup"),
					  0, my $check_wizard_sys = new Gtk::CheckButton(_("Backup system")),
					  0, my $check_wizard_user = new Gtk::CheckButton(_("Backup Users")),
					  0, gtkpack_(new Gtk::HBox(0, 15),
						      1, new Gtk::VBox(0, 5),	
						      0, gtksignal_connect(new Gtk::Button(_("Select user manually")), clicked => sub {
							  ${$central_widget}->destroy();
							  advanced_what_user(\&wizard);
							  }),
						      ),
					  1, new Gtk::VBox(0, 5),	
					  ),
			      1, new Gtk::VBox(0, 5),	
			      ),
	    );
    foreach ([$check_wizard_sys, \$backup_sys], [$check_wizard_user, \$backup_user]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { 
	    ${$ref} = ${$ref} ? 0 : 1;
	    if ($backup_sys || $backup_user && @user_list ) { $next_widget = \&wizard_step2; } 
	    else { $next_widget = \&message_noselect_what_box; }
	})}
    if ($backup_sys || $backup_user && @user_list ) { $next_widget = \&wizard_step2; } 
    else { $next_widget = \&message_noselect_what_box; }
    button_box_wizard();
    $custom_help = "";
    $central_widget = \$box2;
    $current_widget = \&wizard;
    $previous_widget =\&interactive_mode_box;
    $up_box->show_all();
}

################################################  RESTORE  ################################################  

sub find_backup_to_restore {
	# fixme: 
	# faire test existance cd
	# faire reponse si non existance de  $path_to_find_restore
    my @list_backup_tmp2 = ();
    my $to_put;
    @sys_backuped = ();
    my @list_backup = ();
    my @list_backup_tmp;
    my @user_backuped_tmp;

    @user_backuped = ();
    -d $path_to_find_restore and my @list_backup_tmp2 = all($path_to_find_restore);
    foreach (@list_backup_tmp2) {
	s/\_base//gi;
	s/\_incr//gi;
	push @list_backup , $_;
	
    }
    if (grep /^backup_other/, @list_backup) {$other_backuped = 1;}
    if (grep /^backup_sys/, @list_backup) {$sys_backuped = 1;}
    foreach (grep /^backup_sys_/, @list_backup) {
	chomp;
	s/^backup_sys_//gi;
	s/.tar.gz$//gi;
	s/.tar.bz2$//gi;
 	my ( $date, $heure) = /^(.*)_([^_]*)$/; 
	my $year = substr($date, 0, 4);
	my $month = substr($date, 4,  2);
	my $day =  substr($date, 6, 2);
	my $hour = substr($heure, 0,  2);
	my $min =  substr($heure, 2, 2);
	$to_put = "$day/$month/$year $hour:$min                   $_";
 	push @sys_backuped , $to_put;
    }
    $restore_step_sys_date  = $to_put;
    foreach (grep /^backup_user_/, @list_backup) {
	chomp;
	s/^backup_user_//gi;
	s/.tar.gz$//gi;
	s/.tar.bz2$//gi;
	my ($nom, $date, $heure) = /^(.*)_([^_]*)_([^_]*)$/;
	my $year = substr($date, 0, 4);
	my $month = substr($date, 4,  2);
	my $day =  substr($date, 6, 2);
	my $hour = substr($heure, 0,  2);
	my $min =  substr($heure, 2, 2);
#	my $to_put = "  $nom,  (date: $date, hour: $heure)";
	$to_put = "$_       user: $nom,   date: $day/$month/$year,   hour: $hour:$min";
	push @user_backuped , $to_put;
    }
}

sub system_state {
    $system_state = ();

    if ($cfg_file_exist) { 
	$system_state .= _("\nBackup Sources: \n");
        $backup_sys and $system_state .= _("\n- System Files:\n"); 
        $backup_sys and $system_state .= _("\t\t$_\n") foreach @sys_files; 
        $backup_user and $system_state .= _("\n- Users Files:\n");
        $backup_user and $system_state .= _("\t\t$_\n") foreach @user_list;
        @list_other and $system_state .= _("\n- Other Files:\n"); 
        @list_other and $system_state .= _("\t\t$_\n") foreach @list_other;
        $system_state .= _("\n- Path to save backups: $save_path\n");
	$system_state .= _("\n- Options:\n");
	$backup_sys or $system_state .= _("\tDo not include System Files\n");
	if ($comp_mode) { $system_state .= _("\tBackups use tar and bzip2\n "); }
	else { $system_state .= _("\tBackups use tar and gzip\n"); }   
    }
    else {$system_state = _("No configuration please click Wizard or Advanced.\n")}
}

sub restore_state {
    $restore_state = _("List of data to restore:\n\n");
    if ($restore_sys) { $restore_state .= "- Restore System Files.\n" }
    if ($restore_user) { 
	$restore_state .= "- Restore Users Files: \n" ;
	$restore_state .= "\t\t$_\n" foreach @user_list_to_restore2 ;
	push @user_list_to_restore, (split(',', $_))[0] foreach @user_list_to_restore2 ;
    }
    if ($restore_other) { 
	$restore_state .= "- Restore Other Files: \n";
	-f "$path_to_find_restore/list_other" and $restore_state .= "\t\t$_\n" foreach split( "\n", cat_("$path_to_find_restore/list_other")); 
    }
    if ($restore_other_path) {
	$restore_state .= "- Path to Restore: $restore_path \n";
    }
}

sub restore_backend {
    my $untar_cmd;
    if (grep /tar.gz$/, all($path_to_find_restore)) { $untar_cmd = 0; } 
    else { $untar_cmd = 1; } 
    if ($restore_user)  { 
#	$untar_cmd or system(" echo 'user: $_' && cd /tmp &&  tar xfz  $path_to_find_restore/backup_user_$_.tar.gz -C $restore_path") foreach @user_list_to_restore;
#	$untar_cmd and system("echo 'user: $_' && cd /tmp &&  /usr/bin/bzip2 -cd $path_to_find_restore/backup_user_$_.tar.bz2 | tar xf -C $restore_path ") foreach @user_list_to_restore;
	print "user list too restore : $_\n"foreach @user_list_to_restore2;
    }
## fixme 
    if ($restore_sys)   { 
#	$untar_cmd or system("echo backup_sys  && cd /tmp && tar xfz $path_to_find_restore/backup_sys.tar.gz  -C $restore_path ");
#	$untar_cmd and system("echo backup_sys cd /tmp && /usr/bin/bzip2 -cd $path_to_find_restore/backup_sys.tar.bz2  | tar xf -C $restore_path ");
	print " restore sys\n";
    }

## fixme
    if ($restore_other) { 
#	$untar_cmd or system("echo backup_other && cd /tmp && tar xfz $path_to_find_restore/backup_other.tar.gz  -C $restore_path ");
#	$untar_cmd and system("echo backup_other && cd /tmp && /usr/bin/bzip2 -cd $path_to_find_restore/backup_other.tar.bz2  | tar xf -C $restore_path ");
	print "restore other \n";
    }
    print "End of restore\n";
}

sub restore_do {

    if ($backup_bef_restore) {
	if ($restore_sys) { $backup_sys = 1;}
	else { $backup_sys = 0;}
	if ($restore_user) { 
	    $backup_user = 1;
	    @user_list = @user_list_to_restore;
	} else { $backup_user = 0;}
	build_backup_status();
	build_backup_files();
	read_conf_file();
	$table->destroy();
    }
    restore_do2();
}

sub restore_do2 {
    my $do_restore;
    my $button_restore;
    my $text = new Gtk::Text(undef, undef);
    restore_state();
    gtktext_insert($text, $restore_state);
    button_box_restore_main();

    gtkpack($advanced_box,
	    $do_restore = gtkpack_(new Gtk::VBox(0,10),
				   0, _("         Restore Configuration       "),
				   1, createScrolledWindow($text),
				   ),
	    );
    button_box_restore_end();
    $previous_widget =\&restore_box;
    $custom_help = "restore";
    $current_widget = \&restore_do2;
    $central_widget = \$do_restore;
    $up_box->show_all();
}

sub restore_step_other {
    my $retore_step_other;
    my $text = new Gtk::Text(undef, undef);
    my $other_rest = cat_("$path_to_find_restore/list_other");
    gtktext_insert($text, $other_rest); 
    gtkpack($advanced_box,
	    $retore_step_other = gtkpack_(new Gtk::VBox(0,10),
					  1, new Gtk::VBox(0,10),
					  1, createScrolledWindow($text),
					  0, my $check_restore_other_sure = new Gtk::CheckButton(_(" Sure to restore the other files .")),
					  1, new Gtk::VBox(0,10),
					  ),
	    );
    foreach  ([$check_restore_other_sure, \$restore_other]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; })
	}
    $next_widget = \&restore_do;
    $previous_widget = \&restore_step2;
    $custom_help = "restore";
    $current_widget = \&restore_step_other;
    $central_widget = \$retore_step_other;
    $up_box->show_all();
}

my %check_user_to_restore;
sub restore_step_user {
    my $retore_step_user;
    @user_list_to_restore2 = sort @user_backuped;
    @user_backuped = @user_list_to_restore2;

    gtkpack($advanced_box,
	    $retore_step_user = gtkpack_(new Gtk::VBox(0,10),
		     0, new Gtk::VBox(0,10),
		     0, _("User list to restore (only the more recent date per user is important)"),
		     1, createScrolledWindow( gtkpack__(new Gtk::VBox(0,0),
							map { my @name_l = split(/,/, $_);
							      my $name_complet = $_;
							      my @user_list_tmp = ();
							      my $name  = $name_l[0];
							      my $b = new Gtk::CheckButton($name_complet); 
							      if ( grep $name_complet, @user_list_to_restore2)  {
								  gtkset_active($b, 1);
							      } else {
								  gtkset_active($b, 0);
							      }
							      $b->signal_connect(toggled => sub { 
								  if ($check_user_to_restore{$name_complet}[1] ) {
								      $check_user_to_restore{$name_complet}[1] = 0;
								      if (!member(/$name_complet/, @user_list_to_restore2) ) {
									  push @user_list_to_restore2, $name_complet;}
								  } else {
								      $check_user_to_restore{$name_complet}[1] = 1;
								      foreach (@user_list_to_restore2) {
									  if ($name_complet ne $_) {
									      push @user_list_tmp, $_;
									  }
								      }
								      @user_list_to_restore2 = @user_list_tmp;
								  }
							      });
							      $b } (@user_backuped) 
							),
					      ),
					 ),
	    );
    if ($restore_other) { $next_widget = \&restore_step_other;}
    else{ $next_widget = \&restore_do;}
    $custom_help = "restore";
    $current_widget = \&restore_step_user;
    $central_widget = \$retore_step_user;
    $up_box->show_all();
}

sub restore_step_sys {
    my $restore_step_sys;
    my $combo_restore_step_sys = new Gtk::Combo();
    $combo_restore_step_sys->set_popdown_strings (@sys_backuped);

    gtkpack($advanced_box,
	    $restore_step_sys = gtkpack_(new Gtk::VBox(0,10),
					1, new Gtk::VBox(0,10),
					0, my $check_backup_before = new Gtk::CheckButton(_(" Backup the system files before.")),
					0, gtkpack_(new Gtk::HBox(0,10),
						    1, _("please choose the date to restore"),
						    0, $combo_restore_step_sys,
						    0, new Gtk::HBox(0,10),
						    ),
					1, new Gtk::VBox(0,10),
					),
	    );
    $combo_restore_step_sys->entry->signal_connect( 'changed', sub {
	$restore_step_sys_date = $combo_restore_step_sys->entry->get_text();
	print $restore_step_sys_date. "\n";
	});
    $combo_restore_step_sys->entry->set_text($restore_step_sys_date);
    if ($restore_user) { $next_widget = \&restore_step_user;}
    elsif ($restore_other){ $next_widget = \&restore_step_other;}
    else{ $next_widget = \&restore_do;}
    $custom_help = "restore";
    $current_widget = \&restore_step_sys;
    $central_widget = \$restore_step_sys;
    $up_box->show_all();
}

sub restore_other_media_hd {
    my ($previous_function) = @_,
    my $box_where_hd;
    my $button;
    my $adj = new Gtk::Adjustment 550.0, 1.0, 10000.0, 1.0, 5.0, 0.0;
    my ($pix_fs_map, $pix_fs_mask) = gtkcreate_png("filedialog");
    
    gtkpack($advanced_box,
	    $box_where_hd = gtkpack_(new Gtk::VBox(0, 6),
	 0, new Gtk::HSeparator,
	 0, my $check_where_hd = new Gtk::CheckButton( _(" Use Hard Disk to backup") ),
	 0, new Gtk::HSeparator,
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please entrer the directory to save: ")), $where_hd ),
		     1, new Gtk::VBox(0, 6),
		     0, gtkset_usize(gtkset_sensitive($save_path_entry = new Gtk::Entry(), $where_hd), 152, 20),
		     0, gtkset_sensitive($button = gtksignal_connect(new Gtk::Button(),  clicked => sub {
			 filedialog_where_hd();}), $where_hd ),
		     ),
	 0, new Gtk::VBox(0, 6),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please entrer the maximum size\n allowed for Drakbackup ")),  $where_hd ),
		     1, new Gtk::VBox(0, 6),
		     0, gtkset_usize(gtkset_sensitive(my $spinner = new Gtk::SpinButton( $adj, 0, 0), $where_hd ), 200, 20),
		     ),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     1, new Gtk::VBox(0, 6),
		     0, gtkset_sensitive(my $check_where_hd_quota = new Gtk::CheckButton( _(" Use quota for backup files.")), $where_hd ),
		     0, new Gtk::VBox(0, 6),
		     ),
	 ),
	    );
    foreach ([$check_where_hd_quota, \$hd_quota]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; })
	}
    gtksignal_connect(gtkset_active($check_where_hd, $where_hd), toggled => sub { 
	$where_hd = $where_hd ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
    });
    $custom_help = "";
    $button->add(gtkpack(new Gtk::HBox(0,10), new Gtk::Pixmap($pix_fs_map, $pix_fs_mask)));
    $save_path_entry->set_text( $save_path );
    $save_path_entry->signal_connect( 'changed', sub { $save_path = $save_path_entry->get_text()});
    $current_widget = \&advanced_where_hd;
    if ($previous_function) { $previous_widget =\&$previous_function; }
    else { $previous_widget =\&advanced_where; }
    $central_widget = \$box_where_hd;
    $up_box->show_all();
}

sub restore_find_net {
    my ($previous_function) = @_,
    my $box_where_net;
    
    gtkpack($advanced_box,
	    $box_where_net = gtkpack_(new Gtk::HBox(0, 15),
				      1, new Gtk::VBox(0, 5),
				      1, gtkpack_(new Gtk::VBox(0, 15),	
						  1, new Gtk::VBox(0, 5),
						  1, new Gtk::VBox(0,10),
						  1, gtksignal_connect(new Gtk::Button(_(" FTP Connexion")), clicked => sub { 
						      $box_where_net->destroy(); 
						      if ($previous_function ) {
							  advanced_where_net_ftp(\&$previous_function);
						      } else {
							  advanced_where_net_ftp();
						      }}),
						  1, gtksignal_connect(new Gtk::Button(_(" Secure Connexion ")),  clicked => sub {
						      $box_where_net->destroy(); 
						      if ($previous_function ) {
							  advanced_where_net_ssh(\&$previous_function);
						      } else {
							  advanced_where_net_ssh();
						      }}),
						  1, new Gtk::VBox(0, 5),
						  1, new Gtk::VBox(0,10),
						  ),
				      1, new Gtk::VBox(0, 5),	
				      ),
	    );
    if ($previous_function) { $previous_widget =\&$previous_function; }
    else { $previous_widget =\&advanced_where; }
    $custom_help = "";
    $current_widget = \&advanced_where_net;
    $central_widget = \$box_where_net;
    $up_box->show_all();
}

sub restore_other_media {
    my $box_find_restore;
    my $button;
    my $adj = new Gtk::Adjustment 550.0, 1.0, 10000.0, 1.0, 5.0, 0.0;
    my ($pix_fs_map, $pix_fs_mask) = gtkcreate_png("filedialog");
    
    gtkpack($advanced_box,
	    $box_find_restore = gtkpack_(new Gtk::VBox(0, 6),
	 0, new Gtk::HSeparator,
	 0, my $check_other_media_hd = new Gtk::CheckButton( _(" Use Hard Disk to find backups") ),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please entrer the directory to find backup ")), $other_media_hd ),
		     1, new Gtk::VBox(0, 6),
		     0, gtkset_usize(gtkset_sensitive($restore_find_path_entry = new Gtk::Entry(), $other_media_hd), 152, 20),
		     0, gtkset_sensitive($button = gtksignal_connect(new Gtk::Button(),  clicked => sub {
			 filedialog_restore_find_path();}), $other_media_hd ),
		     ),
	 1, new Gtk::VBox(0, 6),
	 0, new Gtk::HSeparator,
	 0, my $check_other_media_net = new Gtk::CheckButton( _(" Use Network to find backups") ),
	 0, new Gtk::VBox(0, 6),
	 1, gtkpack(new Gtk::HBox(0,10),
		     new Gtk::VBox(0, 6),
		     gtkset_sensitive(gtksignal_connect(new Gtk::Button("Network"),  clicked => sub {
			 ${$central_widget}->destroy();
			 restore_find_net(\&restore_other_media);}), !$other_media_hd ),
		     new Gtk::VBox(0, 6),
		     ),
	 1, new Gtk::VBox(0, 6),
					 
	 0, new Gtk::HSeparator,


	 0, new Gtk::VBox(0, 6),
	 ),
	    );
    gtksignal_connect(gtkset_active($check_other_media_hd, $other_media_hd), toggled => sub { 
	$other_media_hd = $other_media_hd ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
    });
    gtksignal_connect(gtkset_active($check_other_media_net, !$other_media_hd), toggled => sub { 
	$other_media_hd = $other_media_hd ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
    });
    $button->add(gtkpack(new Gtk::HBox(0,10), new Gtk::Pixmap($pix_fs_map, $pix_fs_mask)));
    $restore_find_path_entry->set_text( $path_to_find_restore );
    $restore_find_path_entry->signal_connect( 'changed', sub { $path_to_find_restore = $restore_find_path_entry->get_text()});
    $current_widget = \&restore_other_media;
    $central_widget = \$box_find_restore;
    $previous_widget =\&restore_step2; 
    $custom_help = "other_media";
    $up_box->show_all();
}

sub restore_step2 {
    my $retore_step2;

    gtkpack($advanced_box,
	    $retore_step2 = gtkpack_(new Gtk::VBox(0,10),
				     1, new Gtk::VBox(0,10),
				     1, new Gtk::VBox(0,10),
				     0, gtkpack_(new Gtk::HBox(0,10),
					0, my $check_restore_other_src = new Gtk::CheckButton(_("select an other media to find backups")),
					1, new Gtk::HBox(0,10),
					0, gtkset_sensitive(gtksignal_connect(new Gtk::Button(_("Other Media")),
									      clicked => sub {
										  ${$central_widget}->destroy();
										  restore_other_media();
									      }), $restore_other_src ),
						 ),
				     0, my $check_restore_sys = new Gtk::CheckButton(_("Restore system")),
				     0, my $check_restore_user = new Gtk::CheckButton(_("Restore Users")),
				     0, my $check_restore_other = new Gtk::CheckButton(_("Restore Other")),
				     0, gtkpack_(new Gtk::HBox(0,10),
					0, my $check_restore_other_path = new Gtk::CheckButton(_("select path to restore (instead of / ) ")),
					1, new Gtk::HBox(0,10),
					0, gtkset_sensitive(my $restore_path_entry = new Gtk::Entry(), $restore_other_path),
						 ),
				     0, gtkset_sensitive(my $check_backup_bef_restore = new Gtk::CheckButton(_("do new backup before restore (only for incremental backups.)")), $backup_sys_versions || $backup_user_versions ),
				     1, new Gtk::VBox(0,10),
				     ),
	    );
    foreach  ([$check_restore_sys, \$restore_sys], 
	      [$check_backup_bef_restore, \$backup_bef_restore],
	      [$check_restore_user, \$restore_user],
	      [$check_restore_other, \$restore_other]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { 
	    ${$ref} = ${$ref} ? 0 : 1;
	    if (!$restore_sys && !$restore_user && !$restore_other) { $next_widget = \&message_norestore_box; }
	    elsif ($restore_sys && $backup_sys_versions) { $next_widget = \&restore_step_sys; }
	    elsif ($restore_user) { $next_widget = \&restore_step_user;}
	    elsif ($restore_other){ $next_widget = \&restore_step_other;}
	    else{ $next_widget = \&restore_do;}
	})
	}
    gtksignal_connect(gtkset_active($check_restore_other_path, $restore_other_path), toggled => sub {
	$restore_other_path = $restore_other_path ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
    });
    gtksignal_connect(gtkset_active($check_restore_other_src, $restore_other_src), toggled => sub {
	$restore_other_src = $restore_other_src ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
    });
    if (!$restore_sys && !$restore_user && !$restore_other) { $next_widget = \&message_norestore_box; }
    elsif ($restore_sys && $backup_sys_versions) { $next_widget = \&restore_step_sys; }
    elsif ($restore_user) { $next_widget = \&restore_step_user;}
    elsif ($restore_other){ $next_widget = \&restore_step_other;}
    else{ $next_widget = \&restore_do;}
    $restore_path_entry->set_text($restore_path); 
    $restore_path_entry->signal_connect( 'changed', sub { $restore_path = $restore_path_entry->get_text(); });
    $custom_help = "restore";
    $previous_widget =\&restore_box;
    $current_widget = \&restore_step2;
    $central_widget = \$retore_step2;
    $up_box->show_all();
}

sub restore_box {
    my $retore_box;
    my $retore_box3;
    my $check_restore_sys;
    my $check_restore_user;
    my $check_restore_other;
    $path_to_find_restore = $save_path;
    find_backup_to_restore();
    button_box_restore_main();

    if ($other_backuped || $sys_backuped || @user_backuped) {
	gtkpack($advanced_box,
		$retore_box = gtkpack_(new Gtk::HBox(0,1),
				       1, new Gtk::VBox(0,10),
				       1, gtkpack_(new Gtk::VBox(0,10),
						   1, new Gtk::VBox(0,10),
						   1, new Gtk::VBox(0,10),
						   1, gtksignal_connect(new Gtk::Button(_("Restore all last backups")), 
								       clicked => sub { $retore_box->destroy();
											button_box_restore();
											$restore_sys = 1;
											$restore_other = 1;
											$restore_user = 1;
											restore_do(); }),
						  1, gtksignal_connect(new Gtk::Button(_("Custom Restore")), 
								       clicked => sub { $retore_box->destroy();
											button_box_restore(); 
											restore_step2();
										    }),
						   1, new Gtk::VBox(0,10),
						   1, new Gtk::VBox(0,10),
						  ),
				       1, new Gtk::HBox(0,10),
				       ),
		);
    } else {
	gtkpack($advanced_box,
		$retore_box = gtkpack_(new Gtk::HBox(0,1),
				       message_norestorefile_box(),
				       ),
		),
     }
    $custom_help = "restore";
    $current_widget = \&restore_box;
    $central_widget = \$retore_box;
    $up_box->show_all();
}

################################################  BUTTON_BOX  ################################################  

sub button_box_adv {
    $button_box_tmp->destroy();
    gtkpack($button_box,
	    $button_box_tmp = gtkpack_(new Gtk::HButtonBox,
				       0, gtksignal_connect(new Gtk::Button(_(" Cancel ")), clicked => sub { 
					   ${$central_widget}->destroy(); interactive_mode_box();  }),
				       0, gtksignal_connect(new Gtk::Button(_(" Help ")), clicked => sub { 
					   ${$central_widget}->destroy(); adv_help(\&$current_widget,$custom_help );  }),
				       1, new Gtk::HBox(0, 1),	
				       0, gtksignal_connect(new Gtk::Button(_(" Previous ")), clicked => sub { 
					   ${$central_widget}->destroy(); $previous_widget->(); }),
				       0, gtksignal_connect(new Gtk::Button(_(" Save ")), clicked => sub { 
					   ${$central_widget}->destroy();  save_conf_file(); $previous_widget->(); }),
				       ),
	    );
}

sub button_box_restore_main {
    $button_box_tmp->destroy();

    gtkpack($button_box,
	    $button_box_tmp = gtkpack_(gtkpack(gtkset_layout(new Gtk::HButtonBox, -start),
					      gtksignal_connect(new Gtk::Button(_(" Cancel ")), clicked => sub { 
						  ${$central_widget}->destroy(); interactive_mode_box();  }),
					      gtksignal_connect(new Gtk::Button(_("     Help      ")), clicked => sub {
						  ${$central_widget}->destroy(); 
						  adv_help(\&$current_widget, $custom_help);
					      }),
					      ),
				       ),
	    );
}

sub button_box_backup_end {
    $button_box_tmp->destroy();

    gtkpack($button_box,
	    $button_box_tmp = gtkpack_(new Gtk::HButtonBox,
				       0, gtksignal_connect(new Gtk::Button(_(" Cancel ")), clicked => sub { 
					   ${$central_widget}->destroy(); interactive_mode_box();  }),
				       0, gtksignal_connect(new Gtk::Button(_(" Help ")), clicked => sub { 
					   ${$central_widget}->destroy(); adv_help(\&$current_widget,$custom_help );  }),
				       1, new Gtk::HBox(0, 1),	
				       0, gtksignal_connect(new Gtk::Button(_(" Previous ")), clicked => sub { 
					   ${$central_widget}->destroy(); $previous_widget->(); }),
				       0, gtksignal_connect(new Gtk::Button(_(" Build Backup ")), clicked => sub { 
					   ${$central_widget}->destroy();
					   build_backup_status();
					   build_backup_files
(); 
				       }),
				       ),
	    );
}

sub button_box_wizard_end {
    $button_box_tmp->destroy();

    gtkpack($button_box,
	    $button_box_tmp = gtkpack_(new Gtk::HButtonBox,
				       0, gtksignal_connect(new Gtk::Button(_(" Cancel ")), clicked => sub { 
					   ${$central_widget}->destroy(); interactive_mode_box();  }),
				       0, gtksignal_connect(new Gtk::Button(_(" Help ")), clicked => sub { 
					   ${$central_widget}->destroy(); adv_help(\&$current_widget,$custom_help );  }),
				       1, new Gtk::HBox(0, 1),	
				       0, gtksignal_connect(new Gtk::Button(_(" Previous ")), clicked => sub { 
					   ${$central_widget}->destroy(); $previous_widget->(); }),
				       0, gtksignal_connect(new Gtk::Button(_(" Save ")), clicked => sub { 
 					   ${$central_widget}->destroy();  save_conf_file(); interactive_mode_box(); }),
				       ),
	    );
}

sub button_box_restore_end {
    $button_box_tmp->destroy();

    gtkpack($button_box,
	    $button_box_tmp = gtkpack_(new Gtk::HButtonBox,
				       0, gtksignal_connect(new Gtk::Button(_(" Cancel ")), clicked => sub { 
					   ${$central_widget}->destroy(); interactive_mode_box();  }),
				       0, gtksignal_connect(new Gtk::Button(_(" Help ")), clicked => sub { 
					   ${$central_widget}->destroy(); adv_help(\&$current_widget,$custom_help );  }),
				       1, new Gtk::HBox(0, 1),	
				       0, gtksignal_connect(new Gtk::Button(_(" Previous ")), clicked => sub { 
					   ${$central_widget}->destroy(); $previous_widget->(); }),
				       0, gtksignal_connect(new Gtk::Button(_(" Restore ")), clicked => sub { 
 					   ${$central_widget}->destroy(); restore_backend(); }),
				       ),
	    );
}

sub button_box_build_backup_end {
    $button_box_tmp->destroy();

    gtkpack($button_box,
	    $button_box_tmp = gtkpack(gtkset_layout(new Gtk::HButtonBox, -start),
				       gtksignal_connect(new Gtk::Button(_(" Close ")), clicked => sub { 
					   ${$central_widget}->destroy(); interactive_mode_box();  }),
				       ),
	    );
}

sub button_box_build_backup {
    $button_box_tmp->destroy();

    gtkpack($button_box,
	    $button_box_tmp = gtkpack_(new Gtk::HButtonBox,
				       1, gtksignal_connect(new Gtk::Button(_(" Cancel ")), clicked => sub { 
					   ${$central_widget}->destroy(); interactive_mode_box();  }),
				       1, gtksignal_connect(new Gtk::Button(_("     Help      ")), clicked => sub {
					   ${$central_widget}->destroy(); adv_help(\&$current_widget,$custom_help); }),
				       1, new Gtk::HBox(0, 0),
				       0, gtksignal_connect(new Gtk::Button(_(" Previous ")), clicked => sub { 
					   ${$central_widget}->destroy(); $previous_widget->(); }),
				       1, gtksignal_connect(new Gtk::Button(_("     Next      ")), clicked => sub {
					   ${$central_widget}->destroy(); $next_widget->();
				       }),
				       ),
	    );
}

sub button_box_restore {

    $button_box_tmp->destroy();

    gtkpack($button_box,
	    $button_box_tmp = gtkpack_(new Gtk::HButtonBox,
				       1, gtksignal_connect(new Gtk::Button(_(" Cancel ")), clicked => sub { 
					   ${$central_widget}->destroy(); interactive_mode_box();  }),
				       1, gtksignal_connect(new Gtk::Button(_("     Help      ")), clicked => sub {
					   ${$central_widget}->destroy(); adv_help(\&$current_widget,$custom_help); }),
				       1, new Gtk::HBox(0, 0),
				       0, gtksignal_connect(new Gtk::Button(_(" Previous ")), clicked => sub { 
					   ${$central_widget}->destroy(); $previous_widget->(); }),
				       1, gtksignal_connect(new Gtk::Button(_("     Next      ")), clicked => sub {
					   ${$central_widget}->destroy(); $next_widget->();
				       }),
				       ),
	    );
}

sub button_box_wizard {
    $button_box_tmp->destroy();

    gtkpack($button_box,
	    $button_box_tmp = gtkpack_(new Gtk::HButtonBox,
				       1, gtksignal_connect(new Gtk::Button(_(" Cancel ")), clicked => sub { 
					   ${$central_widget}->destroy(); interactive_mode_box();  }),
				       1, gtksignal_connect(new Gtk::Button(_("     Help      ")), clicked => sub {
					   ${$central_widget}->destroy(); adv_help(\&$current_widget,$custom_help); }),
				       1, new Gtk::HBox(0, 0),
				       0, gtksignal_connect(new Gtk::Button(_(" Previous ")), clicked => sub { 
					   ${$central_widget}->destroy(); $previous_widget->(); }),
				       1, gtksignal_connect(new Gtk::Button(_("     Next      ")), clicked => sub {
					   ${$central_widget}->destroy(); $next_widget->();
				       }),
				       ),
	    );
}

sub button_box_main {
    $button_box_tmp->destroy();

    gtkpack($button_box,
	    $button_box_tmp = gtkpack(gtkset_layout(new Gtk::HButtonBox, -start),
				      gtksignal_connect(new Gtk::Button(_("close")), clicked => sub {  
					  Gtk->main_quit() }),
				      gtksignal_connect(new Gtk::Button(_(" Help ")), clicked => sub { 
					  ${$central_widget}->destroy(); adv_help(\&interactive_mode_box,$custom_help) }),
				      ),
	    );
}

################################################  MESSAGES  ################################################  

sub message_norestorefile_box {
    $box2->destroy();
    my ($pix_warn_map, $pix_warn_mask) = gtkcreate_png('warning');
    
    gtkadd($advanced_box,
	   $box2 = gtkpack_(new Gtk::HBox(0, 15),	
			    1, new Gtk::VBox(0, 5),	
			    1, gtkpack(new Gtk::HBox(0, 15),	
				       new Gtk::VBox(0, 5),	
				       new Gtk::Pixmap($pix_warn_map, $pix_warn_mask),
				       _("Please Build backup before to restore it...\n or verify that your path to save is correct."),
				       new Gtk::VBox(0, 5),	
				       ),
			    1, new Gtk::VBox(0, 5),	
			    ),
	   );
    button_box_restore_main();
    $central_widget = \$box2;
    $up_box->show_all();    
}

sub message_norestore_box {
    $box2->destroy();
    my ($pix_warn_map, $pix_warn_mask) = gtkcreate_png('warning');
    
    gtkadd($advanced_box,
	   $box2 = gtkpack_(new Gtk::HBox(0, 15),	
			    1, new Gtk::VBox(0, 5),	
			    1, gtkpack(new Gtk::HBox(0, 15),	
				       new Gtk::VBox(0, 5),	
				       new Gtk::Pixmap($pix_warn_map, $pix_warn_mask),
				       _(" Please check data to restore..."),
				       new Gtk::VBox(0, 5),	
				       ),
			    1, new Gtk::VBox(0, 5),	
			    ),
	   );
    button_box_restore_main();
    $central_widget = \$box2;
    $up_box->show_all();    
}

sub message_noselect_box {
    $box2->destroy();
    my ($pix_warn_map, $pix_warn_mask) = gtkcreate_png('warning');
    
    gtkadd($advanced_box,
	   $box2 = gtkpack_(new Gtk::HBox(0, 15),	
			    1, new Gtk::VBox(0, 5),	
			    1, gtkpack(new Gtk::HBox(0, 15),	
				       new Gtk::VBox(0, 5),	
				       new Gtk::Pixmap($pix_warn_map, $pix_warn_mask),
				       _(" Please check way where backup..."),
				       new Gtk::VBox(0, 5),	
				       ),
			    1, new Gtk::VBox(0, 5),	
			    ),
	   );
    $previous_widget = \&wizard_step2;
    $next_widget = \&wizard_step2;
    $central_widget = \$box2;
    $up_box->show_all();    
}

sub message_noselect_what_box {
    $box2->destroy();
    my ($pix_warn_map, $pix_warn_mask) = gtkcreate_png('warning');
    
    gtkadd($advanced_box,
	   $box2 = gtkpack_(new Gtk::HBox(0, 15),	
			    1, new Gtk::VBox(0, 5),	
			    1, gtkpack(new Gtk::HBox(0, 15),	
				       new Gtk::VBox(0, 5),	
				       new Gtk::Pixmap($pix_warn_map, $pix_warn_mask),
				       _(" Please check data to backup..."),
				       new Gtk::VBox(0, 5),	
				       ),
			    1, new Gtk::VBox(0, 5),	
			    ),
	   );
    $previous_widget = \&wizard;
    $next_widget = \&wizard;
    $central_widget = \$box2;
    $up_box->show_all();    
}

sub message_noconf_box {
    $box2->destroy();
    my ($pix_warn_map, $pix_warn_mask) = gtkcreate_png('warning');

    gtkadd($advanced_box,
	   $box2 = gtkpack_(new Gtk::HBox(0, 15),	
			    1, new Gtk::VBox(0, 5),	
			    1, gtkpack(new Gtk::HBox(0, 15),	
				       new Gtk::VBox(0, 5),	
				       new Gtk::Pixmap($pix_warn_map, $pix_warn_mask),
				       _(" No configuration file found \nplease click Wizard or Advanced."),
				       new Gtk::VBox(0, 5),	
				       ),
			    1, new Gtk::VBox(0, 5),	
			    ),
	   );
    button_box_restore_main();
    $central_widget = \$box2;
    $up_box->show_all();    
}

sub message_underdevel {
    $box2->destroy();
    my ($pix_warn_map, $pix_warn_mask) = gtkcreate_png('warning');

    gtkadd($advanced_box,
	   $box2 = gtkpack_(new Gtk::HBox(0, 15),	
			    1, new Gtk::VBox(0, 5),	
			    1, gtkpack(new Gtk::HBox(0, 15),	
				       new Gtk::VBox(0, 5),	
				       new Gtk::Pixmap($pix_warn_map, $pix_warn_mask),
				       _(" Under Devel ... please wait."),
				       new Gtk::VBox(0, 5),	
				       ),
			    1, new Gtk::VBox(0, 5),	
			    ),
	   );
    $central_widget = \$box2;
    $up_box->show_all();    
}

################################################  BUILD_BACKUP  ################################################  

sub progress {
    my ($progressbar, $incr, $label_text) = @_;
    my($new_val) = $progressbar->get_current_percentage;
    $new_val += $incr;
    if ($new_val > 1) {$new_val = 1}
    $progressbar->update($new_val);
    $progressbar->{label}->set($label_text);
    Gtk->main_iteration while Gtk->events_pending;
}

sub find_backup_to_put_on_cd {
    my @list_backup_tmp;
    my @data_backuped_tmp;
    @data_backuped = ();
    -d $save_path and my @list_backup = all($save_path);
    foreach (grep /^backup_other/, @list_backup) {
	$other_backuped = 1;
	chomp;
	my $tail  = (split(' ',`du $save_path/$_` ))[0] ;
	s/^backup_other//gi;
	s/.tar.gz$//gi;
	s/.tar.bz2$//gi;
	my @user_date = split(/\_20/,$_ );
	my @user_date2 = split(/\_/,$user_date[1] );
	my $to_put = "  other_data,          (tail: $tail ko, date: 20$user_date2[0], hour: $user_date2[1])";
	push @data_backuped , $to_put;
    }
    foreach (grep /^backup_sys/, @list_backup) {
	$sys_backuped = 1;
	chomp;
	my $tail  = (split(' ',`du $save_path/$_` ))[0] ;
	s/^backup_other//gi;
	s/.tar.gz$//gi;
	s/.tar.bz2$//gi;
	my @user_date = split(/\_20/,$_ );
	my @user_date2 = split(/\_/,$user_date[1] );
	my $to_put = "  system,          (tail: $tail ko, date: 20$user_date2[0], hour: $user_date2[1])";
	push @data_backuped , $to_put;
    }
    foreach (grep /^backup_user_/, @list_backup) {
	chomp;
	my $tail  = (split(' ',`du $save_path/$_` ))[0] ;
	s/^backup_user_//gi;
	s/.tar.gz$//gi;
	s/.tar.bz2$//gi;
	my @user_date = split(/\_20/,$_ );
	my @user_date2 = split(/\_/,$user_date[1] );
	my $to_put = "  $user_date[0],          (tail: $tail ko, date: 20$user_date2[0], hour: $user_date2[1])";
	push @data_backuped , $to_put;
    }
}

sub build_backup_status {
    $pbar =   new Gtk::ProgressBar;
    $pbar1 =  new Gtk::ProgressBar;
    $pbar2 =  new Gtk::ProgressBar;
    $pbar3 =  new Gtk::ProgressBar;
    button_box_build_backup_end();
    gtkpack($advanced_box,
	    $table = create_packtable({ col_spacings => 10, row_spacings => 5},
   [""], 
   [""], 
   [""], 
   [""], 
   [""], 
   [""], 
   [""], 
   [""], 
   [_("Backup system files")],
   [ $pbar, $pbar->{label} = new Gtk::Label(' ' )],
   [_("Backup user files") ],
   [$pbar1,$pbar1->{label} = new Gtk::Label(' ' ) ],
   [_("Backup other files")],
   [ $pbar2, $pbar2->{label} = new Gtk::Label(' ' ) ],
   [_("Total Progress")],
   [$pbar3,$pbar3->{label} = new Gtk::Label(' ' ) ],
				      ),
	    );
    $custom_help = "options";
    $central_widget = \$table;
    $up_box->show_all();
    Gtk->main_iteration while Gtk->events_pending;
}

sub build_backup_box_see_conf {
    my $box2;    
    my $text = new Gtk::Text(undef, undef);
    system_state();
    gtktext_insert($text, $system_state);
    button_box_restore_main();

    gtkpack($advanced_box,
	    $box2 =  gtkpack_(new Gtk::HBox(0, 15),	
			      1, gtkpack_(new Gtk::VBox(0,10),
					  0, _("         Drakbackup Configuration       "),
					  1, createScrolledWindow($text),
					  ),
			      ),
	    );
    button_box_backup_end();
    $custom_help = "";
    $central_widget = \$box2;
    $current_widget = \&build_backup_box_see_conf;
    $previous_widget =\&build_backup_box;
    $up_box->show_all();
}

sub build_backup_box_progress {
#    build_backup_files(); 
}

sub aff_total_tail {
    my @toto = ();
    my $total = 0;
    push @toto, (split (",", $_))[1]  foreach @user_list_to_build_on_cd;
    foreach (@toto) {
	s/\s+\(tail://gi;
	s/\s+//gi;
	s/ko//gi;
	$total += $_; 
	}
    $label_tail->set("total tail: $total ko");
}

my %check_data_to_backup_cd;
sub build_backup_cd_select_data {
    my $retore_step_user;
    find_backup_to_put_on_cd();
    @user_list_to_build_on_cd = sort @data_backuped;
    @data_backuped = @user_list_to_build_on_cd;

    gtkpack($advanced_box,
	    $retore_step_user = gtkpack_(new Gtk::VBox(0,10),
		     0, new Gtk::VBox(0,10),
		     0, _(" Data list to include on CDROM. "),
		     1, createScrolledWindow( gtkpack__(new Gtk::VBox(0,0),
						      map { my $name = $_;
							    my @user_list_tmp = ();
							    my $b = new Gtk::CheckButton($name); 
							    if ( grep $name , @user_list_to_build_on_cd)  {
								gtkset_active($b, 1);
							    } else {
								gtkset_active($b, 0);
							    }
							    $b->signal_connect(toggled => sub {
								if ($check_data_to_backup_cd{$name}[1] ) {
								    $check_data_to_backup_cd{$name}[1] = 0;
								    if (!member( /$name$/, @user_list_to_build_on_cd) ) {
									push @user_list_to_build_on_cd, $name;}
								} else {
								    $check_data_to_backup_cd{$name}[1] = 1;
								    foreach (@user_list_to_build_on_cd) {
									if ($name ne $_) {
									    push @user_list_tmp, $_;
								    }
								    }
								    @user_list_to_build_on_cd = @user_list_tmp;
								}
								aff_total_tail();
							    });
							    $b } (@data_backuped) 
						      ),
					      ),
		      0, new Gtk::HSeparator,
		      0, $label_tail = new Gtk::Label(" "),
		      0, new Gtk::HSeparator,
					 ),
	    );
    aff_total_tail();
    $next_widget = \&build_backup_box_see_conf;
    $custom_help = "restore";
    $previous_widget = \&build_backup_cd_box;
    $current_widget = \&restore_step_user;
    $central_widget = \$retore_step_user;
    $up_box->show_all();
}

sub build_backup_cd_box {
    my $box_build_backup_cd;
    my $combo_where_cd_time = new Gtk::Combo();
    my $adj = new Gtk::Adjustment 4.0, 1.0, 10000.0, 1.0, 5.0, 0.0;
    $combo_where_cd_time->set_popdown_strings ("650","700", "750", "800");

    button_box_build_backup();
    gtkpack($advanced_box,
	    $box_build_backup_cd = gtkpack_(new Gtk::VBox(0, 6),
	 0, my $check_where_cd = new Gtk::CheckButton( _(" Use CD/DVDROM to backup")),
	 0, new Gtk::HSeparator,
	 0, new Gtk::VBox(0, 5),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please choose your CD space")), $where_cd),
		     1, new Gtk::VBox(0, 5),
		     0, gtkset_usize(gtkset_sensitive($combo_where_cd_time, $where_cd), 100, 20),
		     ),
	 0, new Gtk::VBox(0, 5),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please entrer the cd writer speed ")),  $where_cd ),
		     1, new Gtk::VBox(0, 6),
		     0, gtkset_usize(gtkset_sensitive(my $spinner = new Gtk::SpinButton( $adj, 0, 0), $where_cd ),  100, 20),
		     ),				 
	 0, new Gtk::VBox(0, 5),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please check if you are using CDRW media")), $where_cd),
		     1, new Gtk::VBox(0, 5),
		     0, gtkset_sensitive(my $check_cdrw = new Gtk::CheckButton(), $where_cd),
		     ),
	 0, new Gtk::VBox(0, 5),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please check if you want to erase your CDRW before")), $cdrw && $where_cd),
		     1, new Gtk::VBox(0, 5),
		     0, gtkset_sensitive(my $check_cdrw_erase = new Gtk::CheckButton(), $cdrw && $where_cd),
		     ),
	 0, new Gtk::VBox(0, 5),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please enter your CD Writer device name (ex: 0,1,0)")),  $where_cd),
		     1, new Gtk::VBox(0, 5),
		     0, gtkset_usize(gtkset_sensitive($cd_devive_entry = new Gtk::Entry(), $where_cd), 100, 20),
		     ),
	 0, new Gtk::VBox(0, 5),
	 0, gtkpack_(new Gtk::HBox(0,10),
		     0, gtkset_sensitive(new Gtk::Label(_("Please check if you want to include install boot on your CD.")),  0),
		     1, new Gtk::VBox(0, 5),
		     0, gtkset_sensitive(my $check_cd_with_install_boot = new Gtk::CheckButton(), 0),
		     ),
	 ),
	    );
    foreach ([$check_cdrw_erase, \$cdrw_erase], [$check_cd_with_install_boot, \$cd_with_install_boot ]) {
	my $ref = $_->[1];
	gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; })
	}
    gtksignal_connect(gtkset_active($check_where_cd, $where_cd), toggled => sub { 
	$where_cd = $where_cd ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
	if($where_cd) { $next_widget = \&build_backup_cd_select_data;}
	else { $next_widget = \&build_backup_cd_box;}
    });
    gtksignal_connect(gtkset_active($check_cdrw, $cdrw), toggled => sub { 
	$cdrw = $cdrw ? 0 : 1;
	${$central_widget}->destroy();
	$current_widget->();
    });
    if($where_cd) { $next_widget = \&build_backup_cd_select_data;}
    else { $next_widget = \&build_backup_cd_box;}
    $cd_devive_entry->set_text( $cd_devive );
    $cd_devive_entry->signal_connect( 'changed', sub { $cd_devive = $cd_devive_entry->get_text(); });
    $combo_where_cd_time->entry->set_text($cd_time);
    $combo_where_cd_time->entry->signal_connect( 'changed', sub { $cd_time = $combo_where_cd_time->entry->get_text()});	       
    $current_widget = \&build_backup_cd_box;
    $previous_widget =\&build_backup_box; 
    $central_widget = \$box_build_backup_cd;
    $up_box->show_all();
}

sub build_backup_box {
    $box2->destroy();
    my ($pix_cd_map, $pix_cd_mask) = gtkcreate_png("ic82-CD-40");
    my ($pix_hd_map, $pix_hd_mask) = gtkcreate_png("ic82-discdurwhat-40");
    my ($pix_options_map, $pix_options_mask) = gtkcreate_png("ic82-moreoption-40");

    gtkadd($advanced_box,
	   $box2 = gtkpack_(new Gtk::HBox(0, 15),	
			    1, new Gtk::VBox(0, 5),	
			    1, gtkpack_(new Gtk::VBox(0, 15),	
					1, new Gtk::VBox(0, 5),	
					1, gtksignal_connect(my $button_from_conf_file = new Gtk::Button(),
							     clicked => sub { ${$central_widget}->destroy();
									      build_backup_box_see_conf();
									  }),
					0, new Gtk::VBox(0, 5),	
					1, gtksignal_connect(my $button_on_cd = new Gtk::Button(), 
							     clicked => sub { ${$central_widget}->destroy(); 
									      $where_cd = 1;
									      build_backup_cd_box();
									  }),
					0, new Gtk::VBox(0, 5),	
					1, gtksignal_connect(my $button_see_conf = new Gtk::Button(), 
							     clicked => sub { ${$central_widget}->destroy();
									      build_backup_box_see_conf();
									  }),
					1, new Gtk::VBox(0, 5),	
					),
			    1, new Gtk::VBox(0, 5),	
			    ),
	   );

    $button_from_conf_file->add(gtkpack(new Gtk::HBox(0,10),
			      new Gtk::Pixmap($pix_hd_map, $pix_hd_mask),
			      new Gtk::Label(_(" Backup Now from configuration file ")),
			      new Gtk::HBox(0, 5)
			      ));
    $button_on_cd->add(gtkpack(new Gtk::HBox(0,10),
			      new Gtk::Pixmap($pix_cd_map, $pix_cd_mask),
			      new Gtk::Label(_(" Backup Now on CDROM ")),
			      new Gtk::HBox(0, 5)
			      ));
    $button_see_conf->add(gtkpack(new Gtk::HBox(0,10),
			      new Gtk::Pixmap($pix_options_map, $pix_options_mask),
			      new Gtk::Label(_(" View Backup Configuration.  ")),
			      new Gtk::HBox(0, 5)
			      ));

    $custom_help = "options";
    button_box_restore_main();
    $central_widget = \$box2;
    $current_widget = \&build_backup_box;
    $up_box->show_all();    
}

################################################  INTERACTIVE  ################################################  

sub interactive_mode_box {
    $box2->destroy();

    read_conf_file();
    gtkadd($advanced_box,
	   $box2 = gtkpack_(new Gtk::HBox(0, 15),	
			    1, new Gtk::VBox(0, 5),	
			    1, gtkpack_(new Gtk::VBox(0, 15),	
					1, new Gtk::VBox(0, 5),	
					1, gtksignal_connect(new Gtk::Button(_(" Advanced Configuration ")), 
							     clicked => sub { button_box_adv();
									      ${$central_widget}->destroy();
									      advanced_box(); }),
					1, gtksignal_connect(new Gtk::Button(_(" Wizard Configuration ")), 
							     clicked => sub { ${$central_widget}->destroy();
									      read_conf_file();
									      wizard(); }),
					1, gtksignal_connect(new Gtk::Button(_(" Backup Now ")), 
							     clicked => sub { ${$central_widget}->destroy();
									      if ($cfg_file_exist) { build_backup_box();}
									      else { message_noconf_box();}
									  }),
					1, gtksignal_connect(new Gtk::Button(_("     Restore      ")), 
							     clicked => sub {${$central_widget}->destroy(); restore_box();}),
					1, new Gtk::VBox(0, 5),	
					),
			    1, new Gtk::VBox(0, 5),	
			    ),
	   );
    button_box_main();
    $custom_help = "main";
    $central_widget = \$box2;
    $up_box->show_all();    
}

sub interactive_mode {
    $interactive = 1;
    my $box;
    my $window1 = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel;
    init Gtk;
    $window1->signal_connect (delete_event => sub { Gtk->exit(0) });
    $window1->set_position(1);
    $window1->set_title(_("Drakbackup"));
    my ($pix_u_map, $pix_u_mask) = gtkcreate_png("BDO-drakebackup1");
#     my ($pix_l_map, $pix_l_mask) = gtkcreate_png("backup_left2");
#     my ($pix_r_map, $pix_r_mask) = gtkcreate_png("backup_bot2");
    read_conf_file();    

    gtkadd($window1,
	   gtkpack(new Gtk::VBox(0,0),
		   gtkpack(gtkset_usize($up_box = new Gtk::VBox(0, 5), 540, 400),
		      $box = gtkpack_(new Gtk::VBox(0, 3),
			 0,  new Gtk::Pixmap($pix_u_map, $pix_u_mask),
			    1, gtkpack_(new Gtk::HBox(0, 3),
#			       0, new Gtk::Pixmap($pix_l_map, $pix_l_mask), 
				  1, gtkpack_(new Gtk::HBox(0, 15),	
					     0, new Gtk::HBox(0, 5),	
					     1, $advanced_box = gtkpack_(new Gtk::HBox(0, 15),	
								      1, $box2 = gtkpack_(new Gtk::VBox(0, 15),	
											  ),
									  ),
					      0, new Gtk::HBox(0, 5),	
					      ),
					),
#				      0, new Gtk::Pixmap($pix_r_map, $pix_r_mask),
				      0, new Gtk::HSeparator,
				      0, $button_box = gtkpack(new Gtk::VBox(0, 15),	
							       $button_box_tmp = gtkpack(new Gtk::VBox(0, 0),	
											 ),
							       ),
				      ),
			   ),
		   ),
	   );
    interactive_mode_box();
    $custom_help = "main";
    button_box_main();
    $central_widget = \$box2;
    $window1->show_all;
    $window1->realize;
    $window1->show_all();    
    Gtk->main;
    Gtk->exit(0);
}

################################################  HELP & ABOUT  ################################################  

sub about {
    my $text = new Gtk::Text(undef, undef);
    my $about_box;
    gtkpack($up_box,
	    $about_box = gtkpack_(new Gtk::VBox(0,10),
				  1, gtkpack_(new Gtk::HBox(0,0),
					      1, gtktext_insert(gtkset_editable($text, 1), _("

")),
					      0, new Gtk::VScrollbar($text->vadj),
					      ),
				  0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -spread),
					    gtksignal_connect(new Gtk::Button(_("OK")), clicked => 
							      sub { ${$central_widget}->destroy(); interactive_mode(); }),
					    ),
				  )
	    );
    $central_widget = \$about_box;
    $up_box->show_all();
}

sub adv_help {
    my ($function, $custom_help) = @_,
    my $text = new Gtk::Text(undef, undef);
    my $advanced_box_help;
    
    if ($custom_help eq "toto") { gtktext_insert($text, _("toto")); } 
    elsif ($custom_help eq "options") { gtktext_insert($text, 
_("options description:

 In this step Drakbacup allow you to change:

 - the compression mode:
    
      if you check bzip2 compression, you will compress
      better than gzip your data (about 2-10 %).
      This options are not checked by default because
      this compression mode need more time ( about 1000% more).
 
 - the udpate mode:

      This options will update your backup, but this
      options are not really interesting because you need
      to decompress your backup before to update it.
      
 - the .backupignore mode:

      Like with cvs, Drakbackup will ignore all references
      included on  .backupignore files in each directories.
      ex: 
         \$> cat .backupignore
         *.o
         *~
         ...
      

")); }
    elsif ($custom_help eq "what") { gtktext_insert($text, 
_("options description:

 - Backup system files:
       
	This  options allow you to backup your /etc directory,
	which contain all configuration files please be
	carreful during restore step to not overwriting
		/etc/passwd 
		/etc/group 
		/etc/fstab

 - Backup User files: 

	This option allow to select all users that you want 
	to backup.
	To preserve disk space, it recommeded to not include
	browsers cache.

 - Backup Other files: 

	This option allow to add more data to save.
	With the other backup it's not possible in
	moment to select select incremental backup.		
 
 - Incremental Backups:

	The incremental backup is the most powerfull 
	option to use backup, this option allow you 
	to backup all your data the first time, and 
	only the changed after.
	So you will be able during the restore
	step, to restore your data from a specified
	date.
	If you have not selected this options all
	old backups are deleted before each backup.    


")); }
    elsif ($custom_help eq "restore") { gtktext_insert($text, 
_("restore description:
 
Only the most recent date will be used ,because with incremental 
backups it is necesarry to restore one by one each older backups.

So if you don't like to restore an user please unselect all his
check box.

Otherwise, you are able to select only one of this

 - Incremental Backups:

	The incremental backup is the most powerfull 
	option to use backup, this option allow you 
	to backup all your data the first time, and 
	only the changed after.
	So you will be able during the restore
	step, to restore your data from a specified
	date.
	If you have not selected this options all
	old backups are deleted before each backup.    



")); }
    elsif ($custom_help eq "main") { gtktext_insert($text, 
_(" Copyright (C) 2001 by MandrakeSoft (sdupont\@mandrakesoft.com)

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2, or (at your option)
 any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

                                            _____________________

description:

  Drakbacup is use to backup your system.
  During the configuration you can select 
	- System files, 
	- Users files, 
	- Other files.
	or All your system ...  and Other (like windows Partitions)

  Drakbacup allow you to backup your system on:
	- Harddrive.
	- NFS.
	- CDROM (CDRW), DVDROM (with autoboot, rescue and autoinstall.).
	- FTP.
	- Rsync.
	- Webdav.
	- Tape.

  Drakbacup allow you to Restore your system on
  choosen directory.

  Per default all backup will be stored on your
  /var/drakbackup directory

  configuration file:
	/etc/drakconf/drakbackup/drakbakup.conf


")); }
    elsif ($custom_help eq "ftp") { gtktext_insert($text, 
_("options description:

Please be careful when you are using ftp backup, because only 
backup already build are send on server.
So in moment, you need to build backup on your hard drive
before to send it.

")); } 
 
    else { gtktext_insert($text,
_(" Copyright (C) 2001 by MandrakeSoft (sdupont\@mandrakesoft.com)

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2, or (at your option)
 any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

                                            _____________________

description:

  Drakbacup is use to backup your system.
  During the configuration you can select 
	- System files, 
	- Users files, 
	- Other files.
	or All your system ...  and Other (like windows Partitions)

  Drakbacup allow you to backup your system on:
	- Harddrive.
	- NFS.
	- CDROM (CDRW), DVDROM (with autoboot, rescue and autoinstall.).
	- FTP.
	- Rsync.
	- Webdav.
	- Tape.

  Drakbacup allow you to Restore your system on
  choosen directory.

  Per default all backup will be stored on your
  /var/drakbackup directory

  configuration file:
	/etc/drakconf/drakbackup/drakbakup.conf


"));}

    gtkpack($advanced_box,
	    $advanced_box_help = gtkpack_(new Gtk::VBox(0,10),
					  1, gtkpack_(new Gtk::HBox(0,0),
						      1, $text, 
						      0, new Gtk::VScrollbar($text->vadj),
						      ),
					  0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -spread),
						    gtksignal_connect(new Gtk::Button(_("OK")), clicked => sub { 
							${$central_widget}->destroy(); $function->();  }),
						    ),
					  )
	    );
    $central_widget = \$advanced_box_help;
    $up_box->show_all();
}

sub restore_help {
    my $text = new Gtk::Text(undef, undef);
    my $about_box;
    gtkpack($up_box,
	    $about_box = gtkpack_(new Gtk::VBox(0,10),
				  1, gtkpack_(new Gtk::HBox(0,0),
					      1, gtktext_insert(gtkset_editable($text, 1), _("
Description: Drakbacup Restore Mode. 

Drakbacup allow to restore the system (etc, var files)
 from starup or on drakconf utility.

	system backup:
                   backup_sys.tar.gz 
	user backup
		   backup_user_james.tar.gz      
		   backup_user_seb.tar.gz
	other directories
                   backup_other.tar.gz          

")),
					      0, new Gtk::VScrollbar($text->vadj),
					      ),
				  0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -spread),
					    gtksignal_connect(new Gtk::Button(_("OK")), clicked => 
							      sub { ${$central_widget}->destroy(); restore();  }),
					    ),
				  )
	    );
    $central_widget = \$about_box;
    $up_box->show_all();
}


# _____________________________________________________________ DOCS

##### tester taille decompressee

#(seb@lutin)[~]-% gzip -l old_drakbackup.tar.gz 
#compressed  uncompr. ratio uncompressed_name
#   128662    174080  26.1% old_drakbackup.tar


#### tester integrite archive

# idem pour bzip2 -t
# (seb@lutin)[~]-% gzip -t drakbackup.tar.gz
#
# gzip: drakbackup.tar.gz: invalid compressed data--crc error
#
# gzip: drakbackup.tar.gz: invalid compressed data--length error





# Comment récupérer la date du jour ?

# Cf perldoc -f localtime

# ($seconde,$minute,$heure,$jour_du_mois,$annee,
# $jour_de_la_semaine,$jour_de_l _annee,$drapeau_heure_ete) = localtime(time);

# Il faut ajouter 1900 a l'année pour une date correcte ($annee+=1900) et 1 au jour du mois pour obtenir une date correcte ($jour_du_mois++).

# [Perl] Comment récupérer des informations sur un fichier ?

# Cf perldoc -f stat

# Exemple pour récupérer mtime (date de dernière modification du fichier)
# my(@etat); my($fchier)="/tmp/toto";
# # Si le fichier existe on récupère des infos dessus
# if (-e $fchier) {@etat=stat($fchier); }
# # On convertit avec localtime la valeur de mtime.
# my($date)= localtime($etat[9]);
# print $date;


#Telnet : En utilisant le package Net::Telnet

# use strict; 
# use Net::Telnet; 
# use CGI qw/:standard :html3 :netscape escape unescape/; 
# use CGI::Carp qw/fatalsToBrowser/; 
# my $username="alian"; 
# my $passwd="password"; 
# my $HOST="indy.alianet"; 
# print header; 
# my $t = new Net::Telnet (Timeout=>undef) or die "Can't connect:$!"; 
# $t->open($HOST);
# $t->login($username, $passwd); 
# my @lines = $t->cmd("/ma/commande/a/executer");
# print join(' ',@lines); 

# _____________________________________________________________ DOCS2


# Linux backups HOWTO1

# Add***jbw
# Audience: All???

# /Add***jbw
# Jerry Winegarden
# Revised 4-04-00

# Revised***jbw

# There are several utilities that can be used for backups under Linux. Which is the best? 
# There isn't any one utility that is best. It depends on the media to which you are backing up, 
# whether you are backing up just one machine or several over the network, and what you intend to 
# do with the backup. There are both free utilities which come standard with a Red Hat Linux 
# installation and third-party packages (some free, others not).

# /Revised***jbw
# List of backup utilities

# Add***jbw
# Standard Red Hat Linux (GNU) backup utilities

# /Add***jbw

#     *

#       tar 2
#     *

#       dump

#       Add***jbw
#     * rdump

#       /Add***jbw
#     *

#       cpio
#     *

#       (There are others: sharutil,find + dd, cp) 3

# Add***jbw

# Third-party backup packages

#     * BRU
#     * Networker
#     * Matt: These two are just placeholders - I need to get a proper list (I've got saved email that 
# lists some - just had time to look thru them yet)

# /Add***jbw

# There are different types of backups:

#     *

#       full 4
#     *

#       incremental

#       Add***jbw
#     * partial
#     * local
#     * remote (network)

#       /Add***jbw

# Add***jbw
# Full backups

# Full backups are intended to be a complete backup of every file. Users should not be logged in during a 
# full backup so that files are not left open for writing and thus somehow not included in a full backup.

# Partial backups

# Partial backups include only a specified set of files or directories.

# Incremental backups

# Incremental backups are intended to backup only files that have changed since a previous backup. 
# A common backup scheme is to do a full backup on the weekend when no one is in the office, with 
# incremental backups being done each night of the things that changed that day. Incremental backups 
# can even be added to the same tape, without rewinding. To restore a file from backup that was
#  changed recently, it is often quicker to find the most recent version on an incremental tape backup
#  than to have to search all the way through all the files on a long full backup tape. Thus, full
#  backups tend to be done once a week only with incrementals in between.

# /Add***jbw

# Delete***jbw

# /Delete***jbw

# tar

# tar ("tape archive" isn't just for tapes) is the most commonly used
# backup utility. 5

# To produce a backup of a directory to a file on the disk (e.g. in /tmp):

# tar cvf /tmp/foo.tar .     (output file by default is /dev/tape, so
#                                 the output file name must be specified
#                                 with the f option; here, /tmp/foo.tar)
                                
#                            c option = Create archive (wrap it up
#                                         into a "tar archive")

#                            v option = "verbose" - messages to screen
#                                         when reading/writing each file

#                            f option = specify output file name

#                            /tmp/foo.tar = output file name specified

#                           .  = source directory to create archive of
#                                 (wraps up everything under the 
#                                 current directory)

# addition of the "z" option will gzip the output file to compress it into gzip format:

# tar cvzf /tmp/foo.tar.gz

# To move a directory:

# cd fromdir; tar cvf - . | (cd todir; tar xvf -)

# To unpack an archive of a directory:

# cd destdir; tar xvf /tmp/foo.tar 6

# Further tar options:

#     *

#       x option = eXtract archive
#       it will unpack it into the current default dir (so, first: cd destdir)
#     *

#       v option = verbose
#       Can be included with any other options (good to always include this flag)
#     *

#       f option + file name = specify the INPUT file name
#       (the name of the archive file being extracted).

# "Incremental" backup with tar:

# tar -cvf tarfilename --after-date="sept 1, 2000" /home

# Add***jbw

# dump

# Dump is used to backup complete file systems, such as /, /home, or whatever file systems you have 
# defined. (File systems are listed in the file: /etc/fstab). Dump works on one file system at a time.

# Dump has the concept of a dump "level", which is indicated by a non-negative integer, usually 0-6. 
# Level 0 dumps would be a full backup (of the specified file systems, which might be partial or 
# complete depending on whether all file systems are specified). Level 1 and higher dumps are used 
# for "incremental" backups. A level 1 dump will backup files which have changed (been "touched") 
# since the last level 0 dump. A level 2 dump will backup anything changed since the last level 1 
# dump. This scheme can be used to produce a full backup on weekend (level 0 dump), followed by 
# a level n dump, where n is the day of the week (Monday = 1).

# The other important dump parameter is "-f", which refers to the "file" or device to dump to. 
# Thus, the dump backup of a file system can be written to a disk drive (in another file system) 
# or to a tape drive or a zip drive. In the case of a tape drive, the file name is the special 
# character device name: /dev/rmt0 or /dev/nrmt0 ("no-rewind" tape device) or /dev/tape or whatever 
# the device name of your tape drive.

# A dump is performed as follows:

# dump -0f /dev/rmt0 /filesystemname

# (full backup)

# or,

# dump -2f /dev/nrmt0 /filesystemname

# (incremental, level 2 backup to the no-rewind tape device (don't rewind the tape before or after writing. 
# Just add the backup to the existing tape. This is often done to have incremental backups added to the same tape).

# To extract files from a dump backup, use the utility: restore

# Restores can be done "interactively":

# restore -i

# Dump/restore to be continued...

# cpio
# CPIO is another system backup utility. The rpm package installation utility actually uses cpio 
# format to package software for system installation.

# CPIO - to be continued

# 1This actually reads like, not a "backups HOWTO", but a "backups using tar HOWTO". You mention
#  other archiving utilities, but don't explain how to use them, and also don't explain why tar
#  is used in this document instead of the others.

# ***jbw: I haven't gotten around to writing the details on how to for dump, cpio. Sorry. I'll work
#  on it. This doc is definitely not just a tar howto (heh, I use dump myself, most often, even 
# though some duluggers call dump "evil" under linux).

# 2What does each utility do? Sure, tar means "tape archiver", which is alluded to later; what about the others?

# 3Is this a list that is incomplete, and the author will add to it later? Why the ellipsis?
# ***jbw - Right! List is incomplete and to be finished later. I did add to the list, parenthetically,
#  but I didn't describe those additions. (e.g. find + dd is a two-step method: find ... | dd ...)

# 4It would be helpful to explain the difference between the two. For example:
# A full backup makes an archive of the entire contents of a user's... hard drive? Filesystem? Home directory?
# An incremental backup only includes those parts of the... hard drive? Filesystem? Home directory? ...which 
# have changed since the last time a backup was made.

# ***jbw

# I added the paragraphs describing full, partial, and incremental backups, and I explained the strategy of 
# how they are used (full once a week, incrementals every night) and why such a strategy is used (easier to 
# find one file to be restored from an incremental backup tape, which will have many fewer files written).

# 5Any particular reason this section is pre-formatted?
# YES!!! As with anything that's sort of a "man page" or a real, live, .conf file, it's often done with

# tag.  That is quite intentional to 
# get things formatted in an easily readable format without too much work! 
# The 

# tag is intentional here.  It is even desirable here, 
# WITHOUT quot or footnote or other tags!!!  It's sort of comparable to
# getting a screen shot to show exactly how something is seen.


# 6This is the only part of the HOWTO that actually shows "HOW TO" do something. Even so, the reasons 
# why you'd want to do this aren't explained.