/usr/share/backintime/qt4/settingsdialog.py is in backintime-qt4 1.1.12-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | # Back In Time
# Copyright (C) 2008-2016 Oprea Dan, Bart de Koning, Richard Bailey, Germar Reitze, Taylor Raack
#
# 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 of the License, 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import os
import datetime
import gettext
import copy
import grp
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import config
import tools
import qt4tools
import mount
import messagebox
from exceptions import MountException
_=gettext.gettext
class SettingsDialog( QDialog ):
def __init__( self, parent ):
super(SettingsDialog, self).__init__(parent)
self.parent = parent
self.config = parent.config
self.snapshots = parent.snapshots
self.config_copy_dict = copy.copy( self.config.dict )
self.current_profile_org = self.config.get_current_profile()
import icon
self.icon = icon
self.setWindowIcon(icon.SETTINGS_DIALOG)
self.setWindowTitle( _( 'Settings' ) )
self.main_layout = QVBoxLayout(self)
#profiles
layout = QHBoxLayout()
self.main_layout.addLayout( layout )
layout.addWidget( QLabel( _('Profile:'), self ) )
self.first_update_all = True
self.disable_profile_changed = True
self.combo_profiles = QComboBox( self )
layout.addWidget( self.combo_profiles, 1 )
QObject.connect( self.combo_profiles, SIGNAL('currentIndexChanged(int)'), self.current_profile_changed )
self.disable_profile_changed = False
self.btn_edit_profile = QPushButton(icon.PROFILE_EDIT, _('Edit'), self )
QObject.connect( self.btn_edit_profile, SIGNAL('clicked()'), self.edit_profile )
layout.addWidget( self.btn_edit_profile )
# update to full system backup button
self.btn_modify_profile_for_full_system_backup = QPushButton(icon.ADD, _('Modify for Full System Backup'), self )
QObject.connect( self.btn_modify_profile_for_full_system_backup, SIGNAL('clicked()'), self.modify_profile_for_full_system_backup )
layout.addWidget( self.btn_modify_profile_for_full_system_backup )
self.btn_add_profile = QPushButton(icon.ADD, _('Add'), self)
QObject.connect( self.btn_add_profile, SIGNAL('clicked()'), self.add_profile )
layout.addWidget( self.btn_add_profile )
self.btn_remove_profile = QPushButton(icon.REMOVE, _('Remove'), self)
QObject.connect( self.btn_remove_profile, SIGNAL('clicked()'), self.remove_profile )
layout.addWidget( self.btn_remove_profile )
#TABs
self.tabs_widget = QTabWidget( self )
self.main_layout.addWidget( self.tabs_widget )
#occupy whole space for tabs
scrollButtonDefault = self.tabs_widget.usesScrollButtons()
self.tabs_widget.setUsesScrollButtons(False)
#TAB: General
scrollArea = QScrollArea(self)
scrollArea.setFrameStyle(QFrame.NoFrame)
self.tabs_widget.addTab( scrollArea, _( 'General' ) )
layoutWidget = QWidget(self)
layout = QVBoxLayout(layoutWidget)
#select mode
self.mode = None
vlayout = QVBoxLayout()
layout.addLayout( vlayout )
self.lbl_modes = QLabel( _( 'Mode:' ), self )
self.combo_modes = QComboBox( self )
hlayout = QHBoxLayout()
hlayout.addWidget(self.lbl_modes)
hlayout.addWidget(self.combo_modes, 1)
vlayout.addLayout(hlayout)
store_modes = {}
for key in list(self.config.SNAPSHOT_MODES.keys()):
store_modes[key] = self.config.SNAPSHOT_MODES[key][1]
self.fill_combo( self.combo_modes, store_modes )
#encfs security warning
self.encfsWarning = QLabel(_("<b>Warning:</b> %(app)s uses EncFS for encryption. A recent security audit "
"revealed several possible attack vectors for this. "
"Please take a look at 'A NOTE ON SECURITY' in 'man backintime'.") \
% {'app': self.config.APP_NAME} )
self.encfsWarning.setWordWrap(True)
layout.addWidget(self.encfsWarning)
#Where to save snapshots
group_box = QGroupBox( self )
self.mode_local = group_box
group_box.setTitle( _( 'Where to save snapshots' ) )
layout.addWidget( group_box )
vlayout = QVBoxLayout( group_box )
hlayout = QHBoxLayout()
vlayout.addLayout( hlayout )
self.edit_snapshots_path = QLineEdit( self )
self.edit_snapshots_path.setReadOnly( True )
QObject.connect( self.edit_snapshots_path, SIGNAL('textChanged(QString)'), self.on_full_path_changed )
hlayout.addWidget( self.edit_snapshots_path )
self.btn_snapshots_path = QToolButton(self)
self.btn_snapshots_path.setToolButtonStyle(Qt.ToolButtonIconOnly)
self.btn_snapshots_path.setIcon(icon.FOLDER)
self.btn_snapshots_path.setText(_('Folder'))
self.btn_snapshots_path.setMinimumSize(32,28)
hlayout.addWidget( self.btn_snapshots_path )
QObject.connect( self.btn_snapshots_path, SIGNAL('clicked()'), self.on_btn_snapshots_path_clicked )
#SSH
group_box = QGroupBox( self )
self.mode_ssh = group_box
group_box.setTitle( _( 'SSH Settings' ) )
layout.addWidget( group_box )
vlayout = QVBoxLayout( group_box )
hlayout1 = QHBoxLayout()
vlayout.addLayout( hlayout1 )
hlayout2 = QHBoxLayout()
vlayout.addLayout( hlayout2 )
hlayout3 = QHBoxLayout()
vlayout.addLayout( hlayout3 )
self.lbl_ssh_host = QLabel( _( 'Host:' ), self )
hlayout1.addWidget( self.lbl_ssh_host )
self.txt_ssh_host = QLineEdit( self )
hlayout1.addWidget( self.txt_ssh_host )
self.lbl_ssh_port = QLabel( _( 'Port:' ), self )
hlayout1.addWidget( self.lbl_ssh_port )
self.txt_ssh_port = QLineEdit( self )
hlayout1.addWidget( self.txt_ssh_port )
self.lbl_ssh_user = QLabel( _( 'User:' ), self )
hlayout1.addWidget( self.lbl_ssh_user )
self.txt_ssh_user = QLineEdit( self )
hlayout1.addWidget( self.txt_ssh_user )
self.lbl_ssh_path = QLabel( _( 'Path:' ), self )
hlayout2.addWidget( self.lbl_ssh_path )
self.txt_ssh_path = QLineEdit( self )
QObject.connect( self.txt_ssh_path, SIGNAL('textChanged(QString)'), self.on_full_path_changed )
hlayout2.addWidget( self.txt_ssh_path )
self.lbl_ssh_cipher = QLabel( _( 'Cipher:' ), self )
hlayout3.addWidget( self.lbl_ssh_cipher )
self.combo_ssh_cipher = QComboBox( self )
hlayout3.addWidget( self.combo_ssh_cipher )
self.fill_combo( self.combo_ssh_cipher, self.config.SSH_CIPHERS )
self.lbl_ssh_private_key_file = QLabel( _( 'Private Key:' ), self )
hlayout3.addWidget( self.lbl_ssh_private_key_file )
self.txt_ssh_private_key_file = QLineEdit( self )
self.txt_ssh_private_key_file.setReadOnly( True )
hlayout3.addWidget( self.txt_ssh_private_key_file )
self.btn_ssh_private_key_file = QToolButton(self)
self.btn_ssh_private_key_file.setToolButtonStyle(Qt.ToolButtonIconOnly)
self.btn_ssh_private_key_file.setIcon(icon.FOLDER)
self.btn_ssh_private_key_file.setText(_('Key File'))
self.btn_ssh_private_key_file.setMinimumSize(32,28)
hlayout3.addWidget( self.btn_ssh_private_key_file )
QObject.connect( self.btn_ssh_private_key_file, SIGNAL('clicked()'), self.on_btn_ssh_private_key_file_clicked )
qt4tools.equal_indent(self.lbl_ssh_host, self.lbl_ssh_path, self.lbl_ssh_cipher)
#encfs
self.mode_local_encfs = self.mode_local
self.mode_ssh_encfs = self.mode_ssh
#password
group_box = QGroupBox( self )
self.frame_password_1 = group_box
group_box.setTitle( _( 'Password' ) )
layout.addWidget( group_box )
vlayout = QVBoxLayout( group_box )
hlayout1 = QHBoxLayout()
vlayout.addLayout(hlayout1)
hlayout2 = QHBoxLayout()
vlayout.addLayout(hlayout2)
self.lbl_password_1 = QLabel( _( 'Password' ), self )
hlayout1.addWidget( self.lbl_password_1 )
self.txt_password_1 = QLineEdit( self )
self.txt_password_1.setEchoMode(QLineEdit.Password)
hlayout1.addWidget( self.txt_password_1 )
self.lbl_password_2 = QLabel( _( 'Password' ), self )
hlayout2.addWidget( self.lbl_password_2 )
self.txt_password_2 = QLineEdit( self )
self.txt_password_2.setEchoMode(QLineEdit.Password)
hlayout2.addWidget( self.txt_password_2 )
self.cb_password_save = QCheckBox( _( 'Save Password to Keyring' ), self )
vlayout.addWidget( self.cb_password_save )
self.cb_password_use_cache = QCheckBox( _( 'Cache Password for Cron (Security issue: root can read password)' ), self )
vlayout.addWidget( self.cb_password_use_cache )
self.keyring_supported = tools.keyring_supported()
self.cb_password_save.setEnabled(self.keyring_supported)
#mode change
QObject.connect( self.combo_modes, SIGNAL('currentIndexChanged(int)'), self.on_combo_modes_changed )
#host, user, profile id
group_box = QGroupBox( self )
self.frame_advanced = group_box
group_box.setTitle( _( 'Advanced' ) )
layout.addWidget( group_box )
hlayout = QHBoxLayout( group_box )
hlayout.addSpacing( 12 )
vlayout2 = QVBoxLayout()
hlayout.addLayout( vlayout2 )
hlayout2 = QHBoxLayout()
vlayout2.addLayout( hlayout2 )
self.lbl_host = QLabel( _( 'Host:' ), self )
hlayout2.addWidget( self.lbl_host )
self.txt_host = QLineEdit( self )
QObject.connect( self.txt_host, SIGNAL('textChanged(QString)'), self.on_full_path_changed )
hlayout2.addWidget( self.txt_host )
self.lbl_user = QLabel( _( 'User:' ), self )
hlayout2.addWidget( self.lbl_user )
self.txt_user = QLineEdit( self )
QObject.connect( self.txt_user, SIGNAL('textChanged(QString)'), self.on_full_path_changed )
hlayout2.addWidget( self.txt_user )
self.lbl_profile = QLabel( _( 'Profile:' ), self )
hlayout2.addWidget( self.lbl_profile )
self.txt_profile = QLineEdit( self )
QObject.connect( self.txt_profile, SIGNAL('textChanged(QString)'), self.on_full_path_changed )
hlayout2.addWidget( self.txt_profile )
self.lbl_full_path = QLabel(_('Full snapshot path: '), self)
self.lbl_full_path.setWordWrap(True)
vlayout2.addWidget(self.lbl_full_path)
#Schedule
group_box = QGroupBox( self )
self.global_schedule_group_box = group_box
group_box.setTitle( _( 'Schedule' ) )
layout.addWidget( group_box )
glayout = QGridLayout( group_box )
glayout.setColumnStretch(1, 2)
self.combo_automatic_snapshots = QComboBox( self )
glayout.addWidget( self.combo_automatic_snapshots, 0, 0, 1, 2 )
self.fill_combo( self.combo_automatic_snapshots, self.config.AUTOMATIC_BACKUP_MODES )
self.lbl_automatic_snapshots_day = QLabel( _( 'Day:' ), self )
self.lbl_automatic_snapshots_day.setContentsMargins( 5, 0, 0, 0 )
self.lbl_automatic_snapshots_day.setAlignment( Qt.AlignRight | Qt.AlignVCenter )
glayout.addWidget( self.lbl_automatic_snapshots_day, 1, 0 )
self.combo_automatic_snapshots_day = QComboBox( self )
glayout.addWidget( self.combo_automatic_snapshots_day, 1, 1 )
for d in range( 1, 29 ):
self.combo_automatic_snapshots_day.addItem( QIcon(), str(d), d )
self.lbl_automatic_snapshots_weekday = QLabel( _( 'Weekday:' ), self )
self.lbl_automatic_snapshots_weekday.setContentsMargins( 5, 0, 0, 0 )
self.lbl_automatic_snapshots_weekday.setAlignment( Qt.AlignRight | Qt.AlignVCenter )
glayout.addWidget( self.lbl_automatic_snapshots_weekday, 2, 0 )
self.combo_automatic_snapshots_weekday = QComboBox( self )
glayout.addWidget( self.combo_automatic_snapshots_weekday, 2, 1 )
for d in range( 1, 8 ):
self.combo_automatic_snapshots_weekday.addItem( QIcon(), datetime.date(2011, 11, 6 + d).strftime("%A"), d )
self.lbl_automatic_snapshots_time = QLabel( _( 'Hour:' ), self )
self.lbl_automatic_snapshots_time.setContentsMargins( 5, 0, 0, 0 )
self.lbl_automatic_snapshots_time.setAlignment( Qt.AlignRight | Qt.AlignVCenter )
glayout.addWidget( self.lbl_automatic_snapshots_time, 3, 0 )
self.combo_automatic_snapshots_time = QComboBox( self )
glayout.addWidget( self.combo_automatic_snapshots_time, 3, 1 )
for t in range( 0, 2300, 100 ):
self.combo_automatic_snapshots_time.addItem( QIcon(), datetime.time( t//100, t%100 ).strftime("%H:%M"), t )
self.lbl_automatic_snapshots_time_custom = QLabel( _( 'Hours:' ), self )
self.lbl_automatic_snapshots_time_custom.setContentsMargins( 5, 0, 0, 0 )
self.lbl_automatic_snapshots_time_custom.setAlignment( Qt.AlignRight | Qt.AlignVCenter )
glayout.addWidget( self.lbl_automatic_snapshots_time_custom, 4, 0 )
self.txt_automatic_snapshots_time_custom = QLineEdit( self )
glayout.addWidget( self.txt_automatic_snapshots_time_custom, 4, 1 )
#anacron
self.lbl_automatic_snapshots_anacron = QLabel(_('Run Back In Time repeatedly. This is useful if the computer is not running regular.'))
self.lbl_automatic_snapshots_anacron.setContentsMargins( 5, 0, 0, 0 )
self.lbl_automatic_snapshots_anacron.setWordWrap(True)
glayout.addWidget(self.lbl_automatic_snapshots_anacron, 5, 0, 1, 2)
self.lbl_automatic_snapshots_anacron_period = QLabel(_('Every:'))
self.lbl_automatic_snapshots_anacron_period.setContentsMargins( 5, 0, 0, 0 )
self.lbl_automatic_snapshots_anacron_period.setAlignment( Qt.AlignRight | Qt.AlignVCenter )
glayout.addWidget(self.lbl_automatic_snapshots_anacron_period, 7, 0)
hlayout = QHBoxLayout()
self.sb_automatic_snapshots_anacron_period = QSpinBox(self)
self.sb_automatic_snapshots_anacron_period.setSingleStep( 1 )
self.sb_automatic_snapshots_anacron_period.setRange( 1, 10000 )
hlayout.addWidget(self.sb_automatic_snapshots_anacron_period)
self.combo_automatic_snapshots_anacron_unit = QComboBox( self )
self.fill_combo( self.combo_automatic_snapshots_anacron_unit, self.config.REPEATEDLY_UNITS )
hlayout.addWidget(self.combo_automatic_snapshots_anacron_unit)
hlayout.addStretch()
glayout.addLayout(hlayout, 7, 1)
#udev
self.lbl_automatic_snapshots_udev = QLabel(_('Run Back In Time as soon as the drive is connected (only once every X days).\nYou will be prompted for your sudo password.'))
self.lbl_automatic_snapshots_udev.setWordWrap(True)
glayout.addWidget(self.lbl_automatic_snapshots_udev, 6, 0, 1, 2)
QObject.connect( self.combo_automatic_snapshots, SIGNAL('currentIndexChanged(int)'), self.current_automatic_snapshot_changed )
#
layout.addStretch()
scrollArea.setWidget(layoutWidget)
scrollArea.setWidgetResizable(True)
#TAB: Include
tab_widget = QWidget( self )
self.tabs_widget.addTab( tab_widget, _( 'Include' ) )
layout = QVBoxLayout( tab_widget )
self.list_include = QTreeWidget( self )
self.list_include.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.list_include.setRootIsDecorated( False )
self.list_include.setHeaderLabels( [ _('Include files and folders'),
'Count' ] )
self.list_include_header = self.list_include.header()
self.list_include_header.setResizeMode( 0, QHeaderView.Stretch )
self.list_include_header.setClickable(True)
self.list_include_header.setSortIndicatorShown(True)
self.list_include_header.setSectionHidden(1, True)
self.list_include_sort_loop = False
QObject.connect(self.list_include_header,
SIGNAL('sortIndicatorChanged(int,Qt::SortOrder)'),
self.includeCustomSortOrder )
layout.addWidget( self.list_include )
self.list_include_count = 0
buttons_layout = QHBoxLayout()
layout.addLayout( buttons_layout )
self.btn_include_file_add = QPushButton(icon.ADD, _('Add file'), self)
buttons_layout.addWidget( self.btn_include_file_add )
QObject.connect( self.btn_include_file_add, SIGNAL('clicked()'), self.on_btn_include_file_add_clicked )
self.btn_include_add = QPushButton(icon.ADD, _('Add folder'), self)
buttons_layout.addWidget( self.btn_include_add )
QObject.connect( self.btn_include_add, SIGNAL('clicked()'), self.on_btn_include_add_clicked )
self.btn_include_remove = QPushButton(icon.REMOVE, _('Remove'), self)
buttons_layout.addWidget( self.btn_include_remove )
QObject.connect( self.btn_include_remove, SIGNAL('clicked()'), self.on_btn_include_remove_clicked )
#TAB: Exclude
tab_widget = QWidget( self )
self.tabs_widget.addTab( tab_widget, _( 'Exclude' ) )
layout = QVBoxLayout( tab_widget )
label = QLabel( _('<b>Warning:</b> Wildcards (\'foo*\', \'[fF]oo\', \'fo?\') will be ignored with mode \'SSH encrypted\'.\nOnly separate asterisk are allowed (\'foo/*\', \'foo/**/bar\')'), self )
label.setWordWrap(True)
self.lbl_ssh_encfs_exclude_warning = label
layout.addWidget( label )
self.list_exclude = QTreeWidget( self )
self.list_exclude.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.list_exclude.setRootIsDecorated( False )
self.list_exclude.setHeaderLabels( [ _('Exclude patterns, files or folders') ,
'Count' ] )
self.list_exclude_header = self.list_exclude.header()
self.list_exclude_header.setResizeMode( 0, QHeaderView.Stretch )
self.list_exclude_header.setClickable(True)
self.list_exclude_header.setSortIndicatorShown(True)
self.list_exclude_header.setSectionHidden(1, True)
self.list_exclude_sort_loop = False
QObject.connect(self.list_exclude_header,
SIGNAL('sortIndicatorChanged(int,Qt::SortOrder)'),
self.excludeCustomSortOrder )
layout.addWidget( self.list_exclude )
self.list_exclude_count = 0
label = QLabel( _('Highly recommended:'), self )
qt4tools.set_font_bold( label )
layout.addWidget( label )
label = QLabel( ', '.join(sorted(self.config.DEFAULT_EXCLUDE)), self )
label.setWordWrap(True)
layout.addWidget( label )
buttons_layout = QHBoxLayout()
layout.addLayout( buttons_layout )
self.btn_exclude_add = QPushButton(icon.ADD, _('Add'), self)
buttons_layout.addWidget( self.btn_exclude_add )
QObject.connect( self.btn_exclude_add, SIGNAL('clicked()'), self.on_btn_exclude_add_clicked )
self.btn_exclude_file = QPushButton(icon.ADD, _('Add file'), self)
buttons_layout.addWidget( self.btn_exclude_file )
QObject.connect( self.btn_exclude_file, SIGNAL('clicked()'), self.on_btn_exclude_file_clicked )
self.btn_exclude_folder = QPushButton(icon.ADD, _('Add folder'), self)
buttons_layout.addWidget( self.btn_exclude_folder )
QObject.connect( self.btn_exclude_folder, SIGNAL('clicked()'), self.on_btn_exclude_folder_clicked )
self.btn_exclude_default = QPushButton(icon.DEFAULT_EXCLUDE, _('Add default'), self)
buttons_layout.addWidget(self.btn_exclude_default)
QObject.connect(self.btn_exclude_default, SIGNAL('clicked()'), self.on_btn_exclude_default_clicked)
self.btn_exclude_remove = QPushButton(icon.REMOVE, _('Remove'), self)
buttons_layout.addWidget( self.btn_exclude_remove )
QObject.connect( self.btn_exclude_remove, SIGNAL('clicked()'), self.on_btn_exclude_remove_clicked )
#exclude files by size
hlayout = QHBoxLayout()
layout.addLayout(hlayout)
self.cb_exclude_files_by_size = QCheckBox(_('Exclude files bigger than: '), self)
self.cb_exclude_files_by_size.setToolTip(_('Exclude files bigger than value in %(prefix)s.\n' +\
'With \'Full rsync mode\' disabled this will only affect new files\n' +\
'because for rsync this is a transfer option, not an exclude option.\n' +\
'So big files that has been backed up before will remain in snapshots\n' +\
'even if they had changed.' %{'prefix': 'MiB'}))
hlayout.addWidget(self.cb_exclude_files_by_size)
self.sb_exclude_files_by_size = QSpinBox(self)
self.sb_exclude_files_by_size.setSuffix(' MiB')
self.sb_exclude_files_by_size.setRange( 0, 100000000 )
hlayout.addWidget(self.sb_exclude_files_by_size)
hlayout.addStretch()
enabled = lambda state: self.sb_exclude_files_by_size.setEnabled(state)
enabled(False)
QObject.connect(self.cb_exclude_files_by_size, SIGNAL('stateChanged(int)'), enabled)
#TAB: Auto-remove
scrollArea = QScrollArea(self)
scrollArea.setFrameStyle(QFrame.NoFrame)
self.tabs_widget.addTab( scrollArea, _( 'Auto-remove' ) )
layoutWidget = QWidget(self)
layout = QGridLayout(layoutWidget)
#remove old snapshots
self.cb_remove_older_then = QCheckBox( _( 'Older than:' ), self )
layout.addWidget( self.cb_remove_older_then, 0, 0 )
QObject.connect( self.cb_remove_older_then, SIGNAL('stateChanged(int)'), self.update_remove_older_than )
self.edit_remove_older_then = QSpinBox(self)
self.edit_remove_older_then.setRange(1, 1000)
layout.addWidget( self.edit_remove_older_then, 0, 1 )
self.combo_remove_older_then = QComboBox( self )
layout.addWidget( self.combo_remove_older_then, 0, 2 )
self.fill_combo( self.combo_remove_older_then, self.config.REMOVE_OLD_BACKUP_UNITS )
#min free space
enabled, value, unit = self.config.get_min_free_space()
self.cb_min_free_space = QCheckBox( _( 'If free space is less than:' ), self )
layout.addWidget( self.cb_min_free_space, 1, 0 )
QObject.connect( self.cb_min_free_space, SIGNAL('stateChanged(int)'), self.update_min_free_space )
self.edit_min_free_space = QSpinBox(self)
self.edit_min_free_space.setRange(1, 1000)
layout.addWidget( self.edit_min_free_space, 1, 1 )
self.combo_min_free_space = QComboBox( self )
layout.addWidget( self.combo_min_free_space, 1, 2 )
self.fill_combo( self.combo_min_free_space, self.config.MIN_FREE_SPACE_UNITS )
#min free inodes
self.cb_min_free_inodes = QCheckBox( _('If free inodes is less than:'), self)
layout.addWidget(self.cb_min_free_inodes, 2, 0)
self.edit_min_free_inodes = QSpinBox(self)
self.edit_min_free_inodes.setSuffix(' %')
self.edit_min_free_inodes.setSingleStep( 1 )
self.edit_min_free_inodes.setRange( 0, 15 )
layout.addWidget(self.edit_min_free_inodes, 2, 1)
enabled = lambda state: self.edit_min_free_inodes.setEnabled(state)
enabled(False)
QObject.connect( self.cb_min_free_inodes, SIGNAL('stateChanged(int)'), enabled)
#smart remove
self.cb_smart_remove = QCheckBox( _( 'Smart remove' ), self )
layout.addWidget( self.cb_smart_remove, 3, 0 )
widget = QWidget( self )
widget.setContentsMargins( 25, 0, 0, 0 )
layout.addWidget( widget, 4, 0, 1, 3 )
smlayout = QGridLayout( widget )
self.cb_run_smart_remove_remote_in_background = QCheckBox(_('Run in background on remote Host.') + _(' EXPERIMENTAL!'), self)
smlayout.addWidget(self.cb_run_smart_remove_remote_in_background, 0, 0, 1, 3)
smlayout.addWidget( QLabel( _( 'Keep all snapshots for the last' ), self ), 1, 0 )
self.edit_keep_all = QSpinBox(self)
self.edit_keep_all.setRange(1, 10000)
smlayout.addWidget( self.edit_keep_all, 1, 1 )
smlayout.addWidget( QLabel( _( 'day(s)' ), self ), 1, 2 )
smlayout.addWidget( QLabel( _( 'Keep one snapshot per day for the last' ), self ), 2, 0 )
self.edit_keep_one_per_day = QSpinBox(self)
self.edit_keep_one_per_day.setRange(1, 10000)
smlayout.addWidget( self.edit_keep_one_per_day, 2, 1 )
smlayout.addWidget( QLabel( _( 'day(s)' ), self ), 2, 2 )
smlayout.addWidget( QLabel( _( 'Keep one snapshot per week for the last' ), self ), 3, 0 )
self.edit_keep_one_per_week = QSpinBox(self)
self.edit_keep_one_per_week.setRange(1, 10000)
smlayout.addWidget( self.edit_keep_one_per_week, 3, 1 )
smlayout.addWidget( QLabel( _( 'weeks(s)' ), self ), 3, 2 )
smlayout.addWidget( QLabel( _( 'Keep one snapshot per month for the last' ), self ), 4, 0 )
self.edit_keep_one_per_month = QSpinBox(self)
self.edit_keep_one_per_month.setRange(1, 1000)
smlayout.addWidget( self.edit_keep_one_per_month, 4, 1 )
smlayout.addWidget( QLabel( _( 'month(s)' ), self ), 4, 2 )
smlayout.addWidget( QLabel( _( 'Keep one snapshot per year for all years' ), self ), 5, 0, 1, 3 )
enabled = lambda state: [smlayout.itemAt(x).widget().setEnabled(state) for x in range(smlayout.count())]
enabled(False)
QObject.connect( self.cb_smart_remove, SIGNAL('stateChanged(int)'), enabled)
#don't remove named snapshots
self.cb_dont_remove_named_snapshots = QCheckBox( _( 'Don\'t remove named snapshots' ), self )
layout.addWidget( self.cb_dont_remove_named_snapshots, 5, 0, 1, 3 )
#
layout.addWidget( QWidget(self), 6, 0 )
layout.setRowStretch( 6, 2 )
scrollArea.setWidget(layoutWidget)
scrollArea.setWidgetResizable(True)
#TAB: Options
scrollArea = QScrollArea(self)
scrollArea.setFrameStyle(QFrame.NoFrame)
self.tabs_widget.addTab( scrollArea, _( 'Options' ) )
layoutWidget = QWidget(self)
layout = QVBoxLayout(layoutWidget)
self.cb_notify_enabled = QCheckBox( _( 'Enable notifications' ), self )
layout.addWidget( self.cb_notify_enabled )
self.cb_no_on_battery = QCheckBox( _( 'Disable snapshots when on battery' ), self )
if not tools.power_status_available ():
self.cb_no_on_battery.setEnabled ( False )
self.cb_no_on_battery.setToolTip ( _( 'Power status not available from system' ) )
layout.addWidget( self.cb_no_on_battery )
self.cb_use_global_flock = QCheckBox(_('Run only one snapshot at a time'))
self.cb_use_global_flock.setToolTip(_('Other snapshots will be blocked until the current snapshot is done.\n'
'This is a global option. So it will effect all profiles for this user.\n'
'But you need to activate this for all other users, too.'))
layout.addWidget(self.cb_use_global_flock)
self.cb_backup_on_restore = QCheckBox(_('Backup replaced files on restore'), self)
self.cb_backup_on_restore.setToolTip( _('Newer versions of files will be '
'renamed with trailing \'%(suffix)s\' '
'before restoring.\n'
'If you don\'t need them anymore '
'you can remove them with \'%(cmd)s\'')
%{'suffix': self.snapshots.backup_suffix(),
'cmd': 'find ./ -name "*%s" -delete' % self.snapshots.backup_suffix() })
layout.addWidget( self.cb_backup_on_restore )
self.cb_continue_on_errors = QCheckBox( _( 'Continue on errors (keep incomplete snapshots)' ), self )
layout.addWidget( self.cb_continue_on_errors )
self.cb_use_checksum = QCheckBox( _( 'Use checksum to detect changes' ), self )
layout.addWidget( self.cb_use_checksum )
self.cb_full_rsync = QCheckBox( _( 'Full rsync mode. May be faster but:' ), self )
label = QLabel( _('- snapshots are not read-only\n- destination file-system must support all Linux attributes (dates, rights, user, group ...)'), self)
label.setIndent(36)
label.setWordWrap(True)
QObject.connect( self.cb_full_rsync, SIGNAL('stateChanged(int)'), self.update_check_for_changes )
layout.addWidget( self.cb_full_rsync )
layout.addWidget( label )
self.cb_take_snapshot_regardless_of_changes = QCheckBox(_('Take a new snapshot regardless of there were changes or not.'))
layout.addWidget(self.cb_take_snapshot_regardless_of_changes)
self.cb_check_for_changes = QCheckBox( _( 'Check for changes (don\'t take a new snapshot if nothing changed)' ), self )
layout.addWidget( self.cb_check_for_changes )
#log level
hlayout = QHBoxLayout()
layout.addLayout( hlayout )
hlayout.addWidget( QLabel( _('Log Level:'), self ) )
self.combo_log_level = QComboBox( self )
hlayout.addWidget( self.combo_log_level, 1 )
self.combo_log_level.addItem( QIcon(), _('None'), 0 )
self.combo_log_level.addItem( QIcon(), _('Errors'), 1 )
self.combo_log_level.addItem( QIcon(), _('Changes & Errors'), 2 )
self.combo_log_level.addItem( QIcon(), _('All'), 3 )
#
layout.addStretch()
scrollArea.setWidget(layoutWidget)
scrollArea.setWidgetResizable(True)
#TAB: Expert Options
scrollArea = QScrollArea(self)
scrollArea.setFrameStyle(QFrame.NoFrame)
self.tabs_widget.addTab( scrollArea, _( 'Expert Options' ) )
layoutWidget = QWidget(self)
layout = QVBoxLayout(layoutWidget)
label = QLabel( _('Change these options only if you really know what you are doing !'), self )
qt4tools.set_font_bold( label )
layout.addWidget( label )
label = QLabel(_("Run 'nice':"))
layout.addWidget(label)
grid = QGridLayout()
grid.setColumnMinimumWidth(0, 20)
layout.addLayout(grid)
self.cb_run_nice_from_cron = QCheckBox(_('as cron job') + self.printDefault(self.config.DEFAULT_RUN_NICE_FROM_CRON), self)
grid.addWidget(self.cb_run_nice_from_cron, 0, 1)
self.cb_run_nice_on_remote = QCheckBox(_('on remote host') + self.printDefault(self.config.DEFAULT_RUN_NICE_ON_REMOTE), self)
grid.addWidget(self.cb_run_nice_on_remote, 1, 1)
label = QLabel(_("Run 'ionice':"))
layout.addWidget(label)
grid = QGridLayout()
grid.setColumnMinimumWidth(0, 20)
layout.addLayout(grid)
self.cb_run_ionice_from_cron = QCheckBox(_('as cron job') + self.printDefault(self.config.DEFAULT_RUN_IONICE_FROM_CRON), self)
grid.addWidget(self.cb_run_ionice_from_cron, 0, 1)
self.cb_run_ionice_from_user = QCheckBox(_('when taking a manual snapshot') + self.printDefault(self.config.DEFAULT_RUN_IONICE_FROM_USER), self )
grid.addWidget(self.cb_run_ionice_from_user, 1, 1)
self.cb_run_ionice_on_remote = QCheckBox(_('on remote host') + self.printDefault(self.config.DEFAULT_RUN_IONICE_ON_REMOTE), self)
grid.addWidget(self.cb_run_ionice_on_remote, 2, 1)
self.nocacheAvailable = tools.check_command('nocache')
label = QLabel(_("Run 'rsync' with 'nocache':"))
layout.addWidget(label)
grid = QGridLayout()
grid.setColumnMinimumWidth(0, 20)
layout.addLayout(grid)
self.cb_run_nocache_on_local = QCheckBox(_('on local machine') + self.printDefault(self.config.DEFAULT_RUN_NOCACHE_ON_LOCAL), self)
self.cb_run_nocache_on_local.setEnabled(self.nocacheAvailable)
grid.addWidget(self.cb_run_nocache_on_local, 0, 1)
self.cb_run_nocache_on_remote = QCheckBox(_('on remote host') + self.printDefault(self.config.DEFAULT_RUN_NOCACHE_ON_REMOTE), self)
grid.addWidget(self.cb_run_nocache_on_remote, 2, 1)
self.cb_redirect_stdout = QCheckBox(_('Redirect stdout to /dev/null in cronjobs.')
+ self.printDefault(self.config.DEFAULT_REDIRECT_STDOUT_IN_CRON),
self)
self.cb_redirect_stdout.setToolTip('cron will automatically send an email with attached output of cronjobs if a MTA is installed.')
layout.addWidget(self.cb_redirect_stdout)
self.cb_redirect_stderr = QCheckBox(_('Redirect stderr to /dev/null in cronjobs.')
+ self.printDefault(self.config.DEFAULT_REDIRECT_STDERR_IN_CRON),
self)
self.cb_redirect_stderr.setToolTip('cron will automatically send an email with attached errors of cronjobs if a MTA is installed.')
layout.addWidget(self.cb_redirect_stderr)
#bwlimit
hlayout = QHBoxLayout()
layout.addLayout(hlayout)
self.cb_bwlimit = QCheckBox( _( 'Limit rsync bandwidth usage: ' ), self )
hlayout.addWidget( self.cb_bwlimit )
self.sb_bwlimit = QSpinBox(self)
self.sb_bwlimit.setSuffix( _(' KB/sec') )
self.sb_bwlimit.setSingleStep( 100 )
self.sb_bwlimit.setRange( 0, 1000000 )
hlayout.addWidget(self.sb_bwlimit)
hlayout.addStretch()
enabled = lambda state: self.sb_bwlimit.setEnabled(state)
enabled(False)
QObject.connect( self.cb_bwlimit, SIGNAL('stateChanged(int)'), enabled)
self.cb_bwlimit.setToolTip(
'uses \'rsync --bwlimit=RATE\'\n'
'From \'man rsync\':\n'
'This option allows you to specify the maximum transfer rate for\n'
'the data sent over the socket, specified in units per second.\n'
'The RATE value can be suffixed with a string to indicate a size\n'
'multiplier, and may be a fractional value (e.g. "--bwlimit=1.5m").\n'
'If no suffix is specified, the value will be assumed to be in\n'
'units of 1024 bytes (as if "K" or "KiB" had been appended).\n'
'See the --max-size option for a description of all the available\n'
'suffixes. A value of zero specifies no limit.\n\n'
'For backward-compatibility reasons, the rate limit will be\n'
'rounded to the nearest KiB unit, so no rate smaller than\n'
'1024 bytes per second is possible.\n\n'
'Rsync writes data over the socket in blocks, and this option\n'
'both limits the size of the blocks that rsync writes, and tries\n'
'to keep the average transfer rate at the requested limit.\n'
'Some "burstiness" may be seen where rsync writes out a block\n'
'of data and then sleeps to bring the average rate into compliance.\n\n'
'Due to the internal buffering of data, the --progress option\n'
'may not be an accurate reflection on how fast the data is being\n'
'sent. This is because some files can show up as being rapidly\n'
'sent when the data is quickly buffered, while other can show up\n'
'as very slow when the flushing of the output buffer occurs.\n'
'This may be fixed in a future version.'
)
self.cb_preserve_acl = QCheckBox( _( 'Preserve ACL' ), self )
self.cb_preserve_acl.setToolTip(
'uses \'rsync -A\'\n'
'From \'man rsync\':\n'
'This option causes rsync to update the destination ACLs to be\n'
'the same as the source ACLs. The option also implies --perms.\n\n'
'The source and destination systems must have compatible ACL\n'
'entries for this option to work properly.\n'
'See the --fake-super option for a way to backup and restore\n'
'ACLs that are not compatible.'
)
layout.addWidget( self.cb_preserve_acl )
self.cb_preserve_xattr = QCheckBox( _( 'Preserve extended attributes (xattr)' ), self )
self.cb_preserve_xattr.setToolTip(
'uses \'rsync -X\'\n'
'From \'man rsync\':\n'
'This option causes rsync to update the destination extended\n'
'attributes to be the same as the source ones.\n\n'
'For systems that support extended-attribute namespaces, a copy\n'
'being done by a super-user copies all namespaces except\n'
'system.*. A normal user only copies the user.* namespace.\n'
'To be able to backup and restore non-user namespaces as a normal\n'
'user, see the --fake-super option.\n\n'
'Note that this option does not copy rsyncs special xattr values\n'
'(e.g. those used by --fake-super) unless you repeat the option\n'
'(e.g. -XX). This "copy all xattrs" mode cannot be used\n'
'with --fake-super.'
)
layout.addWidget( self.cb_preserve_xattr )
self.cb_copy_unsafe_links = QCheckBox( _( 'Copy unsafe links (works only with absolute links)' ), self )
self.cb_copy_unsafe_links.setToolTip(
'uses \'rsync --copy-unsafe-links\'\n'
'From \'man rsync\':\n'
'This tells rsync to copy the referent of symbolic links that\n'
'point outside the copied tree. Absolute symlinks are also\n'
'treated like ordinary files, and so are any symlinks in the\n'
'source path itself when --relative is used. This option has\n'
'no additional effect if --copy-links was also specified.\n'
)
layout.addWidget( self.cb_copy_unsafe_links )
self.cb_copy_links = QCheckBox( _( 'Copy links (dereference symbolic links)' ), self )
self.cb_copy_links.setToolTip(
'uses \'rsync --copy-links\'\n'
'From \'man rsync\':\n'
'When symlinks are encountered, the item that they point to\n'
'(the referent) is copied, rather than the symlink. In older\n'
'versions of rsync, this option also had the side-effect of\n'
'telling the receiving side to follow symlinks, such as\n'
'symlinks to directories. In a modern rsync such as this one,\n'
'you\'ll need to specify --keep-dirlinks (-K) to get this extra\n'
'behavior. The only exception is when sending files to an rsync\n'
'that is too old to understand -K -- in that case, the -L option\n'
'will still have the side-effect of -K on that older receiving rsync.'
)
layout.addWidget( self.cb_copy_links )
#additional rsync options
hlayout = QHBoxLayout()
layout.addLayout(hlayout)
self.cb_rsync_options = QCheckBox( _('Paste additional options to rsync'), self)
hlayout.addWidget(self.cb_rsync_options)
self.txt_rsync_options = QLineEdit(self)
self.txt_rsync_options.setToolTip( _('Options must be quoted e.g. --exclude-from="/path/to/my exclude file".') )
hlayout.addWidget(self.txt_rsync_options)
enabled = lambda state: self.txt_rsync_options.setEnabled(state)
enabled(False)
QObject.connect( self.cb_rsync_options, SIGNAL('stateChanged(int)'), enabled)
#ssh prefix
hlayout = QHBoxLayout()
layout.addLayout(hlayout)
self.cb_ssh_prefix = QCheckBox( _('Add prefix to SSH commands'), self)
hlayout.addWidget(self.cb_ssh_prefix)
self.txt_ssh_prefix = QLineEdit(self)
self.txt_ssh_prefix.setToolTip( _('Prefix to run before every command on remote host.\n'
'Variables need to be escaped with \$FOO.\n'
'This doesn\'t touch rsync. So to add a prefix\n'
'for rsync use "%(cb_rsync_options)s" with\n'
'%(rsync_options_value)s\n\n'
'%(default)s: %(def_value)s')
% {'cb_rsync_options': self.cb_rsync_options.text(),
'rsync_options_value': '--rsync-path="FOO=bar:\$FOO /usr/bin/rsync"',
'default': _('default'),
'def_value': self.config.DEFAULT_SSH_PREFIX})
hlayout.addWidget(self.txt_ssh_prefix)
enabled = lambda state: self.txt_ssh_prefix.setEnabled(state)
enabled(False)
QObject.connect( self.cb_ssh_prefix, SIGNAL('stateChanged(int)'), enabled)
qt4tools.equal_indent(self.cb_rsync_options, self.cb_ssh_prefix)
#
layout.addStretch()
scrollArea.setWidget(layoutWidget)
scrollArea.setWidgetResizable(True)
#buttons
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, parent = self)
btnRestore = button_box.addButton(_('Restore Config'), QDialogButtonBox.ResetRole)
QObject.connect(button_box, SIGNAL('accepted()'), self.accept)
QObject.connect(button_box, SIGNAL('rejected()'), self.reject)
QObject.connect(btnRestore, SIGNAL('clicked()'), self.restoreConfig)
self.main_layout.addWidget(button_box)
self.update_profiles()
self.on_combo_modes_changed()
#enable tabs scroll buttons again but keep dialog size
size = self.sizeHint()
self.tabs_widget.setUsesScrollButtons(scrollButtonDefault)
self.resize(size)
def modify_profile_for_full_system_backup( self ):
# verify to user that settings will change
message = _("Full system backup can only create a snapshot to be restored to the same physical disk(s) "
"with the same disk partitioning as from the source; restoring to new physical disks or the same disks "
"with different partitioning will yield a potentially broken and unusable system.\n\n"
"Full system backup will override some settings that may have been customized. Continue?")
if QMessageBox.No == messagebox.warningYesNo(self, message):
return
# configure for full system backup
# need full rsync
self.config.set_full_rsync(True)
# don't want to create a backup with any errors and give user false sense that backup was ok
self.config.set_continue_on_errors(False)
# make sure all files are backed up
self.config.set_exclude_by_size_enabled(False)
# when we restore the full system, don't want to keep old files (since we back up everything)
self.config.set_backup_on_restore(False)
# no need for checksum mode
self.config.set_use_checksum(False)
# must preserve ACLs and xattrs
self.config.set_preserve_acl(True)
self.config.set_preserve_xattr(True)
# don't want links
self.config.set_copy_links(False)
self.config.set_copy_unsafe_links(False)
# backup root
self.config.set_include( [ ("/", 0) ] )
# set UI
self.update_profiles()
def add_profile( self ):
ret_val = QInputDialog.getText(self, _('New profile'), str() )
if not ret_val[1]:
return
name = ret_val[0].strip()
if not name:
return
profile_id = self.config.add_profile( name )
if profile_id is None:
return
self.config.set_current_profile( profile_id )
self.update_profiles()
def edit_profile( self ):
ret_val = QInputDialog.getText(self, _('Rename profile'), str() )
if not ret_val[1]:
return
name = ret_val[0].strip()
if not name:
return
if not self.config.set_profile_name( name ):
return
self.update_profiles()
def remove_profile( self ):
if self.question_handler( _('Are you sure you want to delete the profile "%s" ?') % self.config.get_profile_name() ):
self.config.remove_profile()
self.update_profiles()
def update_automatic_snapshot_time( self, backup_mode ):
if backup_mode == self.config.CUSTOM_HOUR:
self.lbl_automatic_snapshots_time_custom.show()
self.txt_automatic_snapshots_time_custom.show()
else:
self.lbl_automatic_snapshots_time_custom.hide()
self.txt_automatic_snapshots_time_custom.hide()
if backup_mode == self.config.WEEK:
self.lbl_automatic_snapshots_weekday.show()
self.combo_automatic_snapshots_weekday.show()
else:
self.lbl_automatic_snapshots_weekday.hide()
self.combo_automatic_snapshots_weekday.hide()
if backup_mode == self.config.MONTH:
self.lbl_automatic_snapshots_day.show()
self.combo_automatic_snapshots_day.show()
else:
self.lbl_automatic_snapshots_day.hide()
self.combo_automatic_snapshots_day.hide()
if backup_mode >= self.config.DAY:
self.lbl_automatic_snapshots_time.show()
self.combo_automatic_snapshots_time.show()
else:
self.lbl_automatic_snapshots_time.hide()
self.combo_automatic_snapshots_time.hide()
if self.config.REPEATEDLY <= backup_mode <= self.config.UDEV:
self.lbl_automatic_snapshots_anacron_period.show()
self.sb_automatic_snapshots_anacron_period.show()
self.combo_automatic_snapshots_anacron_unit.show()
self.lbl_automatic_snapshots_time.hide()
self.combo_automatic_snapshots_time.hide()
else:
self.lbl_automatic_snapshots_anacron_period.hide()
self.sb_automatic_snapshots_anacron_period.hide()
self.combo_automatic_snapshots_anacron_unit.hide()
if backup_mode == self.config.REPEATEDLY:
self.lbl_automatic_snapshots_anacron.show()
else:
self.lbl_automatic_snapshots_anacron.hide()
if backup_mode == self.config.UDEV:
self.lbl_automatic_snapshots_udev.show()
else:
self.lbl_automatic_snapshots_udev.hide()
def current_automatic_snapshot_changed( self, index ):
backup_mode = self.combo_automatic_snapshots.itemData( index )
self.update_automatic_snapshot_time( backup_mode )
def current_profile_changed( self, index ):
if self.disable_profile_changed:
return
profile_id = str( self.combo_profiles.itemData( index ) )
if not profile_id:
return
if profile_id != self.config.get_current_profile():
self.save_profile()
self.config.set_current_profile( profile_id )
self.update_profile()
def update_check_for_changes(self):
enabled = not self.cb_full_rsync.isChecked()
self.cb_check_for_changes.setVisible(enabled)
self.cb_take_snapshot_regardless_of_changes.setVisible(not enabled)
def update_profiles( self ):
self.update_profile()
current_profile_id = self.config.get_current_profile()
self.disable_profile_changed = True
self.combo_profiles.clear()
profiles = self.config.get_profiles_sorted_by_name()
for profile_id in profiles:
self.combo_profiles.addItem( self.config.get_profile_name( profile_id ), profile_id )
if profile_id == current_profile_id:
self.combo_profiles.setCurrentIndex( self.combo_profiles.count() - 1 )
self.disable_profile_changed = False
def update_profile( self ):
if self.config.get_current_profile() == '1':
self.btn_edit_profile.setEnabled( False )
self.btn_remove_profile.setEnabled( False )
else:
self.btn_edit_profile.setEnabled( True )
self.btn_remove_profile.setEnabled( True )
self.btn_add_profile.setEnabled(self.config.is_configured('1'))
#TAB: General
#mode
self.set_combo_value( self.combo_modes, self.config.get_snapshots_mode(), t = 'str' )
#local
self.edit_snapshots_path.setText( self.config.get_snapshots_path( mode = 'local') )
#ssh
self.txt_ssh_host.setText( self.config.get_ssh_host() )
self.txt_ssh_port.setText( str(self.config.get_ssh_port()) )
self.txt_ssh_user.setText( self.config.get_ssh_user() )
self.txt_ssh_path.setText( self.config.get_snapshots_path_ssh() )
self.set_combo_value( self.combo_ssh_cipher, self.config.get_ssh_cipher(), t = 'str' )
self.txt_ssh_private_key_file.setText( self.config.get_ssh_private_key_file() )
#local_encfs
if self.mode == 'local_encfs':
self.edit_snapshots_path.setText( self.config.get_local_encfs_path() )
#password
password_1 = self.config.get_password( mode = self.mode, pw_id = 1, only_from_keyring = True )
password_2 = self.config.get_password( mode = self.mode, pw_id = 2, only_from_keyring = True )
if password_1 is None:
password_1 = ''
if password_2 is None:
password_2 = ''
self.txt_password_1.setText( password_1 )
self.txt_password_2.setText( password_2 )
self.cb_password_save.setChecked( self.keyring_supported and self.config.get_password_save( mode = self.mode ) )
self.cb_password_use_cache.setChecked( self.config.get_password_use_cache( mode = self.mode ) )
host, user, profile = self.config.get_host_user_profile()
self.txt_host.setText( host )
self.txt_user.setText( user )
self.txt_profile.setText( profile )
self.set_combo_value( self.combo_automatic_snapshots, self.config.get_automatic_backup_mode() )
self.set_combo_value( self.combo_automatic_snapshots_time, self.config.get_automatic_backup_time() )
self.set_combo_value( self.combo_automatic_snapshots_day, self.config.get_automatic_backup_day() )
self.set_combo_value( self.combo_automatic_snapshots_weekday, self.config.get_automatic_backup_weekday() )
self.txt_automatic_snapshots_time_custom.setText( self.config.get_custom_backup_time() )
self.sb_automatic_snapshots_anacron_period.setValue(self.config.get_automatic_backup_anacron_period())
self.set_combo_value(self.combo_automatic_snapshots_anacron_unit, self.config.get_automatic_backup_anacron_unit())
self.update_automatic_snapshot_time( self.config.get_automatic_backup_mode() )
#TAB: Include
self.list_include.clear()
for include in self.config.get_include():
self.add_include( include )
includeSortColumn = int(self.config.get_profile_int_value('qt4.settingsdialog.include.SortColumn', 1))
includeSortOrder = int(self.config.get_profile_int_value('qt4.settingsdialog.include.SortOrder', Qt.AscendingOrder))
self.list_include.sortItems(includeSortColumn, includeSortOrder)
#TAB: Exclude
self.list_exclude.clear()
for exclude in self.config.get_exclude():
self.add_exclude( exclude )
self.cb_exclude_files_by_size.setChecked(self.config.exclude_by_size_enabled())
self.sb_exclude_files_by_size.setValue(self.config.exclude_by_size())
excludeSortColumn = int(self.config.get_profile_int_value('qt4.settingsdialog.exclude.SortColumn', 1))
excludeSortOrder = int(self.config.get_profile_int_value('qt4.settingsdialog.exclude.SortOrder', Qt.AscendingOrder))
self.list_exclude.sortItems(excludeSortColumn, excludeSortOrder)
#TAB: Auto-remove
#remove old snapshots
enabled, value, unit = self.config.get_remove_old_snapshots()
self.cb_remove_older_then.setChecked( enabled )
self.edit_remove_older_then.setValue( value )
self.set_combo_value( self.combo_remove_older_then, unit )
#min free space
enabled, value, unit = self.config.get_min_free_space()
self.cb_min_free_space.setChecked( enabled )
self.edit_min_free_space.setValue( value )
self.set_combo_value( self.combo_min_free_space, unit )
#min free inodes
self.cb_min_free_inodes.setChecked(self.config.min_free_inodes_enabled())
self.edit_min_free_inodes.setValue(self.config.min_free_inodes())
#smart remove
smart_remove, keep_all, keep_one_per_day, keep_one_per_week, keep_one_per_month = self.config.get_smart_remove()
self.cb_smart_remove.setChecked( smart_remove )
self.edit_keep_all.setValue( keep_all )
self.edit_keep_one_per_day.setValue( keep_one_per_day )
self.edit_keep_one_per_week.setValue( keep_one_per_week )
self.edit_keep_one_per_month.setValue( keep_one_per_month )
self.cb_run_smart_remove_remote_in_background.setChecked(self.config.get_smart_remove_run_remote_in_background())
#don't remove named snapshots
self.cb_dont_remove_named_snapshots.setChecked( self.config.get_dont_remove_named_snapshots() )
#TAB: Options
self.cb_notify_enabled.setChecked( self.config.is_notify_enabled() )
self.cb_no_on_battery.setChecked( self.config.is_no_on_battery_enabled() )
self.cb_use_global_flock.setChecked(self.config.use_global_flock())
self.cb_backup_on_restore.setChecked( self.config.is_backup_on_restore_enabled() )
self.cb_continue_on_errors.setChecked( self.config.continue_on_errors() )
self.cb_use_checksum.setChecked( self.config.use_checksum() )
self.cb_full_rsync.setChecked( self.config.full_rsync() )
self.update_check_for_changes()
self.cb_take_snapshot_regardless_of_changes.setChecked(self.config.take_snapshot_regardless_of_changes())
self.cb_check_for_changes.setChecked( self.config.check_for_changes() )
self.set_combo_value( self.combo_log_level, self.config.log_level() )
#TAB: Expert Options
self.cb_run_nice_from_cron.setChecked( self.config.is_run_nice_from_cron_enabled() )
self.cb_run_ionice_from_cron.setChecked( self.config.is_run_ionice_from_cron_enabled() )
self.cb_run_ionice_from_user.setChecked( self.config.is_run_ionice_from_user_enabled() )
self.cb_run_nice_on_remote.setChecked(self.config.is_run_nice_on_remote_enabled())
self.cb_run_ionice_on_remote.setChecked(self.config.is_run_ionice_on_remote_enabled())
self.cb_run_nocache_on_local.setChecked(self.config.is_run_nocache_on_local_enabled() and self.nocacheAvailable)
self.cb_run_nocache_on_remote.setChecked(self.config.is_run_nocache_on_remote_enabled())
self.cb_redirect_stdout.setChecked(self.config.redirect_stdout_in_cron())
self.cb_redirect_stderr.setChecked(self.config.redirect_stderr_in_cron())
self.cb_bwlimit.setChecked( self.config.bwlimit_enabled() )
self.sb_bwlimit.setValue( self.config.bwlimit() )
self.cb_preserve_acl.setChecked( self.config.preserve_acl() )
self.cb_preserve_xattr.setChecked( self.config.preserve_xattr() )
self.cb_copy_unsafe_links.setChecked( self.config.copy_unsafe_links() )
self.cb_copy_links.setChecked( self.config.copy_links() )
self.cb_rsync_options.setChecked(self.config.rsync_options_enabled() )
self.txt_rsync_options.setText(self.config.rsync_options() )
self.cb_ssh_prefix.setChecked(self.config.ssh_prefix_enabled() )
self.txt_ssh_prefix.setText(self.config.ssh_prefix() )
#update
self.update_remove_older_than()
self.update_min_free_space()
def save_profile( self ):
if self.combo_automatic_snapshots.itemData( self.combo_automatic_snapshots.currentIndex() ) == self.config.CUSTOM_HOUR:
if not tools.check_cron_pattern(self.txt_automatic_snapshots_time_custom.text() ):
self.error_handler( _('Custom Hours can only be a comma seperate list of hours (e.g. 8,12,18,23) or */3 for periodic backups every 3 hours') )
return False
#mode
mode = str( self.combo_modes.itemData( self.combo_modes.currentIndex() ) )
self.config.set_snapshots_mode( mode )
mount_kwargs = {}
#password
password_1 = self.txt_password_1.text()
password_2 = self.txt_password_2.text()
if mode in ('ssh', 'local_encfs'):
mount_kwargs = {'password': password_1
}
if mode == 'ssh_encfs':
mount_kwargs = {'ssh_password': password_1,
'encfs_password': password_2,
}
#snapshots path
self.config.set_host_user_profile(
self.txt_host.text(),
self.txt_user.text(),
self.txt_profile.text() )
#save ssh
self.config.set_ssh_host(self.txt_ssh_host.text())
self.config.set_ssh_port(self.txt_ssh_port.text())
self.config.set_ssh_user(self.txt_ssh_user.text())
self.config.set_snapshots_path_ssh(self.txt_ssh_path.text())
self.config.set_ssh_cipher(self.combo_ssh_cipher.itemData( self.combo_ssh_cipher.currentIndex() ))
self.config.set_ssh_private_key_file(self.txt_ssh_private_key_file.text())
#save local_encfs
self.config.set_local_encfs_path(self.edit_snapshots_path.text())
#include list
self.config.set_profile_int_value('qt4.settingsdialog.include.SortColumn',
self.list_include_header.sortIndicatorSection())
self.config.set_profile_int_value('qt4.settingsdialog.include.SortOrder',
self.list_include_header.sortIndicatorOrder())
self.list_include.sortItems(1, Qt.AscendingOrder)
include_list = []
for index in range( self.list_include.topLevelItemCount() ):
item = self.list_include.topLevelItem( index )
include_list.append( ( item.text(0), item.data( 0, Qt.UserRole ) ) )
self.config.set_include( include_list )
#exclude patterns
self.config.set_profile_int_value('qt4.settingsdialog.exclude.SortColumn',
self.list_exclude_header.sortIndicatorSection())
self.config.set_profile_int_value('qt4.settingsdialog.exclude.SortOrder',
self.list_exclude_header.sortIndicatorOrder())
self.list_exclude.sortItems(1, Qt.AscendingOrder)
exclude_list = []
for index in range( self.list_exclude.topLevelItemCount() ):
item = self.list_exclude.topLevelItem( index )
exclude_list.append( item.text(0) )
self.config.set_exclude( exclude_list )
self.config.set_exclude_by_size_enabled(self.cb_exclude_files_by_size.isChecked())
self.config.set_exclude_by_size(self.sb_exclude_files_by_size.value())
#schedule
self.config.set_automatic_backup_mode( self.combo_automatic_snapshots.itemData( self.combo_automatic_snapshots.currentIndex() ) )
self.config.set_automatic_backup_time( self.combo_automatic_snapshots_time.itemData( self.combo_automatic_snapshots_time.currentIndex() ) )
self.config.set_automatic_backup_weekday( self.combo_automatic_snapshots_weekday.itemData( self.combo_automatic_snapshots_weekday.currentIndex() ) )
self.config.set_automatic_backup_day( self.combo_automatic_snapshots_day.itemData( self.combo_automatic_snapshots_day.currentIndex() ) )
self.config.set_custom_backup_time( self.txt_automatic_snapshots_time_custom.text() )
self.config.set_automatic_backup_anacron_period(self.sb_automatic_snapshots_anacron_period.value())
self.config.set_automatic_backup_anacron_unit(self.combo_automatic_snapshots_anacron_unit.itemData(self.combo_automatic_snapshots_anacron_unit.currentIndex() ))
#auto-remove
self.config.set_remove_old_snapshots(
self.cb_remove_older_then.isChecked(),
self.edit_remove_older_then.value(),
self.combo_remove_older_then.itemData( self.combo_remove_older_then.currentIndex() ) )
self.config.set_min_free_space(
self.cb_min_free_space.isChecked(),
self.edit_min_free_space.value(),
self.combo_min_free_space.itemData( self.combo_min_free_space.currentIndex() ) )
self.config.set_min_free_inodes(
self.cb_min_free_inodes.isChecked(),
self.edit_min_free_inodes.value() )
self.config.set_dont_remove_named_snapshots( self.cb_dont_remove_named_snapshots.isChecked() )
self.config.set_smart_remove(
self.cb_smart_remove.isChecked(),
self.edit_keep_all.value(),
self.edit_keep_one_per_day.value(),
self.edit_keep_one_per_week.value(),
self.edit_keep_one_per_month.value() )
self.config.set_smart_remove_run_remote_in_background(self.cb_run_smart_remove_remote_in_background.isChecked())
#options
self.config.set_notify_enabled( self.cb_notify_enabled.isChecked() )
self.config.set_no_on_battery_enabled( self.cb_no_on_battery.isChecked() )
self.config.set_use_global_flock(self.cb_use_global_flock.isChecked())
self.config.set_backup_on_restore( self.cb_backup_on_restore.isChecked() )
self.config.set_continue_on_errors( self.cb_continue_on_errors.isChecked() )
self.config.set_use_checksum( self.cb_use_checksum.isChecked() )
self.config.set_full_rsync( self.cb_full_rsync.isChecked() )
self.config.set_take_snapshot_regardless_of_changes(self.cb_take_snapshot_regardless_of_changes.isChecked())
self.config.set_check_for_changes( self.cb_check_for_changes.isChecked() )
self.config.set_log_level( self.combo_log_level.itemData( self.combo_log_level.currentIndex() ) )
#expert options
self.config.set_run_nice_from_cron_enabled( self.cb_run_nice_from_cron.isChecked() )
self.config.set_run_ionice_from_cron_enabled( self.cb_run_ionice_from_cron.isChecked() )
self.config.set_run_ionice_from_user_enabled( self.cb_run_ionice_from_user.isChecked() )
self.config.set_run_nice_on_remote_enabled(self.cb_run_nice_on_remote.isChecked())
self.config.set_run_ionice_on_remote_enabled(self.cb_run_ionice_on_remote.isChecked())
self.config.set_run_nocache_on_local_enabled(self.cb_run_nocache_on_local.isChecked())
self.config.set_run_nocache_on_remote_enabled(self.cb_run_nocache_on_remote.isChecked())
self.config.set_redirect_stdout_in_cron(self.cb_redirect_stdout.isChecked())
self.config.set_redirect_stderr_in_cron(self.cb_redirect_stderr.isChecked())
self.config.set_bwlimit_enabled( self.cb_bwlimit.isChecked() )
self.config.set_bwlimit( self.sb_bwlimit.value() )
self.config.set_preserve_acl( self.cb_preserve_acl.isChecked() )
self.config.set_preserve_xattr( self.cb_preserve_xattr.isChecked() )
self.config.set_copy_unsafe_links( self.cb_copy_unsafe_links.isChecked() )
self.config.set_copy_links( self.cb_copy_links.isChecked() )
self.config.set_rsync_options_enabled(self.cb_rsync_options.isChecked() )
self.config.set_rsync_options(self.txt_rsync_options.text() )
self.config.set_ssh_prefix_enabled(self.cb_ssh_prefix.isChecked() )
self.config.set_ssh_prefix(self.txt_ssh_prefix.text() )
if not self.config.SNAPSHOT_MODES[mode][0] is None:
#pre_mount_check
mnt = mount.Mount(cfg = self.config, tmp_mount = True, parent = self)
try:
mnt.pre_mount_check(mode = mode, first_run = True, **mount_kwargs)
except MountException as ex:
self.error_handler(str(ex))
return False
#okay, lets try to mount
try:
hash_id = mnt.mount(mode = mode, check = False, **mount_kwargs)
except MountException as ex:
self.error_handler(str(ex))
return False
#save password
self.config.set_password_save(self.cb_password_save.isChecked(), mode = mode)
self.config.set_password_use_cache(self.cb_password_use_cache.isChecked(), mode = mode)
self.config.set_password(password_1, mode = mode)
self.config.set_password(password_2, mode = mode, pw_id = 2)
#save snaphots_path
if self.config.SNAPSHOT_MODES[mode][0] is None:
snapshots_path = self.edit_snapshots_path.text()
else:
snapshots_path = self.config.get_snapshots_path(mode = mode, tmp_mount = True)
ret = self.config.set_snapshots_path( snapshots_path, mode = mode )
if not ret:
return ret
#umount
if not self.config.SNAPSHOT_MODES[mode][0] is None:
try:
mnt.umount(hash_id = hash_id)
except MountException as ex:
self.error_handler(str(ex))
return False
return True
def error_handler( self, message ):
messagebox.critical( self, message )
def question_handler( self, message ):
return QMessageBox.Yes == messagebox.warningYesNo( self, message )
def exec_( self ):
self.config.set_question_handler( self.question_handler )
self.config.set_error_handler( self.error_handler )
ret_val = super(SettingsDialog, self).exec_()
self.config.clear_handlers()
if ret_val != QDialog.Accepted:
self.config.dict = self.config_copy_dict
self.config.set_current_profile( self.current_profile_org )
return ret_val
def update_snapshots_location( self ):
'''Update snapshot location dialog'''
self.config.set_question_handler( self.question_handler )
self.config.set_error_handler( self.error_handler )
self.snapshots.update_snapshots_location()
def update_remove_older_than( self ):
enabled = self.cb_remove_older_then.isChecked()
self.edit_remove_older_then.setEnabled( enabled )
self.combo_remove_older_then.setEnabled( enabled )
def update_min_free_space( self ):
enabled = self.cb_min_free_space.isChecked()
self.edit_min_free_space.setEnabled( enabled )
self.combo_min_free_space.setEnabled( enabled )
def add_include( self, data ):
item = QTreeWidgetItem()
if data[1] == 0:
item.setIcon(0, self.icon.FOLDER)
else:
item.setIcon(0, self.icon.FILE)
item.setText( 0, data[0] )
item.setData( 0, Qt.UserRole, data[1] )
self.list_include_count += 1
item.setText(1, str(self.list_include_count).zfill(6))
item.setData(1, Qt.UserRole, self.list_include_count )
self.list_include.addTopLevelItem( item )
if self.list_include.currentItem() is None:
self.list_include.setCurrentItem( item )
return item
def add_exclude( self, pattern ):
item = QTreeWidgetItem()
item.setText(0, pattern)
item.setData(0, Qt.UserRole, pattern )
self.list_exclude_count += 1
item.setText(1, str(self.list_exclude_count).zfill(6))
item.setData(1, Qt.UserRole, self.list_exclude_count )
self.formatExcludeItem(item)
self.list_exclude.addTopLevelItem(item)
if self.list_exclude.currentItem() is None:
self.list_exclude.setCurrentItem( item )
return item
def fill_combo( self, combo, d ):
keys = list(d.keys())
keys.sort()
for key in keys:
combo.addItem( QIcon(), d[ key ], key )
def set_combo_value( self, combo, value, t = 'int' ):
for i in range( combo.count() ):
if t == 'int' and value == combo.itemData( i ):
combo.setCurrentIndex( i )
break
if t == 'str' and value == combo.itemData( i ):
combo.setCurrentIndex( i )
break
def validate( self ):
if not self.save_profile():
return False
if not self.config.check_config():
return False
if not self.config.setup_cron():
return False
return self.config.save()
def on_btn_exclude_remove_clicked ( self ):
for item in self.list_exclude.selectedItems():
index = self.list_exclude.indexOfTopLevelItem( item )
if index < 0:
continue
self.list_exclude.takeTopLevelItem( index )
if self.list_exclude.topLevelItemCount() > 0:
self.list_exclude.setCurrentItem( self.list_exclude.topLevelItem(0) )
def add_exclude_( self, pattern ):
if not pattern:
return
for index in range( self.list_exclude.topLevelItemCount() ):
item = self.list_exclude.topLevelItem( index )
if pattern == item.text(0):
return
self.add_exclude( pattern )
def on_btn_exclude_add_clicked( self ):
dlg = QInputDialog(self)
dlg.setInputMode(QInputDialog.TextInput)
dlg.setWindowTitle(_('Exclude pattern'))
dlg.setLabelText('')
dlg.resize(400, 0)
if not dlg.exec():
return
pattern = dlg.textValue().strip()
if not pattern:
return
self.add_exclude_( pattern )
def on_btn_exclude_file_clicked( self ):
for path in qt4tools.getOpenFileNames(self, _('Exclude file')):
self.add_exclude_( path )
def on_btn_exclude_folder_clicked( self ):
for path in qt4tools.getExistingDirectories(self, _('Exclude folder')) :
self.add_exclude_( path )
def on_btn_exclude_default_clicked(self):
for path in self.config.DEFAULT_EXCLUDE:
self.add_exclude_(path)
def on_btn_include_remove_clicked ( self ):
for item in self.list_include.selectedItems():
index = self.list_include.indexOfTopLevelItem( item )
if index < 0:
continue
self.list_include.takeTopLevelItem( index )
if self.list_include.topLevelItemCount() > 0:
self.list_include.setCurrentItem( self.list_include.topLevelItem(0) )
def on_btn_include_file_add_clicked( self ):
for path in qt4tools.getOpenFileNames(self, _('Include file')):
if not path:
continue
if os.path.islink(path) \
and not (self.cb_copy_unsafe_links.isChecked() \
or self.cb_copy_links.isChecked()):
if self.question_handler( \
_('"%s" is a symlink. The linked target will not be backed up until you include it, too.\nWould you like to include the symlinks target instead?') % path ):
path = os.path.realpath(path)
path = self.config.prepare_path( path )
for index in range( self.list_include.topLevelItemCount() ):
if path == self.list_include.topLevelItem( index ).text( 0 ):
continue
self.add_include( ( path, 1 ) )
def on_btn_include_add_clicked( self ):
for path in qt4tools.getExistingDirectories(self, _('Include folder')):
if not path:
continue
if os.path.islink(path) \
and not (self.cb_copy_unsafe_links.isChecked() \
or self.cb_copy_links.isChecked()):
if self.question_handler( \
_('"%s" is a symlink. The linked target will not be backed up until you include it, too.\nWould you like to include the symlinks target instead?') % path ):
path = os.path.realpath(path)
path = self.config.prepare_path( path )
for index in range( self.list_include.topLevelItemCount() ):
if path == self.list_include.topLevelItem( index ).text( 0 ):
continue
self.add_include( ( path, 0 ) )
def on_btn_snapshots_path_clicked( self ):
old_path = self.edit_snapshots_path.text()
path = str(qt4tools.getExistingDirectory(self,
_('Where to save snapshots'),
self.edit_snapshots_path.text() ) )
if path:
if old_path and old_path != path:
if not self.question_handler( _('Are you sure you want to change snapshots folder ?') ):
return
self.edit_snapshots_path.setText( self.config.prepare_path( path ) )
def on_btn_ssh_private_key_file_clicked( self ):
old_file = self.txt_ssh_private_key_file.text()
if old_file:
start_dir = self.txt_ssh_private_key_file.text()
else:
start_dir = self.config.get_ssh_private_key_folder()
f = qt4tools.getOpenFileName(self, _('SSH private key'), start_dir)
if f:
self.txt_ssh_private_key_file.setText(f)
def on_combo_modes_changed(self, *params):
if not params:
index = self.combo_modes.currentIndex()
else:
index = params[0]
active_mode = str( self.combo_modes.itemData( index ) )
if active_mode != self.mode:
for mode in list(self.config.SNAPSHOT_MODES.keys()):
getattr(self, 'mode_%s' % mode).hide()
for mode in list(self.config.SNAPSHOT_MODES.keys()):
if active_mode == mode:
getattr(self, 'mode_%s' % mode).show()
self.mode = active_mode
if self.config.mode_need_password(active_mode):
self.lbl_password_1.setText( self.config.SNAPSHOT_MODES[active_mode][2] + ':' )
self.frame_password_1.show()
if self.config.mode_need_password(active_mode, 2):
self.lbl_password_2.setText( self.config.SNAPSHOT_MODES[active_mode][3] + ':' )
self.lbl_password_2.show()
self.txt_password_2.show()
qt4tools.equal_indent(self.lbl_password_1, self.lbl_password_2)
else:
self.lbl_password_2.hide()
self.txt_password_2.hide()
qt4tools.equal_indent(self.lbl_password_1)
else:
self.frame_password_1.hide()
if active_mode == 'ssh_encfs':
self.lbl_ssh_encfs_exclude_warning.show()
else:
self.lbl_ssh_encfs_exclude_warning.hide()
self.updateExcludeItems()
enabled = active_mode in ('ssh', 'ssh_encfs')
self.cb_run_nice_on_remote.setEnabled(enabled)
self.cb_run_ionice_on_remote.setEnabled(enabled)
self.cb_bwlimit.setEnabled(enabled)
self.sb_bwlimit.setEnabled(enabled and self.cb_bwlimit.isChecked())
self.cb_run_nocache_on_remote.setEnabled(enabled)
self.cb_run_smart_remove_remote_in_background.setHidden(not enabled)
self.cb_ssh_prefix.setHidden(not enabled)
self.txt_ssh_prefix.setHidden(not enabled)
self.encfsWarning.setHidden(active_mode not in ('local_encfs', 'ssh_encfs'))
def on_full_path_changed(self, dummy):
if self.mode in ('ssh', 'ssh_encfs'):
path = self.txt_ssh_path.text()
else:
path = self.edit_snapshots_path.text()
self.lbl_full_path.setText(
_('Full snapshot path: ') +
os.path.join(
path,
'backintime',
self.txt_host.text(),
self.txt_user.text(),
self.txt_profile.text()
))
def updateExcludeItems(self):
for index in range(self.list_exclude.topLevelItemCount()):
item = self.list_exclude.topLevelItem(index)
self.formatExcludeItem(item)
def formatExcludeItem(self, item):
if self.mode == 'ssh_encfs' and tools.patternHasNotEncryptableWildcard(item.text(0)):
item.setIcon(0, self.icon.INVALID_EXCLUDE)
item.setBackground(0, QBrush(Qt.lightGray))
elif item.text(0) in self.config.DEFAULT_EXCLUDE:
item.setIcon(0, self.icon.DEFAULT_EXCLUDE)
item.setBackground(0, QBrush())
else:
item.setIcon(0, self.icon.EXCLUDE)
item.setBackground(0, QBrush())
def customSortOrder(self, header, loop, newColumn, newOrder):
if newColumn == 0 and newOrder == Qt.AscendingOrder:
if loop:
newColumn, newOrder = 1, Qt.AscendingOrder
header.setSortIndicator(newColumn, newOrder)
loop = False
else:
loop = True
header.model().sort(newColumn, newOrder)
return loop
def includeCustomSortOrder(self, *args):
self.list_include_sort_loop = self.customSortOrder(self.list_include_header,
self.list_include_sort_loop,
*args)
def excludeCustomSortOrder(self, *args):
self.list_exclude_sort_loop = self.customSortOrder(self.list_exclude_header,
self.list_exclude_sort_loop,
*args)
def printDefault(self, value):
if value:
value_ = _('enabled')
else:
value_ = _('disabled')
return ' (%s: %s)' %(_('default'), value_)
def restoreConfig(self, *args):
RestoreConfigDialog(self).exec_()
self.update_profiles()
def accept( self ):
if self.validate():
super(SettingsDialog, self).accept()
class RestoreConfigDialog(QDialog):
"""Show a dialog that will help to restore BITs configuration.
User can select a config from previous snapshots.
"""
def __init__(self, parent):
super(RestoreConfigDialog, self).__init__(parent)
self.parent = parent
self.config = parent.config
self.snapshots = parent.snapshots
import icon
self.icon = icon
self.setWindowIcon(icon.SETTINGS_DIALOG)
self.setWindowTitle(_( 'Restore Settings' ))
layout = QVBoxLayout(self)
#show a hint on how the snapshot path will look like.
samplePath = os.path.join( 'backintime',
self.config.get_host(),
self.config.get_user(), '1',
self.snapshots.get_snapshot_id(datetime.datetime.now())
)
#inform user to join group fuse if he hasn't already.
#If there is no group fuse than it is most likly not nessesary.
addFuse = ''
try:
user = self.config.get_user()
fuse_grp_members = grp.getgrnam('fuse')[3]
if not user in fuse_grp_members:
addFuse = _(' and add your user to group \'fuse\'')
except KeyError:
pass
label = QLabel(_('Please navigate to the snapshot from which you want '
'to restore %(appName)s\'s configuration. The path '
'may look like: \n%(samplePath)s\n\n'
'If your snapshots are on a remote drive or if they are '
'encrypted you need to manually mount them first. '
'If you use Mode SSH you also may need to set up public key '
'login to the remote host%(addFuse)s.\n'
'Take a look at \'man backintime\'.')
% {'appName': self.config.APP_NAME, 'samplePath': samplePath,
'addFuse': addFuse}, self)
label.setWordWrap(True)
layout.addWidget(label)
#treeView
self.treeView = qt4tools.MyTreeView(self)
self.treeViewModel = QFileSystemModel(self)
self.treeViewModel.setRootPath(QDir().rootPath())
self.treeViewModel.setReadOnly(True)
self.treeViewModel.setFilter(QDir.AllDirs |
QDir.NoDotAndDotDot | QDir.Hidden)
self.treeViewFilterProxy = QSortFilterProxyModel(self)
self.treeViewFilterProxy.setDynamicSortFilter(True)
self.treeViewFilterProxy.setSourceModel(self.treeViewModel)
self.treeViewFilterProxy.setFilterRegExp(r'^[^\.]')
self.treeView.setModel(self.treeViewFilterProxy)
for col in range(self.treeView.header().count()):
self.treeView.setColumnHidden(col, col != 0)
self.treeView.header().hide()
#expand users home
self.expandAll(os.path.expanduser('~'))
layout.addWidget(self.treeView)
#context menu
self.treeView.setContextMenuPolicy(Qt.CustomContextMenu)
self.connect(self.treeView, SIGNAL('customContextMenuRequested(const QPoint&)'), self.onContextMenu)
self.contextMenu = QMenu(self)
self.btnShowHidden = self.contextMenu.addAction(icon.SHOW_HIDDEN, _('Show hidden files'))
self.btnShowHidden.setCheckable(True)
self.connect(self.btnShowHidden, SIGNAL('toggled(bool)'), self.onBtnShowHidden)
#colors
self.colorRed = QPalette()
self.colorRed.setColor(QPalette.WindowText, QColor(205, 0, 0))
self.colorGreen = QPalette()
self.colorGreen.setColor(QPalette.WindowText, QColor(0, 160, 0))
#wait indicator which will show that the scan for snapshots is still running
self.wait = QProgressBar(self)
self.wait.setMinimum(0)
self.wait.setMaximum(0)
self.wait.setMaximumHeight(7)
layout.addWidget(self.wait)
#show where a snapshot with config was found
self.lblFound = QLabel(_('No config found'), self)
self.lblFound.setWordWrap(True)
self.lblFound.setPalette(self.colorRed)
layout.addWidget(self.lblFound)
#show profiles inside the config
self.widgetProfiles = QWidget(self)
self.widgetProfiles.setContentsMargins(0, 0, 0, 0)
self.widgetProfiles.hide()
self.gridProfiles = QGridLayout()
self.gridProfiles.setContentsMargins(0, 0, 0, 0)
self.gridProfiles.setHorizontalSpacing(20)
self.widgetProfiles.setLayout(self.gridProfiles)
layout.addWidget(self.widgetProfiles)
self.restoreConfig = None
self.scan = ScanFileSystem(self)
self.treeView.myCurrentIndexChanged.connect(self.indexChanged)
self.connect(self.scan, SIGNAL('foundConfig'), self.scanFound)
self.connect(self.scan, SIGNAL('finished()'), self.scanFinished)
button_box = QDialogButtonBox(self)
self.restoreButton = button_box.addButton(_('Restore'), QDialogButtonBox.AcceptRole)
self.restoreButton.setEnabled(False)
button_box.addButton(QDialogButtonBox.Cancel)
QObject.connect(button_box, SIGNAL('accepted()'), self.accept)
QObject.connect(button_box, SIGNAL('rejected()'), self.reject)
layout.addWidget(button_box)
self.scan.start()
self.resize(600, 700)
def pathFromIndex(self, index):
"""return a path string for a given treeView index
"""
sourceIndex = self.treeViewFilterProxy.mapToSource(index)
return str(self.treeViewModel.filePath(sourceIndex))
def indexFromPath(self, path):
"""return the index for path which can be used in treeView
"""
indexSource = self.treeViewModel.index(path)
return self.treeViewFilterProxy.mapFromSource(indexSource)
def indexChanged(self, current, previous):
"""called everytime a new item is choosen in treeView.
If there was a config found inside the selected folder, show
available informations about the config.
"""
cfg = self.searchConfig(self.pathFromIndex(current))
if cfg:
self.expandAll(os.path.dirname(os.path.dirname(cfg._LOCAL_CONFIG_PATH)))
self.lblFound.setText(cfg._LOCAL_CONFIG_PATH)
self.lblFound.setPalette(self.colorGreen)
self.showProfile(cfg)
self.restoreConfig = cfg
else:
self.lblFound.setText(_('No config found'))
self.lblFound.setPalette(self.colorRed)
self.widgetProfiles.hide()
self.restoreConfig = None
self.restoreButton.setEnabled(bool(cfg))
def searchConfig(self, path):
"""try to find config in couple possible subfolders
"""
snapshotPath = os.path.join('backintime',
self.config.get_host(),
self.config.get_user())
tryPaths = ['', '..', 'last_snapshot']
tryPaths.extend([os.path.join(snapshotPath, str(i), 'last_snapshot') for i in range(10)])
for p in tryPaths:
cfgPath = os.path.join(path, p, 'config')
if os.path.exists(cfgPath):
try:
cfg = config.Config(cfgPath)
if cfg.is_configured():
return cfg
except:
pass
return
def expandAll(self, path):
"""expand all folders from filesystem root to given path
"""
paths = [path, ]
while len(path) > 1:
path = os.path.dirname(path)
paths.append(path)
paths.append('/')
paths.reverse()
[self.treeView.expand(self.indexFromPath(p)) for p in paths]
def showProfile(self, cfg):
"""show information about the profiles inside cfg
"""
child = self.gridProfiles.takeAt(0)
while child:
child.widget().deleteLater()
child = self.gridProfiles.takeAt(0)
for row, profileId in enumerate(cfg.get_profiles()):
for col, txt in enumerate( (_('Profile:') + ' ' + str(profileId),
cfg.get_profile_name(profileId),
_('Mode:') + ' ' + cfg.SNAPSHOT_MODES[cfg.get_snapshots_mode(profileId)][1]
) ):
self.gridProfiles.addWidget(QLabel(txt, self), row, col)
self.gridProfiles.setColumnStretch(col, 1)
self.widgetProfiles.show()
def scanFound(self, path):
"""scan hit a config. Expand the snapshot folder.
"""
self.expandAll(os.path.dirname(path))
def scanFinished(self):
"""scan is done. Delete the wait indicator
"""
self.wait.deleteLater()
def onContextMenu(self, point):
self.contextMenu.exec_(self.treeView.mapToGlobal(point))
def onBtnShowHidden(self, checked):
if checked:
self.treeViewFilterProxy.setFilterRegExp(r'')
else:
self.treeViewFilterProxy.setFilterRegExp(r'^[^\.]')
def accept(self):
"""handle over the dict from the selected config. The dict contains
all settings from the config.
"""
if self.restoreConfig:
self.config.dict = self.restoreConfig.dict
super(RestoreConfigDialog, self).accept()
def exec_(self):
"""stop the scan thread if it is still running after dialog was closed.
"""
ret = super(RestoreConfigDialog, self).exec_()
self.scan.stop()
return ret
class ScanFileSystem(QThread):
CONFIG = 'config'
BACKUP = 'backup'
BACKINTIME = 'backintime'
def __init__(self, parent):
super(ScanFileSystem, self).__init__(parent)
self.stopper = False
def stop(self):
"""prepair stop and wait for finish.
"""
self.stopper = True
return self.wait()
def run(self):
"""search in order of hopefully fastest way to find the snapshots.
1. /home/USER 2. /media 3. /mnt and at last filesystem root.
Already searched paths will be excluded.
"""
searchOrder = [os.path.expanduser('~'), '/media', '/mnt', '/']
for scan in searchOrder:
exclude = searchOrder[:]
exclude.remove(scan)
for path in self.scanPath(scan, exclude):
self.emit(SIGNAL('foundConfig'), path)
def scanPath(self, path, excludes = ()):
"""walk through all folders and try to find 'config' file.
If found make sure it is nested in backintime/FOO/BAR/1/2345/config and
return its path.
Exclude all paths from excludes and also all backintime/FOO/BAR/1/2345/backup
"""
for root, dirs, files in os.walk(path, topdown = True):
if self.stopper:
return
for exclude in excludes:
exDir, exBase = os.path.split(exclude)
if root == exDir:
if exBase in dirs:
del dirs[dirs.index(exBase)]
if self.CONFIG in files:
rootdirs = root.split(os.sep)
if len(rootdirs) > 4 and rootdirs[-5].startswith(self.BACKINTIME):
if self.BACKUP in dirs:
del dirs[dirs.index(self.BACKUP)]
yield root
def debug_trace():
'''Set a tracepoint in the Python debugger that works with Qt'''
from pdb import set_trace
pyqtRemoveInputHook()
set_trace()
|