Compare commits
784 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e3c2da79c | |||
| 37dc94bc79 | |||
| fc274b43f0 | |||
| 9ab12e4312 | |||
| a5ff35c198 | |||
| 458e7776c5 | |||
| fa5fa1c11b | |||
| f8bc67be8d | |||
| 17586d49ac | |||
| 2f75c9aa9e | |||
|
60650ccfc7 |
|||
| c12c47cace | |||
| d6aaab8a09 | |||
| 128ebf04ce | |||
| b1941bcce9 | |||
| 7b3b28616d | |||
| f3910f49ca | |||
| 59e1cac92c | |||
| b1f0287fdb | |||
| 99c35d4077 | |||
| 07b9ff61f2 | |||
| f573c1810a | |||
| 1d37b14356 | |||
| 6c617eddd5 | |||
| e14ebee4e0 | |||
| a897ffd514 | |||
| a472735616 | |||
| b3fec03cf4 | |||
| 89dccc25c3 | |||
| 3846155d62 | |||
| 386979ebb4 | |||
| 07222cd984 | |||
| cf4c6c274d | |||
| 340bd72176 | |||
| 1a1bb71af1 | |||
| ae45dfe63a | |||
| d6ac7a9192 | |||
| d959fdbf8d | |||
| 81739791e0 | |||
| 4cdff74e9b | |||
| 11e830bb1d | |||
| cba00a9c4e | |||
| f2198de151 | |||
|
0c439c0c02 |
|||
| f11a9bb4aa | |||
| ee6f390910 | |||
|
9a5117db14 |
|||
| 9585c8f908 | |||
| 3495484ddd | |||
| 67ab2acb82 | |||
| c085bacccf | |||
| 896401088e | |||
| ef3dda9213 | |||
| c9f5d9b048 | |||
| ccbd0b608b | |||
| a7cc2ea803 | |||
| 9ec75ccf3f | |||
| 7c890be76d | |||
| 39e5aac479 | |||
| e25f2c4e6c | |||
| 7ad8f9ac6f | |||
| 2add3ff7ad | |||
| 0602ca1862 | |||
| e973802fc1 | |||
| 2bdf6dfd70 | |||
| f894c49540 | |||
| 7900e5ea53 | |||
| 5587f48bda | |||
| de3ee07566 | |||
| fe39453598 | |||
| 9c75063c05 | |||
| 5cf2ef1732 | |||
| f35e6ea7ad | |||
| 90595e9c18 | |||
| 032d4adee3 | |||
| 4444219e17 | |||
| 56fd78089d | |||
| 86dbc00cbe | |||
| c644270599 | |||
| 1676a98c51 | |||
| 358ed53da0 | |||
| 90925c9428 | |||
| cd192a6909 | |||
| 7185146481 | |||
| c15e6c5fe5 | |||
| 79c2b9df06 | |||
| acd6772148 | |||
| cd91dbd4f7 | |||
| 8fc4efff88 | |||
| 4bf3e906a1 | |||
| 0ca43ef67a | |||
| 603e055a39 | |||
| 75c04611dc | |||
| 881dc9b01e | |||
| 8c72e909a7 | |||
| 74ac148747 | |||
| be7887c071 | |||
| da459d95b8 | |||
| b3aa6af859 | |||
| b816af1b13 | |||
| 276aeb9875 | |||
| de94001508 | |||
| 7cfab3620b | |||
| 6c136ebbf1 | |||
| eaa5eb4174 | |||
| acc2a39454 | |||
| a10c7a8496 | |||
| de82919e39 | |||
| 1ba56d5262 | |||
| 1c825b5d84 | |||
| d6d66de251 | |||
| 76d79f0331 | |||
| dc43c38e29 | |||
| 7d7308a80d | |||
| b43ef9d76d | |||
| 28cdd67743 | |||
| 7f126ce127 | |||
| a6c4debf78 | |||
| a74ad5475e | |||
| fa293828df | |||
| f5582b1754 | |||
| 1af95714c2 | |||
| 0406d18cfd | |||
| 66e9ec9c3c | |||
| 899a7c8318 | |||
| 7c01b69498 | |||
| 4f0d3bf4ed | |||
| 9a5e7a3abb | |||
| 02eb6c7e09 | |||
| 418c09398c | |||
| cdbd4c55e8 | |||
| 2374410891 | |||
| d2c46e91fe | |||
| 12441331e6 | |||
| 9ceeae2de0 | |||
| e0e493c2f1 | |||
| 0f05f7ad93 | |||
| 9bc1b71017 | |||
| b3776871b5 | |||
| 308cb31bf9 | |||
| e1f4643215 | |||
| bc4fb322b5 | |||
| 2c4f192e43 | |||
| fb7a6dccaa | |||
| 2826b7bd7c | |||
| 932848f6c1 | |||
| 9255940c6b | |||
| 3eadd16856 | |||
| 61f46c5ad5 | |||
| aad47d1741 | |||
| 079dd3fe4c | |||
| d47f1bff4d | |||
| 53967f6324 | |||
| f5a70dc2a5 | |||
| 31ae1013d7 | |||
| 071945e558 | |||
| 5c4d6a6e83 | |||
| 9c9be65b2b | |||
| c164684703 | |||
| 842c9001ba | |||
| 481e47076e | |||
|
917a0dd0a0 |
|||
|
358aed7c31 |
|||
| 9893834e85 | |||
| 32cf3225c5 | |||
| 2bfd7518c5 | |||
| 4ba56684d1 | |||
| 0b1e38e5f6 | |||
|
7974219389 |
|||
|
8424e443a9 |
|||
|
85251cf5d4 |
|||
| 8f882ea3ea | |||
| 7a2bcc96bb | |||
| 8b41e58e1f | |||
| 9417359da3 | |||
| 1cf0e1bd84 | |||
| 223f803e87 | |||
| 6cb901d083 | |||
| 096be14230 | |||
| bb8b1e58e8 | |||
| 06261d8c86 | |||
| 869cccf884 | |||
| 0defaf9cb5 | |||
| 60b1f9921d | |||
| f61bc91b0f | |||
| ed2c6053de | |||
| 2cffa8deaa | |||
| f0581271f6 | |||
| 99522234ea | |||
| 67f2862fb1 | |||
|
1c0dc3f904 |
|||
|
b94dbff216 |
|||
| 7388c723cd | |||
| 128be3c17d | |||
|
4c30c94258 |
|||
|
20b8b45aeb |
|||
| 2dd899f287 | |||
| a13cc0ab17 | |||
| 620f9e64d6 | |||
| 25c320b281 | |||
| f19eec56ac | |||
| 7cbcff2e9b | |||
| 9f6407ada6 | |||
| e933ecf046 | |||
|
4010a2ed77 |
|||
|
2f36096e1a |
|||
|
82ec45e375 |
|||
| 37362150fe | |||
| a7ba97803f | |||
| 31dc903877 | |||
| 8943867433 | |||
| d9cb110563 | |||
| 32113cee67 | |||
|
a621ce199a |
|||
|
1f524d6c87 |
|||
|
0320d449ec |
|||
|
30f007687a |
|||
|
adf7856162 |
|||
|
f9dce8b2d3 |
|||
|
15cb6270ef |
|||
|
ed14fdbac9 |
|||
| 8650a15db1 | |||
| 6a10022543 | |||
|
52e4f48eb9 |
|||
| f5e1e8bec9 | |||
| a291477c19 | |||
| 1c88dda76a | |||
| 0b59c22c23 | |||
| 576377e2b2 | |||
| 6ff1867312 | |||
| 3cb52423d2 | |||
| 5a5b6491ac | |||
| 4272c6b077 | |||
| 26071de2e7 | |||
| fe92d9e838 | |||
| 5ea2d644a2 | |||
| c35f90154f | |||
| 36305c50b1 | |||
| 2b3b8eab71 | |||
| aa7c7651e5 | |||
| c41ffb5ceb | |||
| 766a03375a | |||
| 2a4d4247e3 | |||
| 9de5083a7e | |||
| d0557b2bcd | |||
| 1a980d6321 | |||
| fb21d4e645 | |||
| 5933a4d778 | |||
| 8cf16c7831 | |||
|
fcf4e03c2f |
|||
| d1b29e82da | |||
| 290e969a22 | |||
| 18ae91ea6e | |||
| 0bce77a2ac | |||
| 19155607af | |||
| f357c37e2c | |||
| 2980c14728 | |||
| 7e0e00d45d | |||
| 8b4ac0017b | |||
| 8ec1ec527e | |||
| 6096a7181c | |||
| fa9dfb8ff7 | |||
| 2dc006aab4 | |||
| 031b9d6faf | |||
|
d9018a47f6 |
|||
|
|
e893a20dfd |
||
| 09d521661f | |||
| fd46efb193 | |||
| 426f54c9cc | |||
| 45a537b6b1 | |||
| d6feca169c | |||
| 05e2900ab0 | |||
| 30b52e5523 | |||
| 14aeddc11f | |||
| 066399ecdb | |||
| d4bbac4467 | |||
| 7516443a89 | |||
| 73d67e29b4 | |||
| c3e7425f4c | |||
| cc9dbb1def | |||
| 2045edc11b | |||
| 1dcac44d6c | |||
| 300ead65d3 | |||
| 6a0219a7a4 | |||
| 80c69aac05 | |||
| 7417a3cd00 | |||
| 9ca80a54d8 | |||
| 5c0b17ef39 | |||
| 1697d8aaef | |||
| fef441a8ff | |||
| c1ddc4268b | |||
| e323290e61 | |||
| 1ab44d4201 | |||
| 71b1c3dfb0 | |||
| 695930a607 | |||
| eb2a4ff1f0 | |||
| 531d5c80c0 | |||
| 067ed27689 | |||
| fa38de2de7 | |||
| e4d1b49c39 | |||
| af7caec509 | |||
| 90c1f899fc | |||
| a0691ae4cd | |||
| 2f20e6f808 | |||
| 7a4636ae0f | |||
| 53435dcc3e | |||
| 4d01278037 | |||
| 2299e5d41e | |||
| d16f5d5df3 | |||
| da8e9638f4 | |||
| 900ea80a42 | |||
| 4b92d0f685 | |||
| 3ce5533103 | |||
| 4a1ee8c911 | |||
| 3f22a99412 | |||
| caf95cc913 | |||
| fd3130b4d9 | |||
| 65bb5a49e2 | |||
| 4bcc517326 | |||
| 0b164973e0 | |||
| a125df991b | |||
| f9a9b42c58 | |||
| 56ad1d164a | |||
| 3cce18919c | |||
| 76d6a69f5a | |||
| 3db17277b4 | |||
| ece49eb500 | |||
| 746428ed44 | |||
| 984702b3b2 | |||
| 1bc71e1c5d | |||
| 47efa88c9d | |||
| 3821636b77 | |||
| 596f6f9dac | |||
|
7ecdaea83a |
|||
|
|
98cb2644db |
||
| 31db6faa19 | |||
| 872d8b695a | |||
| 6db3e1dda5 | |||
|
|
9aaf78b9dd | ||
| 5d8ac158ce | |||
| d32a53d58f | |||
| a836ec944f | |||
| e7b128e735 | |||
| ff3cb1d80f | |||
| c5ff08ee25 | |||
| 856db29180 | |||
|
|
20e09b4ea8 | ||
| 1dd0682661 | |||
| 7252b8d614 | |||
|
|
e5870a169b | ||
| 94795a3560 | |||
| 7705debab0 | |||
| f87df0527f | |||
| e4512a40e0 | |||
| 1d4a9510b8 | |||
| 2648f07e7a | |||
| 459bf1fcf6 | |||
| 3930e63320 | |||
| acecb1e397 | |||
| 9b48eb5a61 | |||
| 7d40a448cb | |||
| da7aed3814 | |||
| c7f4200417 | |||
| 5e2a5494af | |||
| 7b77fd2510 | |||
| ece5608677 | |||
| 4644f613b2 | |||
| 3afa5ac76d | |||
| 27f8a1df04 | |||
| 8e5b0bbf17 | |||
| 282e9565c9 | |||
| b714ffd48b | |||
| 9968a15ef8 | |||
| d93da55ce9 | |||
| 789bcd402a | |||
| cf6ab60d2e | |||
| 64364b20ff | |||
| d29c7956bc | |||
| e5ef485d6b | |||
| fc8046edc4 | |||
| 4538017206 | |||
| d664b6d253 | |||
| f42aa0a6f2 | |||
| 9d4ba66f6e | |||
| cf846ab8ac | |||
| 219e287c6c | |||
| dede8f9d4b | |||
| 7a1e3f5639 | |||
|
|
9bd77292ff | ||
| f1a143de5b | |||
| 765e343c71 | |||
| af4b91a048 | |||
| cc9044487b | |||
| 11c30001c3 | |||
| ac9161035a | |||
| 007ec0644c | |||
| 1db808fb3d | |||
| 76656275c3 | |||
|
|
64bdbc4bf0 | ||
| 61033bb4e5 | |||
| e608b7924a | |||
| f7f852a28b | |||
| 9b9c4c4abb | |||
| 1b59f5b190 | |||
| 65ab230961 | |||
|
|
c64d0100d5 | ||
| 0112407250 | |||
| 2d3f5fa05d | |||
| a87036ee46 | |||
| a72f5ff69a | |||
|
|
bb99009191 | ||
| 4c45d60529 | |||
| 2211f959ae | |||
| cc1d6f53a0 | |||
| 389778c716 | |||
|
|
e55e9e8139 | ||
| ef76e87477 | |||
| 62526038d6 | |||
| bf2f39623e | |||
| 28c890a52d | |||
| cd189c4fe4 | |||
| b8f6bab12d | |||
| 50b3240c4f | |||
| 18fbc75e16 | |||
| 0881da4a82 | |||
|
|
fa210766a2 | ||
|
|
d4f52e3137 | ||
|
|
8b2ebdc5f7 | ||
| a00407256d | |||
| 24b5eccefc | |||
|
|
815fb39a05 | ||
|
|
24c196d2a4 | ||
|
|
3e26e70d0c | ||
|
|
5ce25e2790 | ||
|
|
8243552c8c | ||
|
|
425e27dee5 | ||
|
|
9ec9269a18 | ||
|
|
bf5cbd1deb | ||
|
|
4c09cbf1a4 | ||
|
|
fc077af4ce | ||
|
|
ca4312bb85 | ||
|
|
fc3b1fccba | ||
|
|
f83346b9b3 | ||
|
|
63c7241aec | ||
|
|
fd77dc579e | ||
|
|
f017ed648f | ||
|
|
27a6745743 | ||
|
|
95be0c8e46 | ||
|
|
17a774ba7e | ||
|
|
a1d2bd173b | ||
|
|
f495550ad7 | ||
|
|
43d0e597a2 | ||
|
|
f1c07b5cf5 | ||
|
|
f2782426d5 | ||
|
|
f13ed92b0e | ||
|
|
6e9e7c45d7 | ||
|
|
c1ca4b9421 | ||
|
|
469feadbc0 | ||
|
|
a5403a4373 | ||
|
|
56c902258d | ||
|
|
9c1660f467 | ||
|
|
dd926b5762 | ||
|
|
9d03351b5d | ||
|
|
719d9a9835 | ||
|
|
731c8c9ad9 | ||
| 2ae8ac2947 | |||
| cc94e5f52f | |||
| a09c9f248e | |||
| 16f0a3976c | |||
| cc78223164 | |||
| 30f56235c1 | |||
| 7458769cb3 | |||
| a5aa9355f5 | |||
| 5c229639f0 | |||
| 059322b7f8 | |||
|
|
f1a98d82c6 | ||
|
|
80e2c023dd | ||
|
|
86511deac4 | ||
|
|
bb3475b3f8 | ||
| bd196c1fb9 | |||
| 873fc22cfb | |||
| f3d6d7c0a3 | |||
| 86cc6ca869 | |||
| d30caa422e | |||
| 84c148fb3b | |||
| 6c4f641c1e | |||
| b44bc57548 | |||
| bb18a9a3f2 | |||
| f7dcbe40d4 | |||
|
|
95533d2b31 | ||
|
|
867d3fceb0 | ||
| 3af92f8b92 | |||
| 7c048d1989 | |||
| d127e73590 | |||
| 13ba5c84de | |||
| 50c4f6f2a1 | |||
| 9588e111c4 | |||
| 37ae34a432 | |||
| e3a559e13b | |||
| 3664ac7418 | |||
| 3f83788858 | |||
| 10cac46f4c | |||
| b1f429f4b5 | |||
| 51095cd419 | |||
| ddd56bf2a7 | |||
| 674a6153f3 | |||
| 793ffbd048 | |||
| aa04473521 | |||
| 247d36a309 | |||
| 77d3c66fb9 | |||
| 9f5b808042 | |||
| 9bea7ae5ed | |||
| e85d487c3a | |||
| 23679a6edd | |||
| 525ffa6a28 | |||
| 0f44fbedf4 | |||
| ac47301a64 | |||
| ae15e0f404 | |||
| 9347c02268 | |||
| a2e8abc537 | |||
| ceeaf25443 | |||
| 10404143c6 | |||
| 62d2b267da | |||
| 94aaf4554f | |||
| 03d50d74ca | |||
| 0c8816e6cc | |||
| 7ed5b33db5 | |||
| e3e4aeff94 | |||
| 57b3066987 | |||
| 89cd879529 | |||
| 1527ff7898 | |||
| 2c61c0bc08 | |||
| 3967e1b5f0 | |||
| bcd8b9982d | |||
| 8cbd51512b | |||
| b36b923c5d | |||
| c38f7a3693 | |||
| f44a7884e6 | |||
| 7c77a5a8a5 | |||
| b61b09f55c | |||
| 9caaee18b5 | |||
| 588955a467 | |||
| 7c0407ed22 | |||
| ee3edeaac2 | |||
| 499f8aa0a4 | |||
| 90a0d3b1e0 | |||
| 548212274f | |||
| cd8ceccfaf | |||
| 1292dd2162 | |||
| e5c12fc81c | |||
| b02ac44cfc | |||
| f5abe05ce9 | |||
| 52963adfc9 | |||
| 6af53d1163 | |||
| 2274cfe480 | |||
| 3cccac8cb1 | |||
| 8cf52651fe | |||
| 919d7573c3 | |||
| 166ef8faae | |||
| 8bfffd8cf7 | |||
| ac2a63763f | |||
| edb54b300b | |||
| 8b2b41eefc | |||
| 41d202c2e7 | |||
| fb172f018a | |||
| 8ef6c6fcbe | |||
| b1355e75c4 | |||
| 0691cda46f | |||
| d2c143d39c | |||
| 8bf07e4766 | |||
| ef32b292a8 | |||
| b3d0fb0cee | |||
| 61f88228b0 | |||
| ff28be7724 | |||
| f98558546c | |||
| 5ff016238e | |||
| 9cc7c77ba9 | |||
| 618e56b2a5 | |||
| 3b1b058ffe | |||
| 338b80903c | |||
| 9a3b52e1fd | |||
| fea97b5149 | |||
| 0dfc935af6 | |||
| 17c87f8758 | |||
| 2f7527a333 | |||
| d49be19544 | |||
| 263891f414 | |||
| d4ae7814a0 | |||
| 644c2e6612 | |||
| dc9b075d5a | |||
| 999feb81ca | |||
| 1bcb2a8be4 | |||
| f581f4b8d9 | |||
| a16d90ff46 | |||
| c7803a2814 | |||
| e50fd04750 | |||
| f4e5dc8382 | |||
| 745de200df | |||
| f19a40ef9c | |||
| bff6980eee | |||
| 483bd50bdf | |||
| 1dc60d2856 | |||
| 5110e64e63 | |||
| 6e85940d63 | |||
| 4d7556f68b | |||
| e00f74ddf7 | |||
| 9212f87735 | |||
| 1aaf27dfb2 | |||
| ebd34f1695 | |||
| 87c65fb723 | |||
| a34dccbd27 | |||
| abb6bed459 | |||
| 49c4f483fd | |||
| 5bd1cc5580 | |||
| 4447956da7 | |||
| f6d2e983d9 | |||
| 9a96a277e6 | |||
| 6bfe524bac | |||
| a45d7bec81 | |||
| ead991dcd1 | |||
| 63c4bf3bf9 | |||
| b22b552bf3 | |||
| ed0127df91 | |||
| 938392b25b | |||
| 17e9f21fb9 | |||
| 481dbc14c3 | |||
| 16cc77fd9d | |||
| 600c438951 | |||
| 5d9bb13410 | |||
| 2e3e68d2cb | |||
| da513c1089 | |||
| 331adca23e | |||
| 3579dbe813 | |||
| e1e5db22f8 | |||
| 8e3a2c7a85 | |||
| 377e3948ff | |||
| 706a31f189 | |||
| 4533fec167 | |||
| e5c772d8a5 | |||
| 633700c0af | |||
| 40a215802f | |||
| 007b3e6d4e | |||
| 5d46acbe41 | |||
|
|
175761c757 | ||
|
|
9dc4960277 | ||
| c7e23fe9ed | |||
| 7644a38574 | |||
| 9e45da75cb | |||
| 2359135327 | |||
| 0ea5824427 | |||
| df9cc6a7d2 | |||
| 5b66dc69a1 | |||
| 448c2593ed | |||
| 8210172d7f | |||
| a364369f25 | |||
| 82e8dae948 | |||
| e430b8c281 | |||
| fa87aed263 | |||
| 219408647c | |||
| c3b4cb21ed | |||
| 5bffa35741 | |||
| 030b321e39 | |||
| a938a2ad61 | |||
|
|
15bf273e6e | ||
|
|
37b6f043dd | ||
| cf545ae93a | |||
| 0c97dba5f1 | |||
| 45a2b9cded | |||
| f149fa4b4b | |||
|
953d08ba63 |
|||
|
88da0c3039 |
|||
| f669e31305 | |||
| 0012e0cdea | |||
| dd2be365b1 | |||
| 049f9c8853 | |||
| d6585811d6 | |||
| 31482ee559 | |||
| 14a277a64f | |||
| 1ffff3255a | |||
| 9723dbdd4c | |||
|
9e52be6ffd |
|||
|
978096b402 |
|||
| 9f5c5c8e13 | |||
| 4453f41967 | |||
| e4cf193cd7 | |||
| cc6aa7af05 | |||
| e1605ae6ab | |||
|
32858fb0b4 |
|||
| d6ea9b6658 | |||
| e59845d4e1 | |||
| 147996b234 | |||
| 9437e95849 | |||
| ac374f89d2 | |||
| 3a3851d2a5 | |||
| ddde37ff59 | |||
| 80318e6e30 | |||
| 278aaabeb9 | |||
| 6756ca8311 | |||
| 06cdc2c46c | |||
|
|
fa7955b8cf | ||
|
|
e5586f7d87 | ||
| 944c0212c3 | |||
| d044504693 | |||
| 2456fc67f1 | |||
| 8a58b72934 | |||
| 6dc0173b74 | |||
| 5c58f85be1 | |||
| 3a9e32a411 | |||
| 30f6ec4f7d | |||
| c67ab09e4d | |||
| 5299046b6b | |||
| 204e515bf7 | |||
| 1334da99e2 | |||
| 996ca19dac | |||
| 61969d17a2 | |||
| d041e23d35 | |||
|
|
e996e09657 | ||
|
|
9c06874073 | ||
|
|
f5e0e10143 | ||
|
|
952a691f60 | ||
|
|
f94181480c | ||
|
|
c27b4a3497 | ||
|
|
58d33503a1 | ||
|
|
38322a3f6f | ||
| 52ab7cb881 | |||
| 17ac63aae6 | |||
| 1f1c8fdaba | |||
|
|
ce6196a5c6 | ||
|
|
6b0aa13856 | ||
|
|
d25db4cd0d | ||
|
|
7097ed67a6 | ||
|
|
52d5240fa0 | ||
|
|
5bf3a4875c | ||
|
|
d9125451f5 | ||
|
|
c3613e0637 | ||
|
|
c8f1af635f | ||
|
|
cfd61dc1d1 | ||
| 7750d2568c | |||
| 4e4f8c2670 | |||
| cb402d6846 | |||
| aa1178dc49 | |||
| 3506819511 | |||
| ac6c927a23 | |||
| bda6451c1d | |||
| d9e396e264 | |||
| 66286f92df | |||
| 715b240589 | |||
| ee5697ac37 | |||
| aa48b95ee7 | |||
| 2639b7105a | |||
| 02df59e964 | |||
| f23810f19a | |||
| 9f5dd6c10d | |||
| eaf2bd22c1 | |||
| b1113d57ae | |||
| dbd312981e | |||
| 511314a54a | |||
| 18267b9677 | |||
| 056ed7184b | |||
| b94c106a36 | |||
| 965dd1aabe | |||
| 626dd66254 | |||
| d46e370950 | |||
| 126bb279cd | |||
| d0eae19556 | |||
| 69971cd7e2 | |||
| 45c6541266 | |||
| 65c837c828 | |||
| 8a4167b7a3 | |||
| 814770c2a9 | |||
| f862eda7d6 | |||
| 5472424d5a | |||
| 10a449fe1a | |||
| f557e2cbbd | |||
|
|
704b97a636 | ||
| 200a1bd63e | |||
| cf4c262226 | |||
| 7b5363ce14 | |||
| 42d9e2bfd8 | |||
| d182509771 | |||
| e567158246 | |||
| db0f057b54 | |||
| 84922c7232 | |||
|
|
16bebe9832 |
150 changed files with 11388 additions and 1087 deletions
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
.git
|
||||
.tox
|
||||
57
.drone.yml
Normal file
57
.drone.yml
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
---
|
||||
kind: pipeline
|
||||
name: python-3-5-alpine-3-10
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: python:3.5-alpine3.10
|
||||
pull: always
|
||||
commands:
|
||||
- scripts/run-tests
|
||||
---
|
||||
kind: pipeline
|
||||
name: python-3-6-alpine-3-10
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: python:3.6-alpine3.10
|
||||
pull: always
|
||||
commands:
|
||||
- scripts/run-tests
|
||||
---
|
||||
kind: pipeline
|
||||
name: python-3-7-alpine-3-10
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: python:3.7-alpine3.10
|
||||
pull: always
|
||||
commands:
|
||||
- scripts/run-tests
|
||||
---
|
||||
kind: pipeline
|
||||
name: python-3-7-alpine-3-7
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: python:3.7-alpine3.7
|
||||
pull: always
|
||||
commands:
|
||||
- scripts/run-tests
|
||||
---
|
||||
kind: pipeline
|
||||
name: documentation
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: witten/borgmatic-docs
|
||||
dockerfile: docs/Dockerfile
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
42
.eleventy.js
Normal file
42
.eleventy.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
|
||||
const inclusiveLangPlugin = require("@11ty/eleventy-plugin-inclusive-language");
|
||||
|
||||
module.exports = function(eleventyConfig) {
|
||||
eleventyConfig.addPlugin(pluginSyntaxHighlight);
|
||||
eleventyConfig.addPlugin(inclusiveLangPlugin);
|
||||
|
||||
let markdownIt = require("markdown-it");
|
||||
let markdownItAnchor = require("markdown-it-anchor");
|
||||
let markdownItReplaceLink = require("markdown-it-replace-link");
|
||||
|
||||
let markdownItOptions = {
|
||||
html: true,
|
||||
breaks: false,
|
||||
linkify: true,
|
||||
replaceLink: function (link, env) {
|
||||
if (process.env.NODE_ENV == "production") {
|
||||
return link;
|
||||
}
|
||||
return link.replace('https://torsion.org/borgmatic/', 'http://localhost:8080/');
|
||||
}
|
||||
};
|
||||
let markdownItAnchorOptions = {
|
||||
permalink: true,
|
||||
permalinkClass: "direct-link"
|
||||
};
|
||||
|
||||
eleventyConfig.setLibrary(
|
||||
"md",
|
||||
markdownIt(markdownItOptions)
|
||||
.use(markdownItAnchor, markdownItAnchorOptions)
|
||||
.use(markdownItReplaceLink)
|
||||
);
|
||||
|
||||
return {
|
||||
templateFormats: [
|
||||
"md",
|
||||
"txt"
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
31
.gitea/issue_template.md
Normal file
31
.gitea/issue_template.md
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#### What I'm trying to do and why
|
||||
|
||||
#### Steps to reproduce (if a bug)
|
||||
|
||||
Include (sanitized) borgmatic configuration files if applicable.
|
||||
|
||||
#### Actual behavior (if a bug)
|
||||
|
||||
Include (sanitized) `--verbosity 2` output if applicable.
|
||||
|
||||
#### Expected behavior (if a bug)
|
||||
|
||||
#### Other notes / implementation ideas
|
||||
|
||||
#### Environment
|
||||
|
||||
**borgmatic version:** [version here]
|
||||
|
||||
Use `sudo borgmatic --version` or `sudo pip show borgmatic | grep ^Version`
|
||||
|
||||
**borgmatic installation method:** [e.g., Debian package, Docker container, etc.]
|
||||
|
||||
**Borg version:** [version here]
|
||||
|
||||
Use `sudo borg --version`
|
||||
|
||||
**Python version:** [version here]
|
||||
|
||||
Use `python3 --version`
|
||||
|
||||
**operating system and version:** [OS here]
|
||||
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
*.egg-info
|
||||
*.pyc
|
||||
*.swp
|
||||
.cache
|
||||
.coverage
|
||||
.pytest_cache
|
||||
.tox
|
||||
__pycache__
|
||||
build/
|
||||
dist/
|
||||
pip-wheel-metadata/
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
syntax: glob
|
||||
*.egg-info
|
||||
*.pyc
|
||||
*.swp
|
||||
.tox
|
||||
build
|
||||
dist
|
||||
23
.hgtags
23
.hgtags
|
|
@ -1,23 +0,0 @@
|
|||
467d3a3ce9185e84ee51ca9156499162efd94f9a 0.0.2
|
||||
7730ae34665c0dedf46deab90b32780abf6dbaff 0.0.3
|
||||
4bb2e81fc77038be4499b7ea6797ab7d109460e0 0.0.4
|
||||
b31d51b633701554e84f996cc0c73bad2990780b 0.0.5
|
||||
b31d51b633701554e84f996cc0c73bad2990780b 0.0.5
|
||||
aa8a807f4ba28f0652764ed14713ffea2fd6922d 0.0.5
|
||||
aa8a807f4ba28f0652764ed14713ffea2fd6922d 0.0.5
|
||||
569aef47a9b25c55b13753f94706f5d330219995 0.0.5
|
||||
569aef47a9b25c55b13753f94706f5d330219995 0.0.5
|
||||
a03495a8e8b471da63b5e2ae79d3ff9065839c2a 0.0.5
|
||||
7ea93ca83f426ec0a608a68580c72c0775b81f86 0.0.6
|
||||
cf4c7065f0711deda1cba878398bc05390e2c3f9 0.0.7
|
||||
38d72677343f0a5d6845f4ac50d6778397083d45 0.1.0
|
||||
ac5dfa01e9d14d09845f5e94c2c679e21c5eb2f9 0.1.1
|
||||
ac5dfa01e9d14d09845f5e94c2c679e21c5eb2f9 0.1.1
|
||||
7b6c87dca7ea312b2257ac1b46857b3f8c56b39c 0.1.1
|
||||
83067f995dd391e38544a7722dc3b254b59c5521 0.1.2
|
||||
acc7fb61566fe8028c179f43ecc735c851220b06 0.1.3
|
||||
6dda59c12de88f060eb7244e6d330173985a9639 0.1.4
|
||||
6dda59c12de88f060eb7244e6d330173985a9639 0.1.4
|
||||
e58246fc92bb22c2b2fd8b86a1227de69d2d0315 0.1.4
|
||||
0afff209b902698c2266986129d6dc9f5f913101 0.1.5
|
||||
4c63f3d90ec2bf6af1714a3acec84654a7c9edf3 0.1.6
|
||||
8
AUTHORS
8
AUTHORS
|
|
@ -1,4 +1,12 @@
|
|||
Dan Helfman <witten@torsion.org>: Main developer
|
||||
|
||||
Alexander Görtz: Python 3 compatibility
|
||||
Florian Lindner: Logging rewrite
|
||||
Henning Schroeder: Copy editing
|
||||
Johannes Feichtner: Support for user hooks
|
||||
Michele Lazzeri: Custom archive names
|
||||
Nick Whyte: Support prefix filtering for archive consistency checks
|
||||
newtonne: Read encryption password from external file
|
||||
Robin `ypid` Schneider: Support additional options of Borg and add validate-borgmatic-config command
|
||||
Scott Squires: Custom archive names
|
||||
Thomas LÉVEIL: Support for a keep_minutely prune option. Support for the --json option
|
||||
|
|
|
|||
2
MANIFEST.in
Normal file
2
MANIFEST.in
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
include borgmatic/config/schema.yaml
|
||||
graft sample/systemd
|
||||
408
NEWS
408
NEWS
|
|
@ -1,12 +1,412 @@
|
|||
1.4.0
|
||||
* #225: Database dump hooks for PostgreSQL, so you can easily dump your databases before backups
|
||||
run.
|
||||
* #230: Rename "borgmatic list --pattern-from" flag to "--patterns-from" to match Borg.
|
||||
|
||||
1.3.26
|
||||
* #224: Fix "borgmatic list --successful" with a slightly better heuristic for listing successful
|
||||
(non-checkpoint) archives.
|
||||
|
||||
1.3.25
|
||||
* #223: Dead man's switch to detect when backups start failing silently, implemented via
|
||||
healthchecks.io hook integration. See the documentation for more information:
|
||||
https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/#healthchecks-hook
|
||||
* Documentation on monitoring and alerting options for borgmatic backups:
|
||||
https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/
|
||||
* Automatically rewrite links when developing on documentation locally.
|
||||
|
||||
1.3.24
|
||||
* #86: Add "borgmatic list --successful" flag to only list successful (non-checkpoint) archives.
|
||||
* Add a suggestion form to all documentation pages, so users can submit ideas for improving the
|
||||
documentation.
|
||||
* Update documentation link to community Arch Linux borgmatic package.
|
||||
|
||||
1.3.23
|
||||
* #174: More detailed error alerting via runtime context available in "on_error" hook.
|
||||
|
||||
1.3.22
|
||||
* #144: When backups to one of several repositories fails, keep backing up to the other
|
||||
repositories and report errors afterwards.
|
||||
|
||||
1.3.21
|
||||
* #192: User-defined hooks for global setup or cleanup that run before/after all actions. See the
|
||||
documentation for more information:
|
||||
https://torsion.org/borgmatic/docs/how-to/add-preparation-and-cleanup-steps-to-backups/
|
||||
|
||||
1.3.20
|
||||
* #205: More robust sample systemd service: boot delay, network dependency, lowered CPU/IO
|
||||
priority, etc.
|
||||
* #221: Fix "borgmatic create --progress" output so that it updates on the console in real-time.
|
||||
|
||||
1.3.19
|
||||
* #219: Fix visibility of "borgmatic prune --stats" output.
|
||||
|
||||
1.3.18
|
||||
* #220: Fix regression of argument parsing for default actions.
|
||||
|
||||
1.3.17
|
||||
* #217: Fix error with "borgmatic check --only" command-line flag with "extract" consistency check.
|
||||
|
||||
1.3.16
|
||||
* #210: Support for Borg check --verify-data flag via borgmatic "data" consistency check.
|
||||
* #210: Override configured consistency checks via "borgmatic check --only" command-line flag.
|
||||
* When generating sample configuration with generate-borgmatic-config, add a space after each "#"
|
||||
comment indicator.
|
||||
|
||||
1.3.15
|
||||
* #208: Fix for traceback when the "checks" option has an empty value.
|
||||
* #209: Bypass Borg error about a moved repository via "relocated_repo_access_is_ok" option in
|
||||
borgmatic storage configuration section.
|
||||
* #213: Reorder arguments passed to Borg to fix duplicate directories when using Borg patterns.
|
||||
* #214: Fix for hook erroring with exit code 1 not being interpreted as an error.
|
||||
|
||||
1.3.14
|
||||
* #204: Do not treat Borg warnings (exit code 1) as failures.
|
||||
* When validating configuration files, require strings instead of allowing any scalar type.
|
||||
|
||||
1.3.13
|
||||
* #199: Add note to documentation about using spaces instead of tabs for indentation, as YAML does
|
||||
not allow tabs.
|
||||
* #203: Fix compatibility with ruamel.yaml 0.16.x.
|
||||
* If a "prefix" option in borgmatic's configuration has an empty value (blank or ""), then disable
|
||||
default prefix.
|
||||
|
||||
1.3.12
|
||||
* Only log to syslog when run from a non-interactive console (e.g. a cron job).
|
||||
* Remove unicode byte order mark from syslog output so it doesn't show up as a literal in rsyslog
|
||||
output. See discussion on #197.
|
||||
|
||||
1.3.11
|
||||
* #193: Pass through several "borg list" and "borg info" flags like --short, --format, --sort-by,
|
||||
--first, --last, etc. via borgmatic command-line flags.
|
||||
* Add borgmatic info --repository and --archive command-line flags to display info for individual
|
||||
repositories or archives.
|
||||
* Support for Borg --noatime, --noctime, and --nobirthtime flags via corresponding options in
|
||||
borgmatic configuration location section.
|
||||
|
||||
1.3.10
|
||||
* #198: Fix for Borg create error output not showing up at borgmatic verbosity level zero.
|
||||
|
||||
1.3.9
|
||||
* #195: Switch to command-line actions as more traditional sub-commands, e.g. "borgmatic create",
|
||||
"borgmatic prune", etc. However, the classic dashed options like "--create" still work!
|
||||
|
||||
1.3.8
|
||||
* #191: Disable console color via "color" option in borgmatic configuration output section.
|
||||
|
||||
1.3.7
|
||||
* #196: Fix for unclear error message for invalid YAML merge include.
|
||||
* #197: Don't color syslog output.
|
||||
* Change default syslog verbosity to show errors only.
|
||||
|
||||
1.3.6
|
||||
* #53: Log to syslog in addition to existing console logging. Add --syslog-verbosity flag to
|
||||
customize the log level. See the documentation for more information:
|
||||
https://torsion.org/borgmatic/docs/how-to/inspect-your-backups/
|
||||
* #178: Look for .yml configuration file extension in addition to .yaml.
|
||||
* #189: Set umask used when executing hooks via "umask" option in borgmatic hooks section.
|
||||
* Remove Python cache files before each Tox run.
|
||||
* Add #borgmatic Freenode IRC channel to documentation.
|
||||
* Add Borg/borgmatic hosting providers section to documentation.
|
||||
* Add files for building documentation into a Docker image for web serving.
|
||||
* Upgrade project build server from Drone 0.8 to 1.1.
|
||||
* Build borgmatic documentation during continuous integration.
|
||||
* We're nearly at 500 ★s on GitHub. We can do this!
|
||||
|
||||
1.3.5
|
||||
* #153: Support for various Borg directory environment variables (BORG_CONFIG_DIR, BORG_CACHE_DIR,
|
||||
etc.) via options in borgmatic's storage configuration.
|
||||
* #177: Fix for regression with missing verbose log entries.
|
||||
|
||||
1.3.4
|
||||
* Part of #125: Color borgmatic (but not Borg) output when using an interactive terminal.
|
||||
* #166: Run tests for all installed versions of Python.
|
||||
* #168: Update README with continuous integration badge.
|
||||
* #169: Automatically sort Python imports in code.
|
||||
* Document installing borgmatic with pip install --user instead of a system Python install.
|
||||
* Get more reproducible builds by pinning the versions of pip and tox used to run tests.
|
||||
* Factor out build/test configuration from tox.ini file.
|
||||
|
||||
1.3.3
|
||||
* Add validate-borgmatic-config command, useful for validating borgmatic config generated by
|
||||
configuration management or even edited by hand.
|
||||
|
||||
1.3.2
|
||||
* #160: Fix for hooks executing when using --dry-run. Now hooks are skipped during a dry run.
|
||||
|
||||
1.3.1
|
||||
* #155: Fix for invalid JSON output when using multiple borgmatic configuration files.
|
||||
* #157: Fix for seemingly random filename ordering when running through a directory of
|
||||
configuration files.
|
||||
* Fix for empty JSON output when using --create --json.
|
||||
* Now capturing Borg output only when --json flag is used. Previously, borgmatic delayed Borg
|
||||
output even without the --json flag.
|
||||
|
||||
1.3.0
|
||||
* #148: Configuration file includes and merging via "!include" tag to support reuse of common
|
||||
options across configuration files.
|
||||
|
||||
1.2.18
|
||||
* #147: Support for Borg create/extract --numeric-owner flag via "numeric_owner" option in
|
||||
borgmatic's location section.
|
||||
|
||||
1.2.17
|
||||
* #140: List the files within an archive via --list --archive option.
|
||||
|
||||
1.2.16
|
||||
* #119: Include a sample borgmatic configuration file in the documentation.
|
||||
* #123: Support for Borg archive restoration via borgmatic --extract command-line flag.
|
||||
* Refactor documentation into multiple separate pages for clarity and findability.
|
||||
* Organize options within command-line help into logical groups.
|
||||
* Exclude tests from distribution packages.
|
||||
|
||||
1.2.15
|
||||
* #127: Remove date echo from schema example, as it's not a substitute for real logging.
|
||||
* #132: Leave exclude_patterns glob expansion to Borg, since doing it in borgmatic leads to
|
||||
confusing behavior.
|
||||
* #136: Handle and format validation errors raised during argument parsing.
|
||||
* #138: Allow use of --stats flag when --create or --prune flags are implied.
|
||||
|
||||
1.2.14
|
||||
* #103: When generating sample configuration with generate-borgmatic-config, document the defaults
|
||||
for each option.
|
||||
* #116: When running multiple configuration files, attempt all configuration files even if one of
|
||||
them errors. Log a summary of results at the end.
|
||||
* Add borgmatic --version command-line flag to get the current installed version number.
|
||||
|
||||
1.2.13
|
||||
* #100: Support for --stats command-line flag independent of --verbosity.
|
||||
* #117: With borgmatic --init command-line flag, proceed without erroring if a repository already
|
||||
exists.
|
||||
|
||||
1.2.12
|
||||
* #110: Support for Borg repository initialization via borgmatic --init command-line flag.
|
||||
* #111: Update Borg create --filter values so a dry run lists files to back up.
|
||||
* #113: Update README with link to a new/forked Docker image.
|
||||
* Prevent deprecated --excludes command-line option from being used.
|
||||
* Refactor README a bit to flow better for first-time users.
|
||||
* Update README with a few additional borgmatic packages (Debian and Ubuntu).
|
||||
|
||||
1.2.11
|
||||
* #108: Support for Borg create --progress via borgmatic command-line flag.
|
||||
|
||||
1.2.10
|
||||
* #105: Support for Borg --chunker-params create option via "chunker_params" option in borgmatic's
|
||||
storage section.
|
||||
|
||||
1.2.9
|
||||
* #102: Fix for syntax error that occurred in Python 3.5 and below.
|
||||
* Make automated tests support running in Python 3.5.
|
||||
|
||||
1.2.8
|
||||
* #73: Enable consistency checks for only certain repositories via "check_repositories" option in
|
||||
borgmatic's consistency configuration. Handy for large repositories that take forever to check.
|
||||
* Include link to issue tracker within various command output.
|
||||
* Run continuous integration tests on a matrix of Python and Borg versions.
|
||||
|
||||
1.2.7
|
||||
* #98: Support for Borg --keep-secondly prune option.
|
||||
* Use Black code formatter and Flake8 code checker as part of running automated tests.
|
||||
* Add an end-to-end automated test that actually integrates with Borg.
|
||||
* Set up continuous integration for borgmatic automated tests on projects.evoworx.org.
|
||||
|
||||
1.2.6
|
||||
* Fix generated configuration to also include a "keep_daily" value so pruning works out of the
|
||||
box.
|
||||
|
||||
1.2.5
|
||||
* #57: When generating sample configuration with generate-borgmatic-config, comment out all
|
||||
optional configuration so as to streamline the initial configuration process.
|
||||
|
||||
1.2.4
|
||||
* Fix for archive checking traceback due to parameter mismatch.
|
||||
|
||||
1.2.3
|
||||
* #64, #90, #92: Rewrite of logging system. Now verbosity flags passed to Borg are derived from
|
||||
borgmatic's log level. Note that the output of borgmatic might slightly change.
|
||||
* Part of #80: Support for Borg create --read-special via "read_special" option in borgmatic's
|
||||
location configuration.
|
||||
* #87: Support for Borg create --checkpoint-interval via "checkpoint_interval" option in
|
||||
borgmatic's storage configuration.
|
||||
* #88: Fix declared pykwalify compatibility version range in setup.py to prevent use of ancient
|
||||
versions of pykwalify with large version numbers.
|
||||
* #89: Pass --show-rc option to Borg when at highest verbosity level.
|
||||
* #94: Support for Borg --json option via borgmatic command-line to --create archives.
|
||||
|
||||
1.2.2
|
||||
* #85: Fix compatibility issue between pykwalify and ruamel.yaml 0.15.52, which manifested in
|
||||
borgmatic as a pykwalify RuleError.
|
||||
|
||||
1.2.1
|
||||
* Skip before/after backup hooks when only doing --prune, --check, --list, and/or --info.
|
||||
* #71: Support for XDG_CONFIG_HOME environment variable for specifying alternate user ~/.config/
|
||||
path.
|
||||
* #74, #83: Support for Borg --json option via borgmatic command-line to --list archives or show
|
||||
archive --info in JSON format, ideal for programmatic consumption.
|
||||
* #38, #76: Upgrade ruamel.yaml compatibility version range and fix support for Python 3.7.
|
||||
* #77: Skip non-"*.yaml" config filenames in /etc/borgmatic.d/ so as not to parse backup files,
|
||||
editor swap files, etc.
|
||||
* #81: Document user-defined hooks run before/after backup, or on error.
|
||||
* Add code style guidelines to the documention.
|
||||
|
||||
1.2.0
|
||||
* #61: Support for Borg --list option via borgmatic command-line to list all archives.
|
||||
* #61: Support for Borg --info option via borgmatic command-line to display summary information.
|
||||
* #62: Update README to mention other ways of installing borgmatic.
|
||||
* Support for Borg --prefix option for consistency checks via "prefix" option in borgmatic's
|
||||
consistency configuration.
|
||||
* Add introductory screencast link to documentation.
|
||||
* #59: Ignore "check_last" and consistency "prefix" when "archives" not in consistency checks.
|
||||
* #60: Add "Persistent" flag to systemd timer example.
|
||||
* #63: Support for Borg --nobsdflags option to skip recording bsdflags (e.g. NODUMP, IMMUTABLE) in
|
||||
archive.
|
||||
* #69: Support for Borg prune --umask option using value of existing "umask" option in borgmatic's
|
||||
storage configuration.
|
||||
* Update tox.ini to only assume Python 3.x instead of Python 3.4 specifically.
|
||||
* Add ~/.config/borgmatic/config.yaml to default configuration path probing.
|
||||
* Document how to develop on and contribute to borgmatic.
|
||||
|
||||
1.1.15
|
||||
* Support for Borg BORG_PASSCOMMAND environment variable to read a password from an external file.
|
||||
* Fix for Borg create error when using borgmatic's --dry-run and --verbosity options together.
|
||||
Work-around for behavior introduced in Borg 1.1.3: https://github.com/borgbackup/borg/issues/3298
|
||||
* #55: Fix for missing tags/releases on Gitea and GitHub project hosting.
|
||||
* #56: Support for Borg --lock-wait option for the maximum wait for a repository/cache lock.
|
||||
* #58: Support for using tilde in exclude_patterns to reference home directory.
|
||||
|
||||
1.1.14
|
||||
* #49: Fix for typo in --patterns-from option.
|
||||
* #47: Support for Borg --dry-run option via borgmatic command-line.
|
||||
|
||||
1.1.13
|
||||
* #54: Fix for incorrect consistency check flags passed to Borg when all three checks ("repository",
|
||||
"archives", and "extract") are specified in borgmatic configuration.
|
||||
* #48: Add "local_path" to configuration for specifying an alternative Borg executable path.
|
||||
* #49: Support for Borg experimental --patterns-from and --patterns options for specifying mixed
|
||||
includes/excludes.
|
||||
* Moved issue tracker from Taiga to integrated Gitea tracker at
|
||||
https://projects.torsion.org/witten/borgmatic/issues
|
||||
|
||||
1.1.12
|
||||
* #46: Declare dependency on pykwalify 1.6 or above, as older versions yield "Unknown key: version"
|
||||
rule errors.
|
||||
* Support for Borg --keep-minutely prune option.
|
||||
|
||||
1.1.11
|
||||
* #26: Add "ssh_command" to configuration for specifying a custom SSH command or options.
|
||||
* Fix for incorrect /etc/borgmatic.d/ configuration path probing on macOS. This problem manifested
|
||||
as an error on startup: "[Errno 2] No such file or directory: '/etc/borgmatic.d'".
|
||||
|
||||
1.1.10
|
||||
* Pass several Unix signals through to child processes like Borg. This means that Borg now properly
|
||||
shuts down if borgmatic is terminated (e.g. due to a system suspend).
|
||||
* #30: Support for using tilde in repository paths to reference home directory.
|
||||
* #43: Support for Borg --files-cache option for setting the files cache operation mode.
|
||||
* #45: Support for Borg --remote-ratelimit option for limiting upload rate.
|
||||
* Log invoked Borg commands when at highest verbosity level.
|
||||
|
||||
1.1.9
|
||||
* #17, #39: Support for user-defined hooks before/after backup, or on error.
|
||||
* #34: Improve clarity of logging spew at high verbosity levels.
|
||||
* #30: Support for using tilde in source directory path to reference home directory.
|
||||
* Require "prefix" in retention section when "archive_name_format" is set. This is to avoid
|
||||
accidental pruning of archives with a different archive name format. For similar reasons, default
|
||||
"prefix" to "{hostname}-" if not specified.
|
||||
* Convert main source repository from Mercurial to Git.
|
||||
* Update dead links to Borg documentation.
|
||||
|
||||
1.1.8
|
||||
* #40: Fix to make /etc/borgmatic/config.yaml optional rather than required when using the default
|
||||
config paths.
|
||||
|
||||
1.1.7
|
||||
|
||||
* #29: Add "archive_name_format" to configuration for customizing archive names.
|
||||
* Fix for traceback when "exclude_from" value is empty in configuration file.
|
||||
* When pruning, make highest verbosity level list archives kept and pruned.
|
||||
* Clarification of Python 3 pip usage in documentation.
|
||||
|
||||
1.1.6
|
||||
|
||||
* #13, #36: Support for Borg --exclude-from, --exclude-caches, and --exclude-if-present options.
|
||||
|
||||
1.1.5
|
||||
|
||||
* #35: New "extract" consistency check that performs a dry-run extraction of the most recent
|
||||
archive.
|
||||
|
||||
1.1.4
|
||||
|
||||
* #18: Added command-line flags for performing a borgmatic run with only pruning, creating, or
|
||||
checking enabled. This supports use cases like running consistency checks from a different cron
|
||||
job with a different frequency, or running pruning with a different verbosity level.
|
||||
|
||||
1.1.3
|
||||
|
||||
* #15: Support for running multiple config files in /etc/borgmatic.d/ from a single borgmatic run.
|
||||
* Fix for generate-borgmatic-config writing config with invalid one_file_system value.
|
||||
|
||||
1.1.2
|
||||
|
||||
* #33: Fix for passing check_last as integer to subprocess when calling Borg.
|
||||
|
||||
1.1.1
|
||||
|
||||
* Part of #33: Fix for upgrade-borgmatic-config converting check_last option as a string instead of
|
||||
an integer.
|
||||
* Fix for upgrade-borgmatic-config erroring when consistency checks option is not present.
|
||||
|
||||
1.1.0
|
||||
|
||||
* Switched config file format to YAML. Run upgrade-borgmatic-config to upgrade.
|
||||
* Added generate-borgmatic-config command for initial config creation.
|
||||
* Dropped Python 2 support. Now Python 3 only.
|
||||
* #19: Fix for README mention of sample files not included in package.
|
||||
* #23: Sample files for triggering borgmatic from a systemd timer.
|
||||
* Support for backing up to multiple repositories.
|
||||
* To free up space, now pruning backups prior to creating a new backup.
|
||||
* Enabled test coverage output during tox runs.
|
||||
* Added logo.
|
||||
|
||||
1.0.3
|
||||
|
||||
* #22: Fix for verbosity flag not actually causing verbose output.
|
||||
|
||||
1.0.2
|
||||
|
||||
* #21: Fix for traceback when remote_path option is missing.
|
||||
|
||||
1.0.1
|
||||
|
||||
* #20: Support for Borg's --remote-path option to use an alternate Borg
|
||||
executable. See sample/config.
|
||||
|
||||
1.0.0
|
||||
|
||||
* Attic is no longer supported, as there hasn't been any recent development on
|
||||
it. Dropping Attic support will allow faster iteration on Borg-specific
|
||||
features. If you're still using Attic, this is a good time to switch to Borg!
|
||||
* Project renamed from atticmatic to borgmatic. See the borgmatic README for
|
||||
information on upgrading.
|
||||
|
||||
0.1.8
|
||||
|
||||
* Fix for handling of spaces in source_directories which resulted in backup up everything.
|
||||
* Fix for broken links to Borg documentation.
|
||||
* At verbosity zero, suppressing Borg check stderr spew about "Checking segments".
|
||||
* Support for Borg --one-file-system.
|
||||
* Support for Borg create --umask.
|
||||
* Support for file globs in source_directories.
|
||||
|
||||
0.1.7
|
||||
|
||||
* #11: Fixed parsing of punctuation in configuration file.
|
||||
* #12: Fixed parsing of punctuation in configuration file.
|
||||
* Better error message when configuration file is missing.
|
||||
|
||||
0.1.6
|
||||
|
||||
* #9: New configuration option for the encryption passphrase.
|
||||
* #10: Support for Borg's new archive compression feature.
|
||||
* #10: New configuration option for the encryption passphrase.
|
||||
* #11: Support for Borg's new archive compression feature.
|
||||
|
||||
0.1.5
|
||||
|
||||
|
|
@ -18,7 +418,7 @@
|
|||
|
||||
0.1.3
|
||||
|
||||
* #1: Add support for "borg check --last N" to Borg backend.
|
||||
* #2: Add support for "borg check --last N" to Borg backend.
|
||||
|
||||
0.1.2
|
||||
|
||||
|
|
|
|||
225
README.md
225
README.md
|
|
@ -1,143 +1,128 @@
|
|||
title: Atticmatic
|
||||
---
|
||||
title: borgmatic
|
||||
permalink: index.html
|
||||
---
|
||||
<a href="https://build.torsion.org/witten/borgmatic" alt="build status"></a>
|
||||
|
||||
## Overview
|
||||
|
||||
atticmatic is a simple Python wrapper script for the
|
||||
[Attic](https://attic-backup.org/) and
|
||||
[Borg](https://borgbackup.github.io/borgbackup/) backup software that
|
||||
initiates a backup, prunes any old backups according to a retention policy,
|
||||
and validates backups for consistency. The script supports specifying your
|
||||
settings in a declarative configuration file rather than having to put them
|
||||
all on the command-line, and handles common errors.
|
||||
<img src="https://projects.torsion.org/witten/borgmatic/raw/branch/master/static/borgmatic.png" alt="borgmatic logo" width="150px" style="float: right; padding-left: 1em;">
|
||||
|
||||
borgmatic is simple, configuration-driven backup software for servers and
|
||||
workstations. Backup all of your machines from the command-line or scheduled
|
||||
jobs. No GUI required. Built atop [Borg Backup](https://www.borgbackup.org/),
|
||||
borgmatic initiates a backup, prunes any old backups according to a retention
|
||||
policy, and validates backups for consistency. borgmatic supports specifying
|
||||
your settings in a declarative configuration file, rather than having to put
|
||||
them all on the command-line, and handles common errors.
|
||||
|
||||
Here's an example config file:
|
||||
|
||||
[location]
|
||||
# Space-separated list of source directories to backup.
|
||||
source_directories: /home /etc
|
||||
```yaml
|
||||
location:
|
||||
# List of source directories to backup. Globs are expanded.
|
||||
source_directories:
|
||||
- /home
|
||||
- /etc
|
||||
- /var/log/syslog*
|
||||
|
||||
# Path to local or remote backup repository.
|
||||
repository: user@backupserver:sourcehostname.attic
|
||||
# Paths to local or remote repositories.
|
||||
repositories:
|
||||
- user@backupserver:sourcehostname.borg
|
||||
|
||||
[retention]
|
||||
# Any paths matching these patterns are excluded from backups.
|
||||
exclude_patterns:
|
||||
- /home/*/.cache
|
||||
|
||||
retention:
|
||||
# Retention policy for how many backups to keep in each category.
|
||||
keep_daily: 7
|
||||
keep_weekly: 4
|
||||
keep_monthly: 6
|
||||
|
||||
[consistency]
|
||||
# Consistency checks to run, or "disabled" to prevent checks.
|
||||
checks: repository archives
|
||||
|
||||
Additionally, exclude patterns can be specified in a separate excludes config
|
||||
file, one pattern per line.
|
||||
|
||||
atticmatic is hosted at <https://torsion.org/atticmatic> with [source code
|
||||
available](https://torsion.org/hg/atticmatic). It's also mirrored on
|
||||
[GitHub](https://github.com/witten/atticmatic) and
|
||||
[BitBucket](https://bitbucket.org/dhelfman/atticmatic) for convenience.
|
||||
|
||||
|
||||
## Setup
|
||||
|
||||
To get up and running, follow the [Attic Quick
|
||||
Start](https://attic-backup.org/quickstart.html) or the [Borg Quick
|
||||
Start](https://borgbackup.github.io/borgbackup/quickstart.html) to create a
|
||||
repository on a local or remote host. Note that if you plan to run atticmatic
|
||||
on a schedule with cron, and you encrypt your attic repository with a
|
||||
passphrase instead of a key file, you'll need to set the atticmatic
|
||||
`encryption_passphrase` configuration variable. See the repository encryption
|
||||
section of the Quick Start for more info.
|
||||
|
||||
If the repository is on a remote host, make sure that your local root user has
|
||||
key-based ssh access to the desired user account on the remote host.
|
||||
|
||||
To install atticmatic, run the following command to download and install it:
|
||||
|
||||
sudo pip install --upgrade atticmatic
|
||||
|
||||
If you are using Attic, copy the following configuration files:
|
||||
|
||||
sudo cp sample/atticmatic.cron /etc/cron.d/atticmatic
|
||||
sudo mkdir /etc/atticmatic/
|
||||
sudo cp sample/config sample/excludes /etc/atticmatic/
|
||||
|
||||
If you are using Borg, copy the files like this instead:
|
||||
|
||||
sudo cp sample/borgmatic.cron /etc/cron.d/borgmatic
|
||||
sudo mkdir /etc/borgmatic/
|
||||
sudo cp sample/config sample/excludes /etc/borgmatic/
|
||||
|
||||
Lastly, modify the /etc files with your desired configuration.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
You can run atticmatic and start a backup simply by invoking it without
|
||||
arguments:
|
||||
|
||||
atticmatic
|
||||
|
||||
Or, if you're using Borg, use this command instead to make use of the Borg
|
||||
backend:
|
||||
|
||||
borgmatic
|
||||
|
||||
This will also prune any old backups as per the configured retention policy,
|
||||
and check backups for consistency problems due to things like file damage.
|
||||
|
||||
By default, the backup will proceed silently except in the case of errors. But
|
||||
if you'd like to to get additional information about the progress of the
|
||||
backup as it proceeds, use the verbosity option:
|
||||
|
||||
atticmattic --verbosity 1
|
||||
|
||||
Or, for even more progress spew:
|
||||
|
||||
atticmattic --verbosity 2
|
||||
|
||||
If you'd like to see the available command-line arguments, view the help:
|
||||
|
||||
atticmattic --help
|
||||
|
||||
|
||||
## Running tests
|
||||
|
||||
First install tox, which is used for setting up testing environments:
|
||||
|
||||
pip install tox
|
||||
|
||||
Then, to actually run tests, run:
|
||||
|
||||
tox
|
||||
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Broken pipe with remote repository
|
||||
|
||||
When running atticmatic on a large remote repository, you may receive errors
|
||||
like the following, particularly while "attic check" is valiating backups for
|
||||
consistency:
|
||||
# List of consistency checks to run: "repository", "archives", etc.
|
||||
checks:
|
||||
- repository
|
||||
- archives
|
||||
|
||||
Write failed: Broken pipe
|
||||
attic: Error: Connection closed by remote host
|
||||
hooks:
|
||||
# Preparation scripts to run, databases to dump, and monitoring to perform.
|
||||
before_backup:
|
||||
- prepare-for-backup.sh
|
||||
postgresql_databases:
|
||||
- name: users
|
||||
healthchecks: https://hc-ping.com/be067061-cf96-4412-8eae-62b0c50d6a8c
|
||||
```
|
||||
|
||||
This error can be caused by an ssh timeout, which you can rectify by adding
|
||||
the following to the ~/.ssh/config file on the client:
|
||||
borgmatic is hosted at <https://torsion.org/borgmatic> with [source code
|
||||
available](https://projects.torsion.org/witten/borgmatic). It's also mirrored
|
||||
on [GitHub](https://github.com/witten/borgmatic) for convenience.
|
||||
|
||||
Host *
|
||||
ServerAliveInterval 120
|
||||
Want to see borgmatic in action? Check out the <a
|
||||
href="https://asciinema.org/a/203761" target="_blank">screencast</a>.
|
||||
|
||||
This should make the client keep the connection alive while validating
|
||||
backups.
|
||||
<script src="https://asciinema.org/a/203761.js" id="asciicast-203761" async></script>
|
||||
|
||||
|
||||
## Issues and feedback
|
||||
## How-to guides
|
||||
|
||||
Got an issue or an idea for a feature enhancement? Check out the [atticmatic
|
||||
issue tracker](https://tree.taiga.io/project/witten-atticmatic/issues). In
|
||||
order to create a new issue or comment on an issue, you'll need to [login
|
||||
first](https://tree.taiga.io/login).
|
||||
* [Set up backups with borgmatic](https://torsion.org/borgmatic/docs/how-to/set-up-backups/) ⬅ *Start here!*
|
||||
* [Make per-application backups](https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/)
|
||||
* [Deal with very large backups](https://torsion.org/borgmatic/docs/how-to/deal-with-very-large-backups/)
|
||||
* [Inspect your backups](https://torsion.org/borgmatic/docs/how-to/inspect-your-backups/)
|
||||
* [Monitor your backups](https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/)
|
||||
* [Restore a backup](https://torsion.org/borgmatic/docs/how-to/restore-a-backup/)
|
||||
* [Backup your databases](https://torsion.org/borgmatic/docs/how-to/backup-your-databases/)
|
||||
* [Add preparation and cleanup steps to backups](https://torsion.org/borgmatic/docs/how-to/add-preparation-and-cleanup-steps-to-backups/)
|
||||
* [Upgrade borgmatic](https://torsion.org/borgmatic/docs/how-to/upgrade/)
|
||||
* [Develop on borgmatic](https://torsion.org/borgmatic/docs/how-to/develop-on-borgmatic/)
|
||||
|
||||
|
||||
## Reference guides
|
||||
|
||||
* [borgmatic configuration reference](https://torsion.org/borgmatic/docs/reference/configuration/)
|
||||
* [borgmatic command-line reference](https://torsion.org/borgmatic/docs/reference/command-line/)
|
||||
|
||||
|
||||
## Hosting providers
|
||||
|
||||
Need somewhere to store your encrypted offsite backups? The following hosting
|
||||
providers include specific support for Borg/borgmatic. Using these links and
|
||||
services helps support borgmatic development and hosting. (These are referral
|
||||
links, but without any tracking scripts or cookies.)
|
||||
|
||||
<ul>
|
||||
<li class="referral"><a href="https://www.rsync.net/cgi-bin/borg.cgi?campaign=borg&adgroup=borgmatic">rsync.net</a>: Cloud Storage provider with full support for borg and any other SSH/SFTP tool</li>
|
||||
<li class="referral"><a href="https://www.borgbase.com/?utm_source=borgmatic">BorgBase</a>: Borg hosting service with support for monitoring, 2FA, and append-only repos</li>
|
||||
</ul>
|
||||
|
||||
## Support and contributing
|
||||
|
||||
### Issues
|
||||
|
||||
You've got issues? Or an idea for a feature enhancement? We've got an [issue
|
||||
tracker](https://projects.torsion.org/witten/borgmatic/issues). In order to
|
||||
create a new issue or comment on an issue, you'll need to [login
|
||||
first](https://projects.torsion.org/user/login). Note that you can login with
|
||||
an existing GitHub account if you prefer.
|
||||
|
||||
If you'd like to chat with borgmatic developers or users, head on over to the
|
||||
`#borgmatic` IRC channel on Freenode, either via <a
|
||||
href="https://webchat.freenode.net/?channels=borgmatic">web chat</a> or a
|
||||
native <a href="irc://chat.freenode.net:6697">IRC client</a>.
|
||||
|
||||
Other questions or comments? Contact <mailto:witten@torsion.org>.
|
||||
|
||||
|
||||
### Contributing
|
||||
|
||||
If you'd like to contribute to borgmatic development, please feel free to
|
||||
submit a [Pull Request](https://projects.torsion.org/witten/borgmatic/pulls)
|
||||
or open an [issue](https://projects.torsion.org/witten/borgmatic/issues) first
|
||||
to discuss your idea. We also accept Pull Requests on GitHub, if that's more
|
||||
your thing. In general, contributions are very welcome. We don't bite!
|
||||
|
||||
Also, please check out the [borgmatic development
|
||||
how-to](https://torsion.org/borgmatic/docs/how-to/develop-on-borgmatic/) for
|
||||
info on cloning source code, running tests, etc.
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
from functools import partial
|
||||
|
||||
from atticmatic.backends import shared
|
||||
|
||||
# An atticmatic backend that supports Attic for actually handling backups.
|
||||
|
||||
COMMAND = 'attic'
|
||||
CONFIG_FORMAT = shared.CONFIG_FORMAT
|
||||
|
||||
|
||||
initialize = partial(shared.initialize, command=COMMAND)
|
||||
create_archive = partial(shared.create_archive, command=COMMAND)
|
||||
prune_archives = partial(shared.prune_archives, command=COMMAND)
|
||||
check_archives = partial(shared.check_archives, command=COMMAND)
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
from functools import partial
|
||||
|
||||
from atticmatic.config import Section_format, option
|
||||
from atticmatic.backends import shared
|
||||
|
||||
# An atticmatic backend that supports Borg for actually handling backups.
|
||||
|
||||
COMMAND = 'borg'
|
||||
CONFIG_FORMAT = (
|
||||
shared.CONFIG_FORMAT[0], # location
|
||||
Section_format(
|
||||
'storage',
|
||||
(
|
||||
option('encryption_passphrase', required=False),
|
||||
option('compression', required=False),
|
||||
),
|
||||
),
|
||||
shared.CONFIG_FORMAT[2], # retention
|
||||
Section_format(
|
||||
'consistency',
|
||||
(
|
||||
option('checks', required=False),
|
||||
option('check_last', required=False),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
initialize = partial(shared.initialize, command=COMMAND)
|
||||
create_archive = partial(shared.create_archive, command=COMMAND)
|
||||
prune_archives = partial(shared.prune_archives, command=COMMAND)
|
||||
check_archives = partial(shared.check_archives, command=COMMAND)
|
||||
|
|
@ -1,210 +0,0 @@
|
|||
from datetime import datetime
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
from atticmatic.config import Section_format, option
|
||||
from atticmatic.verbosity import VERBOSITY_SOME, VERBOSITY_LOTS
|
||||
|
||||
|
||||
# Common backend functionality shared by Attic and Borg. As the two backup
|
||||
# commands diverge, these shared functions will likely need to be replaced
|
||||
# with non-shared functions within atticmatic.backends.attic and
|
||||
# atticmatic.backends.borg.
|
||||
|
||||
|
||||
CONFIG_FORMAT = (
|
||||
Section_format(
|
||||
'location',
|
||||
(
|
||||
option('source_directories'),
|
||||
option('repository'),
|
||||
),
|
||||
),
|
||||
Section_format(
|
||||
'storage',
|
||||
(
|
||||
option('encryption_passphrase', required=False),
|
||||
),
|
||||
),
|
||||
Section_format(
|
||||
'retention',
|
||||
(
|
||||
option('keep_within', required=False),
|
||||
option('keep_hourly', int, required=False),
|
||||
option('keep_daily', int, required=False),
|
||||
option('keep_weekly', int, required=False),
|
||||
option('keep_monthly', int, required=False),
|
||||
option('keep_yearly', int, required=False),
|
||||
option('prefix', required=False),
|
||||
),
|
||||
),
|
||||
Section_format(
|
||||
'consistency',
|
||||
(
|
||||
option('checks', required=False),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def initialize(storage_config, command):
|
||||
passphrase = storage_config.get('encryption_passphrase')
|
||||
|
||||
if passphrase:
|
||||
os.environ['{}_PASSPHRASE'.format(command.upper())] = passphrase
|
||||
|
||||
|
||||
def create_archive(
|
||||
excludes_filename, verbosity, storage_config, source_directories, repository, command,
|
||||
):
|
||||
'''
|
||||
Given an excludes filename (or None), a vebosity flag, a storage config dict, a space-separated
|
||||
list of source directories, a local or remote repository path, and a command to run, create an
|
||||
attic archive.
|
||||
'''
|
||||
sources = tuple(source_directories.split(' '))
|
||||
exclude_flags = ('--exclude-from', excludes_filename) if excludes_filename else ()
|
||||
compression = storage_config.get('compression', None)
|
||||
compression_flags = ('--compression', compression) if compression else ()
|
||||
verbosity_flags = {
|
||||
VERBOSITY_SOME: ('--stats',),
|
||||
VERBOSITY_LOTS: ('--verbose', '--stats'),
|
||||
}.get(verbosity, ())
|
||||
|
||||
full_command = (
|
||||
command, 'create',
|
||||
'{repo}::{hostname}-{timestamp}'.format(
|
||||
repo=repository,
|
||||
hostname=platform.node(),
|
||||
timestamp=datetime.now().isoformat(),
|
||||
),
|
||||
) + sources + exclude_flags + compression_flags + verbosity_flags
|
||||
|
||||
subprocess.check_call(full_command)
|
||||
|
||||
|
||||
def _make_prune_flags(retention_config):
|
||||
'''
|
||||
Given a retention config dict mapping from option name to value, tranform it into an iterable of
|
||||
command-line name-value flag pairs.
|
||||
|
||||
For example, given a retention config of:
|
||||
|
||||
{'keep_weekly': 4, 'keep_monthly': 6}
|
||||
|
||||
This will be returned as an iterable of:
|
||||
|
||||
(
|
||||
('--keep-weekly', '4'),
|
||||
('--keep-monthly', '6'),
|
||||
)
|
||||
'''
|
||||
return (
|
||||
('--' + option_name.replace('_', '-'), str(retention_config[option_name]))
|
||||
for option_name, value in retention_config.items()
|
||||
)
|
||||
|
||||
|
||||
def prune_archives(verbosity, repository, retention_config, command):
|
||||
'''
|
||||
Given a verbosity flag, a local or remote repository path, a retention config dict, and a
|
||||
command to run, prune attic archives according the the retention policy specified in that
|
||||
configuration.
|
||||
'''
|
||||
verbosity_flags = {
|
||||
VERBOSITY_SOME: ('--stats',),
|
||||
VERBOSITY_LOTS: ('--verbose', '--stats'),
|
||||
}.get(verbosity, ())
|
||||
|
||||
full_command = (
|
||||
command, 'prune',
|
||||
repository,
|
||||
) + tuple(
|
||||
element
|
||||
for pair in _make_prune_flags(retention_config)
|
||||
for element in pair
|
||||
) + verbosity_flags
|
||||
|
||||
subprocess.check_call(full_command)
|
||||
|
||||
|
||||
DEFAULT_CHECKS = ('repository', 'archives')
|
||||
|
||||
|
||||
def _parse_checks(consistency_config):
|
||||
'''
|
||||
Given a consistency config with a space-separated "checks" option, transform it to a tuple of
|
||||
named checks to run.
|
||||
|
||||
For example, given a retention config of:
|
||||
|
||||
{'checks': 'repository archives'}
|
||||
|
||||
This will be returned as:
|
||||
|
||||
('repository', 'archives')
|
||||
|
||||
If no "checks" option is present, return the DEFAULT_CHECKS. If the checks value is the string
|
||||
"disabled", return an empty tuple, meaning that no checks should be run.
|
||||
'''
|
||||
checks = consistency_config.get('checks', '').strip()
|
||||
if not checks:
|
||||
return DEFAULT_CHECKS
|
||||
|
||||
return tuple(
|
||||
check for check in consistency_config['checks'].split(' ')
|
||||
if check.lower() not in ('disabled', '')
|
||||
)
|
||||
|
||||
|
||||
def _make_check_flags(checks, check_last=None):
|
||||
'''
|
||||
Given a parsed sequence of checks, transform it into tuple of command-line flags.
|
||||
|
||||
For example, given parsed checks of:
|
||||
|
||||
('repository',)
|
||||
|
||||
This will be returned as:
|
||||
|
||||
('--repository-only',)
|
||||
|
||||
Additionally, if a check_last value is given, a "--last" flag will be added. Note that only
|
||||
Borg supports this flag.
|
||||
'''
|
||||
last_flag = ('--last', check_last) if check_last else ()
|
||||
if checks == DEFAULT_CHECKS:
|
||||
return last_flag
|
||||
|
||||
return tuple(
|
||||
'--{}-only'.format(check) for check in checks
|
||||
) + last_flag
|
||||
|
||||
|
||||
def check_archives(verbosity, repository, consistency_config, command):
|
||||
'''
|
||||
Given a verbosity flag, a local or remote repository path, a consistency config dict, and a
|
||||
command to run, check the contained attic archives for consistency.
|
||||
|
||||
If there are no consistency checks to run, skip running them.
|
||||
'''
|
||||
checks = _parse_checks(consistency_config)
|
||||
check_last = consistency_config.get('check_last', None)
|
||||
if not checks:
|
||||
return
|
||||
|
||||
verbosity_flags = {
|
||||
VERBOSITY_SOME: ('--verbose',),
|
||||
VERBOSITY_LOTS: ('--verbose',),
|
||||
}.get(verbosity, ())
|
||||
|
||||
full_command = (
|
||||
command, 'check',
|
||||
repository,
|
||||
) + _make_check_flags(checks, check_last) + verbosity_flags
|
||||
|
||||
# The check command spews to stdout even without the verbose flag. Suppress it.
|
||||
stdout = None if verbosity_flags else open(os.devnull, 'w')
|
||||
|
||||
subprocess.check_call(full_command, stdout=stdout)
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
from __future__ import print_function
|
||||
from argparse import ArgumentParser
|
||||
from importlib import import_module
|
||||
import os
|
||||
from subprocess import CalledProcessError
|
||||
import sys
|
||||
|
||||
from atticmatic.config import parse_configuration
|
||||
|
||||
|
||||
DEFAULT_CONFIG_FILENAME_PATTERN = '/etc/{}/config'
|
||||
DEFAULT_EXCLUDES_FILENAME_PATTERN = '/etc/{}/excludes'
|
||||
|
||||
|
||||
def parse_arguments(command_name, *arguments):
|
||||
'''
|
||||
Given the name of the command with which this script was invoked and command-line arguments,
|
||||
parse the arguments and return them as an ArgumentParser instance. Use the command name to
|
||||
determine the default configuration and excludes paths.
|
||||
'''
|
||||
config_filename_default = DEFAULT_CONFIG_FILENAME_PATTERN.format(command_name)
|
||||
excludes_filename_default = DEFAULT_EXCLUDES_FILENAME_PATTERN.format(command_name)
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument(
|
||||
'-c', '--config',
|
||||
dest='config_filename',
|
||||
default=config_filename_default,
|
||||
help='Configuration filename',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--excludes',
|
||||
dest='excludes_filename',
|
||||
default=excludes_filename_default if os.path.exists(excludes_filename_default) else None,
|
||||
help='Excludes filename',
|
||||
)
|
||||
parser.add_argument(
|
||||
'-v', '--verbosity',
|
||||
type=int,
|
||||
help='Display verbose progress (1 for some, 2 for lots)',
|
||||
)
|
||||
|
||||
return parser.parse_args(arguments)
|
||||
|
||||
|
||||
def load_backend(command_name):
|
||||
'''
|
||||
Given the name of the command with which this script was invoked, return the corresponding
|
||||
backend module responsible for actually dealing with backups.
|
||||
'''
|
||||
backend_name = {
|
||||
'atticmatic': 'attic',
|
||||
'borgmatic': 'borg',
|
||||
}.get(command_name, 'attic')
|
||||
|
||||
return import_module('atticmatic.backends.{}'.format(backend_name))
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
command_name = os.path.basename(sys.argv[0])
|
||||
args = parse_arguments(command_name, *sys.argv[1:])
|
||||
backend = load_backend(command_name)
|
||||
config = parse_configuration(args.config_filename, backend.CONFIG_FORMAT)
|
||||
repository = config.location['repository']
|
||||
|
||||
backend.initialize(config.storage)
|
||||
backend.create_archive(
|
||||
args.excludes_filename, args.verbosity, config.storage, **config.location
|
||||
)
|
||||
backend.prune_archives(args.verbosity, repository, config.retention)
|
||||
backend.check_archives(args.verbosity, repository, config.consistency)
|
||||
except (ValueError, IOError, CalledProcessError) as error:
|
||||
print(error, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
from flexmock import flexmock
|
||||
import sys
|
||||
|
||||
|
||||
def builtins_mock():
|
||||
try:
|
||||
# Python 2
|
||||
return flexmock(sys.modules['__builtin__'])
|
||||
except KeyError:
|
||||
# Python 3
|
||||
return flexmock(sys.modules['builtins'])
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
from flexmock import flexmock
|
||||
from nose.tools import assert_raises
|
||||
|
||||
from atticmatic import command as module
|
||||
|
||||
|
||||
COMMAND_NAME = 'foomatic'
|
||||
|
||||
|
||||
def test_parse_arguments_with_no_arguments_uses_defaults():
|
||||
flexmock(os.path).should_receive('exists').and_return(True)
|
||||
|
||||
parser = module.parse_arguments(COMMAND_NAME)
|
||||
|
||||
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME_PATTERN.format(COMMAND_NAME)
|
||||
assert parser.excludes_filename == module.DEFAULT_EXCLUDES_FILENAME_PATTERN.format(COMMAND_NAME)
|
||||
assert parser.verbosity == None
|
||||
|
||||
|
||||
def test_parse_arguments_with_filename_arguments_overrides_defaults():
|
||||
flexmock(os.path).should_receive('exists').and_return(True)
|
||||
|
||||
parser = module.parse_arguments(COMMAND_NAME, '--config', 'myconfig', '--excludes', 'myexcludes')
|
||||
|
||||
assert parser.config_filename == 'myconfig'
|
||||
assert parser.excludes_filename == 'myexcludes'
|
||||
assert parser.verbosity == None
|
||||
|
||||
|
||||
def test_parse_arguments_with_missing_default_excludes_file_sets_filename_to_none():
|
||||
flexmock(os.path).should_receive('exists').and_return(False)
|
||||
|
||||
parser = module.parse_arguments(COMMAND_NAME)
|
||||
|
||||
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME_PATTERN.format(COMMAND_NAME)
|
||||
assert parser.excludes_filename == None
|
||||
assert parser.verbosity == None
|
||||
|
||||
|
||||
def test_parse_arguments_with_missing_overridden_excludes_file_retains_filename():
|
||||
flexmock(os.path).should_receive('exists').and_return(False)
|
||||
|
||||
parser = module.parse_arguments(COMMAND_NAME, '--excludes', 'myexcludes')
|
||||
|
||||
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME_PATTERN.format(COMMAND_NAME)
|
||||
assert parser.excludes_filename == 'myexcludes'
|
||||
assert parser.verbosity == None
|
||||
|
||||
|
||||
def test_parse_arguments_with_verbosity_flag_overrides_default():
|
||||
flexmock(os.path).should_receive('exists').and_return(True)
|
||||
|
||||
parser = module.parse_arguments(COMMAND_NAME, '--verbosity', '1')
|
||||
|
||||
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME_PATTERN.format(COMMAND_NAME)
|
||||
assert parser.excludes_filename == module.DEFAULT_EXCLUDES_FILENAME_PATTERN.format(COMMAND_NAME)
|
||||
assert parser.verbosity == 1
|
||||
|
||||
|
||||
def test_parse_arguments_with_invalid_arguments_exits():
|
||||
flexmock(os.path).should_receive('exists').and_return(True)
|
||||
original_stderr = sys.stderr
|
||||
sys.stderr = sys.stdout
|
||||
|
||||
try:
|
||||
with assert_raises(SystemExit):
|
||||
module.parse_arguments(COMMAND_NAME, '--posix-me-harder')
|
||||
finally:
|
||||
sys.stderr = original_stderr
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
try:
|
||||
# Python 2
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
# Python 3
|
||||
from io import StringIO
|
||||
|
||||
from collections import OrderedDict
|
||||
import string
|
||||
|
||||
from atticmatic import config as module
|
||||
|
||||
|
||||
def test_parse_section_options_with_punctuation_should_return_section_options():
|
||||
parser = module.RawConfigParser()
|
||||
parser.readfp(StringIO('[section]\nfoo: {}\n'.format(string.punctuation)))
|
||||
|
||||
section_format = module.Section_format(
|
||||
'section',
|
||||
(module.Config_option('foo', str, required=True),),
|
||||
)
|
||||
|
||||
config = module.parse_section_options(parser, section_format)
|
||||
|
||||
assert config == OrderedDict(
|
||||
(
|
||||
('foo', string.punctuation),
|
||||
)
|
||||
)
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
import subprocess
|
||||
|
||||
|
||||
def test_setup_version_matches_news_version():
|
||||
setup_version = subprocess.check_output(('python', 'setup.py', '--version')).decode('ascii')
|
||||
news_version = open('NEWS').readline()
|
||||
|
||||
assert setup_version == news_version
|
||||
|
|
@ -1,325 +0,0 @@
|
|||
from collections import OrderedDict
|
||||
import os
|
||||
|
||||
from flexmock import flexmock
|
||||
|
||||
from atticmatic.backends import shared as module
|
||||
from atticmatic.tests.builtins import builtins_mock
|
||||
from atticmatic.verbosity import VERBOSITY_SOME, VERBOSITY_LOTS
|
||||
|
||||
|
||||
def test_initialize_with_passphrase_should_set_environment():
|
||||
orig_environ = os.environ
|
||||
|
||||
try:
|
||||
os.environ = {}
|
||||
module.initialize({'encryption_passphrase': 'pass'}, command='attic')
|
||||
assert os.environ.get('ATTIC_PASSPHRASE') == 'pass'
|
||||
finally:
|
||||
os.environ = orig_environ
|
||||
|
||||
|
||||
def test_initialize_without_passphrase_should_not_set_environment():
|
||||
orig_environ = os.environ
|
||||
|
||||
try:
|
||||
os.environ = {}
|
||||
module.initialize({}, command='attic')
|
||||
assert os.environ.get('ATTIC_PASSPHRASE') == None
|
||||
finally:
|
||||
os.environ = orig_environ
|
||||
|
||||
|
||||
def insert_subprocess_mock(check_call_command, **kwargs):
|
||||
subprocess = flexmock()
|
||||
subprocess.should_receive('check_call').with_args(check_call_command, **kwargs).once()
|
||||
flexmock(module).subprocess = subprocess
|
||||
|
||||
|
||||
def insert_subprocess_never():
|
||||
subprocess = flexmock()
|
||||
subprocess.should_receive('check_call').never()
|
||||
flexmock(module).subprocess = subprocess
|
||||
|
||||
|
||||
def insert_platform_mock():
|
||||
flexmock(module.platform).should_receive('node').and_return('host')
|
||||
|
||||
|
||||
def insert_datetime_mock():
|
||||
flexmock(module).datetime = flexmock().should_receive('now').and_return(
|
||||
flexmock().should_receive('isoformat').and_return('now').mock
|
||||
).mock
|
||||
|
||||
|
||||
CREATE_COMMAND_WITHOUT_EXCLUDES = ('attic', 'create', 'repo::host-now', 'foo', 'bar')
|
||||
CREATE_COMMAND = CREATE_COMMAND_WITHOUT_EXCLUDES + ('--exclude-from', 'excludes')
|
||||
|
||||
|
||||
def test_create_archive_should_call_attic_with_parameters():
|
||||
insert_subprocess_mock(CREATE_COMMAND)
|
||||
insert_platform_mock()
|
||||
insert_datetime_mock()
|
||||
|
||||
module.create_archive(
|
||||
excludes_filename='excludes',
|
||||
verbosity=None,
|
||||
storage_config={},
|
||||
source_directories='foo bar',
|
||||
repository='repo',
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
def test_create_archive_with_none_excludes_filename_should_call_attic_without_excludes():
|
||||
insert_subprocess_mock(CREATE_COMMAND_WITHOUT_EXCLUDES)
|
||||
insert_platform_mock()
|
||||
insert_datetime_mock()
|
||||
|
||||
module.create_archive(
|
||||
excludes_filename=None,
|
||||
verbosity=None,
|
||||
storage_config={},
|
||||
source_directories='foo bar',
|
||||
repository='repo',
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
def test_create_archive_with_verbosity_some_should_call_attic_with_stats_parameter():
|
||||
insert_subprocess_mock(CREATE_COMMAND + ('--stats',))
|
||||
insert_platform_mock()
|
||||
insert_datetime_mock()
|
||||
|
||||
module.create_archive(
|
||||
excludes_filename='excludes',
|
||||
verbosity=VERBOSITY_SOME,
|
||||
storage_config={},
|
||||
source_directories='foo bar',
|
||||
repository='repo',
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
def test_create_archive_with_verbosity_lots_should_call_attic_with_verbose_parameter():
|
||||
insert_subprocess_mock(CREATE_COMMAND + ('--verbose', '--stats'))
|
||||
insert_platform_mock()
|
||||
insert_datetime_mock()
|
||||
|
||||
module.create_archive(
|
||||
excludes_filename='excludes',
|
||||
verbosity=VERBOSITY_LOTS,
|
||||
storage_config={},
|
||||
source_directories='foo bar',
|
||||
repository='repo',
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
def test_create_archive_with_compression_should_call_attic_with_compression_parameters():
|
||||
insert_subprocess_mock(CREATE_COMMAND + ('--compression', 'rle'))
|
||||
insert_platform_mock()
|
||||
insert_datetime_mock()
|
||||
|
||||
module.create_archive(
|
||||
excludes_filename='excludes',
|
||||
verbosity=None,
|
||||
storage_config={'compression': 'rle'},
|
||||
source_directories='foo bar',
|
||||
repository='repo',
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
BASE_PRUNE_FLAGS = (
|
||||
('--keep-daily', '1'),
|
||||
('--keep-weekly', '2'),
|
||||
('--keep-monthly', '3'),
|
||||
)
|
||||
|
||||
|
||||
def test_make_prune_flags_should_return_flags_from_config():
|
||||
retention_config = OrderedDict(
|
||||
(
|
||||
('keep_daily', 1),
|
||||
('keep_weekly', 2),
|
||||
('keep_monthly', 3),
|
||||
)
|
||||
)
|
||||
|
||||
result = module._make_prune_flags(retention_config)
|
||||
|
||||
assert tuple(result) == BASE_PRUNE_FLAGS
|
||||
|
||||
|
||||
PRUNE_COMMAND = (
|
||||
'attic', 'prune', 'repo', '--keep-daily', '1', '--keep-weekly', '2', '--keep-monthly', '3',
|
||||
)
|
||||
|
||||
|
||||
def test_prune_archives_should_call_attic_with_parameters():
|
||||
retention_config = flexmock()
|
||||
flexmock(module).should_receive('_make_prune_flags').with_args(retention_config).and_return(
|
||||
BASE_PRUNE_FLAGS,
|
||||
)
|
||||
insert_subprocess_mock(PRUNE_COMMAND)
|
||||
|
||||
module.prune_archives(
|
||||
verbosity=None,
|
||||
repository='repo',
|
||||
retention_config=retention_config,
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
def test_prune_archives_with_verbosity_some_should_call_attic_with_stats_parameter():
|
||||
retention_config = flexmock()
|
||||
flexmock(module).should_receive('_make_prune_flags').with_args(retention_config).and_return(
|
||||
BASE_PRUNE_FLAGS,
|
||||
)
|
||||
insert_subprocess_mock(PRUNE_COMMAND + ('--stats',))
|
||||
|
||||
module.prune_archives(
|
||||
repository='repo',
|
||||
verbosity=VERBOSITY_SOME,
|
||||
retention_config=retention_config,
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
def test_prune_archives_with_verbosity_lots_should_call_attic_with_verbose_parameter():
|
||||
retention_config = flexmock()
|
||||
flexmock(module).should_receive('_make_prune_flags').with_args(retention_config).and_return(
|
||||
BASE_PRUNE_FLAGS,
|
||||
)
|
||||
insert_subprocess_mock(PRUNE_COMMAND + ('--verbose', '--stats',))
|
||||
|
||||
module.prune_archives(
|
||||
repository='repo',
|
||||
verbosity=VERBOSITY_LOTS,
|
||||
retention_config=retention_config,
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
def test_parse_checks_returns_them_as_tuple():
|
||||
checks = module._parse_checks({'checks': 'foo disabled bar'})
|
||||
|
||||
assert checks == ('foo', 'bar')
|
||||
|
||||
|
||||
def test_parse_checks_with_missing_value_returns_defaults():
|
||||
checks = module._parse_checks({})
|
||||
|
||||
assert checks == module.DEFAULT_CHECKS
|
||||
|
||||
|
||||
def test_parse_checks_with_blank_value_returns_defaults():
|
||||
checks = module._parse_checks({'checks': ''})
|
||||
|
||||
assert checks == module.DEFAULT_CHECKS
|
||||
|
||||
|
||||
def test_parse_checks_with_disabled_returns_no_checks():
|
||||
checks = module._parse_checks({'checks': 'disabled'})
|
||||
|
||||
assert checks == ()
|
||||
|
||||
|
||||
def test_make_check_flags_with_checks_returns_flags():
|
||||
flags = module._make_check_flags(('foo', 'bar'))
|
||||
|
||||
assert flags == ('--foo-only', '--bar-only')
|
||||
|
||||
|
||||
def test_make_check_flags_with_default_checks_returns_no_flags():
|
||||
flags = module._make_check_flags(module.DEFAULT_CHECKS)
|
||||
|
||||
assert flags == ()
|
||||
|
||||
|
||||
def test_make_check_flags_with_checks_and_last_returns_flags_including_last():
|
||||
flags = module._make_check_flags(('foo', 'bar'), check_last=3)
|
||||
|
||||
assert flags == ('--foo-only', '--bar-only', '--last', 3)
|
||||
|
||||
|
||||
def test_make_check_flags_with_last_returns_last_flag():
|
||||
flags = module._make_check_flags(module.DEFAULT_CHECKS, check_last=3)
|
||||
|
||||
assert flags == ('--last', 3)
|
||||
|
||||
|
||||
def test_check_archives_should_call_attic_with_parameters():
|
||||
checks = flexmock()
|
||||
check_last = flexmock()
|
||||
consistency_config = flexmock().should_receive('get').and_return(check_last).mock
|
||||
flexmock(module).should_receive('_parse_checks').and_return(checks)
|
||||
flexmock(module).should_receive('_make_check_flags').with_args(checks, check_last).and_return(())
|
||||
stdout = flexmock()
|
||||
insert_subprocess_mock(
|
||||
('attic', 'check', 'repo'),
|
||||
stdout=stdout,
|
||||
)
|
||||
insert_platform_mock()
|
||||
insert_datetime_mock()
|
||||
builtins_mock().should_receive('open').and_return(stdout)
|
||||
flexmock(module.os).should_receive('devnull')
|
||||
|
||||
module.check_archives(
|
||||
verbosity=None,
|
||||
repository='repo',
|
||||
consistency_config=consistency_config,
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
def test_check_archives_with_verbosity_some_should_call_attic_with_verbose_parameter():
|
||||
consistency_config = flexmock().should_receive('get').and_return(None).mock
|
||||
flexmock(module).should_receive('_parse_checks').and_return(flexmock())
|
||||
flexmock(module).should_receive('_make_check_flags').and_return(())
|
||||
insert_subprocess_mock(
|
||||
('attic', 'check', 'repo', '--verbose'),
|
||||
stdout=None,
|
||||
)
|
||||
insert_platform_mock()
|
||||
insert_datetime_mock()
|
||||
|
||||
module.check_archives(
|
||||
verbosity=VERBOSITY_SOME,
|
||||
repository='repo',
|
||||
consistency_config=consistency_config,
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
def test_check_archives_with_verbosity_lots_should_call_attic_with_verbose_parameter():
|
||||
consistency_config = flexmock().should_receive('get').and_return(None).mock
|
||||
flexmock(module).should_receive('_parse_checks').and_return(flexmock())
|
||||
flexmock(module).should_receive('_make_check_flags').and_return(())
|
||||
insert_subprocess_mock(
|
||||
('attic', 'check', 'repo', '--verbose'),
|
||||
stdout=None,
|
||||
)
|
||||
insert_platform_mock()
|
||||
insert_datetime_mock()
|
||||
|
||||
module.check_archives(
|
||||
verbosity=VERBOSITY_LOTS,
|
||||
repository='repo',
|
||||
consistency_config=consistency_config,
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
def test_check_archives_without_any_checks_should_bail():
|
||||
consistency_config = flexmock().should_receive('get').and_return(None).mock
|
||||
flexmock(module).should_receive('_parse_checks').and_return(())
|
||||
insert_subprocess_never()
|
||||
|
||||
module.check_archives(
|
||||
verbosity=None,
|
||||
repository='repo',
|
||||
consistency_config=consistency_config,
|
||||
command='attic',
|
||||
)
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
from flexmock import flexmock
|
||||
|
||||
from atticmatic import command as module
|
||||
|
||||
|
||||
def test_load_backend_with_atticmatic_command_should_return_attic_backend():
|
||||
backend = flexmock()
|
||||
(
|
||||
flexmock(module).should_receive('import_module').with_args('atticmatic.backends.attic')
|
||||
.and_return(backend).once()
|
||||
)
|
||||
|
||||
assert module.load_backend('atticmatic') == backend
|
||||
|
||||
|
||||
def test_load_backend_with_unknown_command_should_return_attic_backend():
|
||||
backend = flexmock()
|
||||
(
|
||||
flexmock(module).should_receive('import_module').with_args('atticmatic.backends.attic')
|
||||
.and_return(backend).once()
|
||||
)
|
||||
|
||||
assert module.load_backend('unknownmatic') == backend
|
||||
|
||||
|
||||
def test_load_backend_with_borgmatic_command_should_return_borg_backend():
|
||||
backend = flexmock()
|
||||
(
|
||||
flexmock(module).should_receive('import_module').with_args('atticmatic.backends.borg')
|
||||
.and_return(backend).once()
|
||||
)
|
||||
|
||||
assert module.load_backend('borgmatic') == backend
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
VERBOSITY_SOME = 1
|
||||
VERBOSITY_LOTS = 2
|
||||
132
borgmatic/borg/check.py
Normal file
132
borgmatic/borg/check.py
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
import logging
|
||||
|
||||
from borgmatic.borg import extract
|
||||
from borgmatic.execute import execute_command
|
||||
|
||||
DEFAULT_CHECKS = ('repository', 'archives')
|
||||
DEFAULT_PREFIX = '{hostname}-'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _parse_checks(consistency_config, only_checks=None):
|
||||
'''
|
||||
Given a consistency config with a "checks" list, and an optional list of override checks,
|
||||
transform them a tuple of named checks to run.
|
||||
|
||||
For example, given a retention config of:
|
||||
|
||||
{'checks': ['repository', 'archives']}
|
||||
|
||||
This will be returned as:
|
||||
|
||||
('repository', 'archives')
|
||||
|
||||
If no "checks" option is present in the config, return the DEFAULT_CHECKS. If the checks value
|
||||
is the string "disabled", return an empty tuple, meaning that no checks should be run.
|
||||
|
||||
If the "data" option is present, then make sure the "archives" option is included as well.
|
||||
'''
|
||||
checks = [
|
||||
check.lower() for check in (only_checks or consistency_config.get('checks', []) or [])
|
||||
]
|
||||
if checks == ['disabled']:
|
||||
return ()
|
||||
|
||||
if 'data' in checks and 'archives' not in checks:
|
||||
checks.append('archives')
|
||||
|
||||
return tuple(check for check in checks if check not in ('disabled', '')) or DEFAULT_CHECKS
|
||||
|
||||
|
||||
def _make_check_flags(checks, check_last=None, prefix=None):
|
||||
'''
|
||||
Given a parsed sequence of checks, transform it into tuple of command-line flags.
|
||||
|
||||
For example, given parsed checks of:
|
||||
|
||||
('repository',)
|
||||
|
||||
This will be returned as:
|
||||
|
||||
('--repository-only',)
|
||||
|
||||
However, if both "repository" and "archives" are in checks, then omit them from the returned
|
||||
flags because Borg does both checks by default.
|
||||
|
||||
Additionally, if a check_last value is given and "archives" is in checks, then include a
|
||||
"--last" flag. And if a prefix value is given and "archives" is in checks, then include a
|
||||
"--prefix" flag.
|
||||
'''
|
||||
if 'archives' in checks:
|
||||
last_flags = ('--last', str(check_last)) if check_last else ()
|
||||
prefix_flags = ('--prefix', prefix) if prefix else ()
|
||||
else:
|
||||
last_flags = ()
|
||||
prefix_flags = ()
|
||||
if check_last:
|
||||
logger.warning(
|
||||
'Ignoring check_last option, as "archives" is not in consistency checks.'
|
||||
)
|
||||
if prefix:
|
||||
logger.warning(
|
||||
'Ignoring consistency prefix option, as "archives" is not in consistency checks.'
|
||||
)
|
||||
|
||||
common_flags = last_flags + prefix_flags + (('--verify-data',) if 'data' in checks else ())
|
||||
|
||||
if set(DEFAULT_CHECKS).issubset(set(checks)):
|
||||
return common_flags
|
||||
|
||||
return (
|
||||
tuple('--{}-only'.format(check) for check in checks if check in DEFAULT_CHECKS)
|
||||
+ common_flags
|
||||
)
|
||||
|
||||
|
||||
def check_archives(
|
||||
repository,
|
||||
storage_config,
|
||||
consistency_config,
|
||||
local_path='borg',
|
||||
remote_path=None,
|
||||
only_checks=None,
|
||||
):
|
||||
'''
|
||||
Given a local or remote repository path, a storage config dict, a consistency config dict,
|
||||
local/remote commands to run, and an optional list of checks to use instead of configured
|
||||
checks, check the contained Borg archives for consistency.
|
||||
|
||||
If there are no consistency checks to run, skip running them.
|
||||
'''
|
||||
checks = _parse_checks(consistency_config, only_checks)
|
||||
check_last = consistency_config.get('check_last', None)
|
||||
lock_wait = None
|
||||
|
||||
if set(checks).intersection(set(DEFAULT_CHECKS + ('data',))):
|
||||
remote_path_flags = ('--remote-path', remote_path) if remote_path else ()
|
||||
lock_wait = storage_config.get('lock_wait', None)
|
||||
lock_wait_flags = ('--lock-wait', str(lock_wait)) if lock_wait else ()
|
||||
|
||||
verbosity_flags = ()
|
||||
if logger.isEnabledFor(logging.INFO):
|
||||
verbosity_flags = ('--info',)
|
||||
if logger.isEnabledFor(logging.DEBUG):
|
||||
verbosity_flags = ('--debug', '--show-rc')
|
||||
|
||||
prefix = consistency_config.get('prefix', DEFAULT_PREFIX)
|
||||
|
||||
full_command = (
|
||||
(local_path, 'check')
|
||||
+ _make_check_flags(checks, check_last, prefix)
|
||||
+ remote_path_flags
|
||||
+ lock_wait_flags
|
||||
+ verbosity_flags
|
||||
+ (repository,)
|
||||
)
|
||||
|
||||
execute_command(full_command)
|
||||
|
||||
if 'extract' in checks:
|
||||
extract.extract_last_archive_dry_run(repository, lock_wait, local_path, remote_path)
|
||||
195
borgmatic/borg/create.py
Normal file
195
borgmatic/borg/create.py
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
import glob
|
||||
import itertools
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
from borgmatic.execute import execute_command, execute_command_without_capture
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _expand_directory(directory):
|
||||
'''
|
||||
Given a directory path, expand any tilde (representing a user's home directory) and any globs
|
||||
therein. Return a list of one or more resulting paths.
|
||||
'''
|
||||
expanded_directory = os.path.expanduser(directory)
|
||||
|
||||
return glob.glob(expanded_directory) or [expanded_directory]
|
||||
|
||||
|
||||
def _expand_directories(directories):
|
||||
'''
|
||||
Given a sequence of directory paths, expand tildes and globs in each one. Return all the
|
||||
resulting directories as a single flattened tuple.
|
||||
'''
|
||||
if directories is None:
|
||||
return ()
|
||||
|
||||
return tuple(
|
||||
itertools.chain.from_iterable(_expand_directory(directory) for directory in directories)
|
||||
)
|
||||
|
||||
|
||||
def _expand_home_directories(directories):
|
||||
'''
|
||||
Given a sequence of directory paths, expand tildes in each one. Do not perform any globbing.
|
||||
Return the results as a tuple.
|
||||
'''
|
||||
if directories is None:
|
||||
return ()
|
||||
|
||||
return tuple(os.path.expanduser(directory) for directory in directories)
|
||||
|
||||
|
||||
def _write_pattern_file(patterns=None):
|
||||
'''
|
||||
Given a sequence of patterns, write them to a named temporary file and return it. Return None
|
||||
if no patterns are provided.
|
||||
'''
|
||||
if not patterns:
|
||||
return None
|
||||
|
||||
pattern_file = tempfile.NamedTemporaryFile('w')
|
||||
pattern_file.write('\n'.join(patterns))
|
||||
pattern_file.flush()
|
||||
|
||||
return pattern_file
|
||||
|
||||
|
||||
def _make_pattern_flags(location_config, pattern_filename=None):
|
||||
'''
|
||||
Given a location config dict with a potential patterns_from option, and a filename containing
|
||||
any additional patterns, return the corresponding Borg flags for those files as a tuple.
|
||||
'''
|
||||
pattern_filenames = tuple(location_config.get('patterns_from') or ()) + (
|
||||
(pattern_filename,) if pattern_filename else ()
|
||||
)
|
||||
|
||||
return tuple(
|
||||
itertools.chain.from_iterable(
|
||||
('--patterns-from', pattern_filename) for pattern_filename in pattern_filenames
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def _make_exclude_flags(location_config, exclude_filename=None):
|
||||
'''
|
||||
Given a location config dict with various exclude options, and a filename containing any exclude
|
||||
patterns, return the corresponding Borg flags as a tuple.
|
||||
'''
|
||||
exclude_filenames = tuple(location_config.get('exclude_from') or ()) + (
|
||||
(exclude_filename,) if exclude_filename else ()
|
||||
)
|
||||
exclude_from_flags = tuple(
|
||||
itertools.chain.from_iterable(
|
||||
('--exclude-from', exclude_filename) for exclude_filename in exclude_filenames
|
||||
)
|
||||
)
|
||||
caches_flag = ('--exclude-caches',) if location_config.get('exclude_caches') else ()
|
||||
if_present = location_config.get('exclude_if_present')
|
||||
if_present_flags = ('--exclude-if-present', if_present) if if_present else ()
|
||||
|
||||
return exclude_from_flags + caches_flag + if_present_flags
|
||||
|
||||
|
||||
BORGMATIC_SOURCE_DIRECTORY = '~/.borgmatic'
|
||||
|
||||
|
||||
def borgmatic_source_directories():
|
||||
'''
|
||||
Return a list of borgmatic-specific source directories used for state like database backups.
|
||||
'''
|
||||
return (
|
||||
[BORGMATIC_SOURCE_DIRECTORY]
|
||||
if os.path.exists(os.path.expanduser(BORGMATIC_SOURCE_DIRECTORY))
|
||||
else []
|
||||
)
|
||||
|
||||
|
||||
def create_archive(
|
||||
dry_run,
|
||||
repository,
|
||||
location_config,
|
||||
storage_config,
|
||||
local_path='borg',
|
||||
remote_path=None,
|
||||
progress=False,
|
||||
stats=False,
|
||||
json=False,
|
||||
):
|
||||
'''
|
||||
Given vebosity/dry-run flags, a local or remote repository path, a location config dict, and a
|
||||
storage config dict, create a Borg archive and return Borg's JSON output (if any).
|
||||
'''
|
||||
sources = _expand_directories(
|
||||
location_config['source_directories'] + borgmatic_source_directories()
|
||||
)
|
||||
|
||||
pattern_file = _write_pattern_file(location_config.get('patterns'))
|
||||
exclude_file = _write_pattern_file(
|
||||
_expand_home_directories(location_config.get('exclude_patterns'))
|
||||
)
|
||||
checkpoint_interval = storage_config.get('checkpoint_interval', None)
|
||||
chunker_params = storage_config.get('chunker_params', None)
|
||||
compression = storage_config.get('compression', None)
|
||||
remote_rate_limit = storage_config.get('remote_rate_limit', None)
|
||||
umask = storage_config.get('umask', None)
|
||||
lock_wait = storage_config.get('lock_wait', None)
|
||||
files_cache = location_config.get('files_cache')
|
||||
default_archive_name_format = '{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f}'
|
||||
archive_name_format = storage_config.get('archive_name_format', default_archive_name_format)
|
||||
|
||||
full_command = (
|
||||
(local_path, 'create')
|
||||
+ _make_pattern_flags(location_config, pattern_file.name if pattern_file else None)
|
||||
+ _make_exclude_flags(location_config, exclude_file.name if exclude_file else None)
|
||||
+ (('--checkpoint-interval', str(checkpoint_interval)) if checkpoint_interval else ())
|
||||
+ (('--chunker-params', chunker_params) if chunker_params else ())
|
||||
+ (('--compression', compression) if compression else ())
|
||||
+ (('--remote-ratelimit', str(remote_rate_limit)) if remote_rate_limit else ())
|
||||
+ (('--one-file-system',) if location_config.get('one_file_system') else ())
|
||||
+ (('--numeric-owner',) if location_config.get('numeric_owner') else ())
|
||||
+ (('--noatime',) if location_config.get('atime') is False else ())
|
||||
+ (('--noctime',) if location_config.get('ctime') is False else ())
|
||||
+ (('--nobirthtime',) if location_config.get('birthtime') is False else ())
|
||||
+ (('--read-special',) if location_config.get('read_special') else ())
|
||||
+ (('--nobsdflags',) if location_config.get('bsd_flags') is False else ())
|
||||
+ (('--files-cache', files_cache) if files_cache else ())
|
||||
+ (('--remote-path', remote_path) if remote_path else ())
|
||||
+ (('--umask', str(umask)) if umask else ())
|
||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||
+ (('--list', '--filter', 'AME-') if logger.isEnabledFor(logging.INFO) and not json else ())
|
||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO and not json else ())
|
||||
+ (
|
||||
('--stats',)
|
||||
if not dry_run and (logger.isEnabledFor(logging.INFO) or stats) and not json
|
||||
else ()
|
||||
)
|
||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) and not json else ())
|
||||
+ (('--dry-run',) if dry_run else ())
|
||||
+ (('--progress',) if progress else ())
|
||||
+ (('--json',) if json else ())
|
||||
+ (
|
||||
'{repository}::{archive_name_format}'.format(
|
||||
repository=repository, archive_name_format=archive_name_format
|
||||
),
|
||||
)
|
||||
+ sources
|
||||
)
|
||||
|
||||
# The progress output isn't compatible with captured and logged output, as progress messes with
|
||||
# the terminal directly.
|
||||
if progress:
|
||||
execute_command_without_capture(full_command)
|
||||
return
|
||||
|
||||
if json:
|
||||
output_log_level = None
|
||||
elif stats:
|
||||
output_log_level = logging.WARNING
|
||||
else:
|
||||
output_log_level = logging.INFO
|
||||
|
||||
return execute_command(full_command, output_log_level)
|
||||
31
borgmatic/borg/environment.py
Normal file
31
borgmatic/borg/environment.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import os
|
||||
|
||||
OPTION_TO_ENVIRONMENT_VARIABLE = {
|
||||
'borg_base_directory': 'BORG_BASE_DIR',
|
||||
'borg_config_directory': 'BORG_CONFIG_DIR',
|
||||
'borg_cache_directory': 'BORG_CACHE_DIR',
|
||||
'borg_security_directory': 'BORG_SECURITY_DIR',
|
||||
'borg_keys_directory': 'BORG_KEYS_DIR',
|
||||
'encryption_passcommand': 'BORG_PASSCOMMAND',
|
||||
'encryption_passphrase': 'BORG_PASSPHRASE',
|
||||
'ssh_command': 'BORG_RSH',
|
||||
}
|
||||
|
||||
DEFAULT_BOOL_OPTION_TO_ENVIRONMENT_VARIABLE = {
|
||||
'relocated_repo_access_is_ok': 'BORG_RELOCATED_REPO_ACCESS_IS_OK',
|
||||
'unknown_unencrypted_repo_access_is_ok': 'BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK',
|
||||
}
|
||||
|
||||
|
||||
def initialize(storage_config):
|
||||
for option_name, environment_variable_name in OPTION_TO_ENVIRONMENT_VARIABLE.items():
|
||||
value = storage_config.get(option_name)
|
||||
if value:
|
||||
os.environ[environment_variable_name] = value
|
||||
|
||||
for (
|
||||
option_name,
|
||||
environment_variable_name,
|
||||
) in DEFAULT_BOOL_OPTION_TO_ENVIRONMENT_VARIABLE.items():
|
||||
value = storage_config.get(option_name, False)
|
||||
os.environ[environment_variable_name] = 'yes' if value else 'no'
|
||||
92
borgmatic/borg/extract.py
Normal file
92
borgmatic/borg/extract.py
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
import logging
|
||||
|
||||
from borgmatic.execute import execute_command, execute_command_without_capture
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def extract_last_archive_dry_run(repository, lock_wait=None, local_path='borg', remote_path=None):
|
||||
'''
|
||||
Perform an extraction dry-run of the most recent archive. If there are no archives, skip the
|
||||
dry-run.
|
||||
'''
|
||||
remote_path_flags = ('--remote-path', remote_path) if remote_path else ()
|
||||
lock_wait_flags = ('--lock-wait', str(lock_wait)) if lock_wait else ()
|
||||
verbosity_flags = ()
|
||||
if logger.isEnabledFor(logging.DEBUG):
|
||||
verbosity_flags = ('--debug', '--show-rc')
|
||||
elif logger.isEnabledFor(logging.INFO):
|
||||
verbosity_flags = ('--info',)
|
||||
|
||||
full_list_command = (
|
||||
(local_path, 'list', '--short')
|
||||
+ remote_path_flags
|
||||
+ lock_wait_flags
|
||||
+ verbosity_flags
|
||||
+ (repository,)
|
||||
)
|
||||
|
||||
list_output = execute_command(full_list_command, output_log_level=None)
|
||||
|
||||
try:
|
||||
last_archive_name = list_output.strip().splitlines()[-1]
|
||||
except IndexError:
|
||||
return
|
||||
|
||||
list_flag = ('--list',) if logger.isEnabledFor(logging.DEBUG) else ()
|
||||
full_extract_command = (
|
||||
(local_path, 'extract', '--dry-run')
|
||||
+ remote_path_flags
|
||||
+ lock_wait_flags
|
||||
+ verbosity_flags
|
||||
+ list_flag
|
||||
+ (
|
||||
'{repository}::{last_archive_name}'.format(
|
||||
repository=repository, last_archive_name=last_archive_name
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
execute_command(full_extract_command)
|
||||
|
||||
|
||||
def extract_archive(
|
||||
dry_run,
|
||||
repository,
|
||||
archive,
|
||||
restore_paths,
|
||||
location_config,
|
||||
storage_config,
|
||||
local_path='borg',
|
||||
remote_path=None,
|
||||
progress=False,
|
||||
):
|
||||
'''
|
||||
Given a dry-run flag, a local or remote repository path, an archive name, zero or more paths to
|
||||
restore from the archive, and location/storage configuration dicts, extract the archive into the
|
||||
current directory.
|
||||
'''
|
||||
umask = storage_config.get('umask', None)
|
||||
lock_wait = storage_config.get('lock_wait', None)
|
||||
|
||||
full_command = (
|
||||
(local_path, 'extract')
|
||||
+ (('--remote-path', remote_path) if remote_path else ())
|
||||
+ (('--numeric-owner',) if location_config.get('numeric_owner') else ())
|
||||
+ (('--umask', str(umask)) if umask else ())
|
||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||
+ (('--debug', '--list', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||
+ (('--dry-run',) if dry_run else ())
|
||||
+ (('--progress',) if progress else ())
|
||||
+ ('::'.join((repository, archive)),)
|
||||
+ (tuple(restore_paths) if restore_paths else ())
|
||||
)
|
||||
|
||||
# The progress output isn't compatible with captured and logged output, as progress messes with
|
||||
# the terminal directly.
|
||||
if progress:
|
||||
execute_command_without_capture(full_command)
|
||||
return
|
||||
|
||||
execute_command(full_command)
|
||||
31
borgmatic/borg/flags.py
Normal file
31
borgmatic/borg/flags.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import itertools
|
||||
|
||||
|
||||
def make_flags(name, value):
|
||||
'''
|
||||
Given a flag name and its value, return it formatted as Borg-compatible flags.
|
||||
'''
|
||||
if not value:
|
||||
return ()
|
||||
|
||||
flag = '--{}'.format(name.replace('_', '-'))
|
||||
|
||||
if value is True:
|
||||
return (flag,)
|
||||
|
||||
return (flag, str(value))
|
||||
|
||||
|
||||
def make_flags_from_arguments(arguments, excludes=()):
|
||||
'''
|
||||
Given borgmatic command-line arguments as an instance of argparse.Namespace, and optionally a
|
||||
list of named arguments to exclude, generate and return the corresponding Borg command-line
|
||||
flags as a tuple.
|
||||
'''
|
||||
return tuple(
|
||||
itertools.chain.from_iterable(
|
||||
make_flags(name, value=getattr(arguments, name))
|
||||
for name in sorted(vars(arguments))
|
||||
if name not in excludes and not name.startswith('_')
|
||||
)
|
||||
)
|
||||
43
borgmatic/borg/info.py
Normal file
43
borgmatic/borg/info.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import logging
|
||||
|
||||
from borgmatic.borg.flags import make_flags, make_flags_from_arguments
|
||||
from borgmatic.execute import execute_command
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def display_archives_info(
|
||||
repository, storage_config, info_arguments, local_path='borg', remote_path=None
|
||||
):
|
||||
'''
|
||||
Given a local or remote repository path, a storage config dict, and the arguments to the info
|
||||
action, display summary information for Borg archives in the repository or return JSON summary
|
||||
information.
|
||||
'''
|
||||
lock_wait = storage_config.get('lock_wait', None)
|
||||
|
||||
full_command = (
|
||||
(local_path, 'info')
|
||||
+ (
|
||||
('--info',)
|
||||
if logger.getEffectiveLevel() == logging.INFO and not info_arguments.json
|
||||
else ()
|
||||
)
|
||||
+ (
|
||||
('--debug', '--show-rc')
|
||||
if logger.isEnabledFor(logging.DEBUG) and not info_arguments.json
|
||||
else ()
|
||||
)
|
||||
+ make_flags('remote-path', remote_path)
|
||||
+ make_flags('lock-wait', lock_wait)
|
||||
+ make_flags_from_arguments(info_arguments, excludes=('repository', 'archive'))
|
||||
+ (
|
||||
'::'.join((repository, info_arguments.archive))
|
||||
if info_arguments.archive
|
||||
else repository,
|
||||
)
|
||||
)
|
||||
|
||||
return execute_command(
|
||||
full_command, output_log_level=None if info_arguments.json else logging.WARNING
|
||||
)
|
||||
48
borgmatic/borg/init.py
Normal file
48
borgmatic/borg/init.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import logging
|
||||
import subprocess
|
||||
|
||||
from borgmatic.execute import execute_command, execute_command_without_capture
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
INFO_REPOSITORY_NOT_FOUND_EXIT_CODE = 2
|
||||
|
||||
|
||||
def initialize_repository(
|
||||
repository,
|
||||
encryption_mode,
|
||||
append_only=None,
|
||||
storage_quota=None,
|
||||
local_path='borg',
|
||||
remote_path=None,
|
||||
):
|
||||
'''
|
||||
Given a local or remote repository path, a Borg encryption mode, whether the repository should
|
||||
be append-only, and the storage quota to use, initialize the repository. If the repository
|
||||
already exists, then log and skip initialization.
|
||||
'''
|
||||
info_command = (local_path, 'info', repository)
|
||||
logger.debug(' '.join(info_command))
|
||||
|
||||
try:
|
||||
execute_command(info_command, output_log_level=None)
|
||||
logger.info('Repository already exists. Skipping initialization.')
|
||||
return
|
||||
except subprocess.CalledProcessError as error:
|
||||
if error.returncode != INFO_REPOSITORY_NOT_FOUND_EXIT_CODE:
|
||||
raise
|
||||
|
||||
init_command = (
|
||||
(local_path, 'init')
|
||||
+ (('--encryption', encryption_mode) if encryption_mode else ())
|
||||
+ (('--append-only',) if append_only else ())
|
||||
+ (('--storage-quota', storage_quota) if storage_quota else ())
|
||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||
+ (('--debug',) if logger.isEnabledFor(logging.DEBUG) else ())
|
||||
+ (('--remote-path', remote_path) if remote_path else ())
|
||||
+ (repository,)
|
||||
)
|
||||
|
||||
# Don't use execute_command() here because it doesn't support interactive prompts.
|
||||
execute_command_without_capture(init_command)
|
||||
50
borgmatic/borg/list.py
Normal file
50
borgmatic/borg/list.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import logging
|
||||
|
||||
from borgmatic.borg.flags import make_flags, make_flags_from_arguments
|
||||
from borgmatic.execute import execute_command
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# A hack to convince Borg to exclude archives ending in ".checkpoint". This assumes that a
|
||||
# non-checkpoint archive name ends in a digit (e.g. from a timestamp).
|
||||
BORG_EXCLUDE_CHECKPOINTS_GLOB = '*[0123456789]'
|
||||
|
||||
|
||||
def list_archives(repository, storage_config, list_arguments, local_path='borg', remote_path=None):
|
||||
'''
|
||||
Given a local or remote repository path, a storage config dict, and the arguments to the list
|
||||
action, display the output of listing Borg archives in the repository or return JSON output. Or,
|
||||
if an archive name is given, listing the files in that archive.
|
||||
'''
|
||||
lock_wait = storage_config.get('lock_wait', None)
|
||||
if list_arguments.successful:
|
||||
list_arguments.glob_archives = BORG_EXCLUDE_CHECKPOINTS_GLOB
|
||||
|
||||
full_command = (
|
||||
(local_path, 'list')
|
||||
+ (
|
||||
('--info',)
|
||||
if logger.getEffectiveLevel() == logging.INFO and not list_arguments.json
|
||||
else ()
|
||||
)
|
||||
+ (
|
||||
('--debug', '--show-rc')
|
||||
if logger.isEnabledFor(logging.DEBUG) and not list_arguments.json
|
||||
else ()
|
||||
)
|
||||
+ make_flags('remote-path', remote_path)
|
||||
+ make_flags('lock-wait', lock_wait)
|
||||
+ make_flags_from_arguments(
|
||||
list_arguments, excludes=('repository', 'archive', 'successful')
|
||||
)
|
||||
+ (
|
||||
'::'.join((repository, list_arguments.archive))
|
||||
if list_arguments.archive
|
||||
else repository,
|
||||
)
|
||||
)
|
||||
|
||||
return execute_command(
|
||||
full_command, output_log_level=None if list_arguments.json else logging.WARNING
|
||||
)
|
||||
67
borgmatic/borg/prune.py
Normal file
67
borgmatic/borg/prune.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import logging
|
||||
|
||||
from borgmatic.execute import execute_command
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _make_prune_flags(retention_config):
|
||||
'''
|
||||
Given a retention config dict mapping from option name to value, tranform it into an iterable of
|
||||
command-line name-value flag pairs.
|
||||
|
||||
For example, given a retention config of:
|
||||
|
||||
{'keep_weekly': 4, 'keep_monthly': 6}
|
||||
|
||||
This will be returned as an iterable of:
|
||||
|
||||
(
|
||||
('--keep-weekly', '4'),
|
||||
('--keep-monthly', '6'),
|
||||
)
|
||||
'''
|
||||
config = retention_config.copy()
|
||||
|
||||
if 'prefix' not in config:
|
||||
config['prefix'] = '{hostname}-'
|
||||
elif not config['prefix']:
|
||||
config.pop('prefix')
|
||||
|
||||
return (
|
||||
('--' + option_name.replace('_', '-'), str(value)) for option_name, value in config.items()
|
||||
)
|
||||
|
||||
|
||||
def prune_archives(
|
||||
dry_run,
|
||||
repository,
|
||||
storage_config,
|
||||
retention_config,
|
||||
local_path='borg',
|
||||
remote_path=None,
|
||||
stats=False,
|
||||
):
|
||||
'''
|
||||
Given dry-run flag, a local or remote repository path, a storage config dict, and a
|
||||
retention config dict, prune Borg archives according to the retention policy specified in that
|
||||
configuration.
|
||||
'''
|
||||
umask = storage_config.get('umask', None)
|
||||
lock_wait = storage_config.get('lock_wait', None)
|
||||
|
||||
full_command = (
|
||||
(local_path, 'prune')
|
||||
+ tuple(element for pair in _make_prune_flags(retention_config) for element in pair)
|
||||
+ (('--remote-path', remote_path) if remote_path else ())
|
||||
+ (('--umask', str(umask)) if umask else ())
|
||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||
+ (('--stats',) if not dry_run and logger.isEnabledFor(logging.INFO) else ())
|
||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||
+ (('--debug', '--list', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||
+ (('--dry-run',) if dry_run else ())
|
||||
+ (('--stats',) if stats else ())
|
||||
+ (repository,)
|
||||
)
|
||||
|
||||
execute_command(full_command, output_log_level=logging.WARNING if stats else logging.INFO)
|
||||
408
borgmatic/commands/arguments.py
Normal file
408
borgmatic/commands/arguments.py
Normal file
|
|
@ -0,0 +1,408 @@
|
|||
import collections
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from borgmatic.config import collect
|
||||
|
||||
SUBPARSER_ALIASES = {
|
||||
'init': ['--init', '-I'],
|
||||
'prune': ['--prune', '-p'],
|
||||
'create': ['--create', '-C'],
|
||||
'check': ['--check', '-k'],
|
||||
'extract': ['--extract', '-x'],
|
||||
'list': ['--list', '-l'],
|
||||
'info': ['--info', '-i'],
|
||||
}
|
||||
|
||||
|
||||
def parse_subparser_arguments(unparsed_arguments, subparsers):
|
||||
'''
|
||||
Given a sequence of arguments, and a subparsers object as returned by
|
||||
argparse.ArgumentParser().add_subparsers(), give each requested action's subparser a shot at
|
||||
parsing all arguments. This allows common arguments like "--repository" to be shared across
|
||||
multiple subparsers.
|
||||
|
||||
Return the result as a dict mapping from subparser name to a parsed namespace of arguments.
|
||||
'''
|
||||
arguments = collections.OrderedDict()
|
||||
remaining_arguments = list(unparsed_arguments)
|
||||
alias_to_subparser_name = {
|
||||
alias: subparser_name
|
||||
for subparser_name, aliases in SUBPARSER_ALIASES.items()
|
||||
for alias in aliases
|
||||
}
|
||||
|
||||
for subparser_name, subparser in subparsers.choices.items():
|
||||
if subparser_name not in remaining_arguments:
|
||||
continue
|
||||
|
||||
canonical_name = alias_to_subparser_name.get(subparser_name, subparser_name)
|
||||
|
||||
# If a parsed value happens to be the same as the name of a subparser, remove it from the
|
||||
# remaining arguments. This prevents, for instance, "check --only extract" from triggering
|
||||
# the "extract" subparser.
|
||||
parsed, unused_remaining = subparser.parse_known_args(unparsed_arguments)
|
||||
for value in vars(parsed).values():
|
||||
if isinstance(value, str):
|
||||
if value in subparsers.choices:
|
||||
remaining_arguments.remove(value)
|
||||
elif isinstance(value, list):
|
||||
for item in value:
|
||||
if item in subparsers.choices:
|
||||
remaining_arguments.remove(item)
|
||||
|
||||
arguments[canonical_name] = parsed
|
||||
|
||||
# If no actions are explicitly requested, assume defaults: prune, create, and check.
|
||||
if not arguments and '--help' not in unparsed_arguments and '-h' not in unparsed_arguments:
|
||||
for subparser_name in ('prune', 'create', 'check'):
|
||||
subparser = subparsers.choices[subparser_name]
|
||||
parsed, unused_remaining = subparser.parse_known_args(unparsed_arguments)
|
||||
arguments[subparser_name] = parsed
|
||||
|
||||
return arguments
|
||||
|
||||
|
||||
def parse_global_arguments(unparsed_arguments, top_level_parser, subparsers):
|
||||
'''
|
||||
Given a sequence of arguments, a top-level parser (containing subparsers), and a subparsers
|
||||
object as returned by argparse.ArgumentParser().add_subparsers(), parse and return any global
|
||||
arguments as a parsed argparse.Namespace instance.
|
||||
'''
|
||||
# Ask each subparser, one by one, to greedily consume arguments. Any arguments that remain
|
||||
# are global arguments.
|
||||
remaining_arguments = list(unparsed_arguments)
|
||||
present_subparser_names = set()
|
||||
|
||||
for subparser_name, subparser in subparsers.choices.items():
|
||||
if subparser_name not in remaining_arguments:
|
||||
continue
|
||||
|
||||
present_subparser_names.add(subparser_name)
|
||||
unused_parsed, remaining_arguments = subparser.parse_known_args(remaining_arguments)
|
||||
|
||||
# If no actions are explicitly requested, assume defaults: prune, create, and check.
|
||||
if (
|
||||
not present_subparser_names
|
||||
and '--help' not in unparsed_arguments
|
||||
and '-h' not in unparsed_arguments
|
||||
):
|
||||
for subparser_name in ('prune', 'create', 'check'):
|
||||
subparser = subparsers.choices[subparser_name]
|
||||
unused_parsed, remaining_arguments = subparser.parse_known_args(remaining_arguments)
|
||||
|
||||
# Remove the subparser names themselves.
|
||||
for subparser_name in present_subparser_names:
|
||||
if subparser_name in remaining_arguments:
|
||||
remaining_arguments.remove(subparser_name)
|
||||
|
||||
return top_level_parser.parse_args(remaining_arguments)
|
||||
|
||||
|
||||
def parse_arguments(*unparsed_arguments):
|
||||
'''
|
||||
Given command-line arguments with which this script was invoked, parse the arguments and return
|
||||
them as a dict mapping from subparser name (or "global") to an argparse.Namespace instance.
|
||||
'''
|
||||
config_paths = collect.get_default_config_paths()
|
||||
|
||||
global_parser = ArgumentParser(add_help=False)
|
||||
global_group = global_parser.add_argument_group('global arguments')
|
||||
|
||||
global_group.add_argument(
|
||||
'-c',
|
||||
'--config',
|
||||
nargs='*',
|
||||
dest='config_paths',
|
||||
default=config_paths,
|
||||
help='Configuration filenames or directories, defaults to: {}'.format(
|
||||
' '.join(config_paths)
|
||||
),
|
||||
)
|
||||
global_group.add_argument(
|
||||
'--excludes',
|
||||
dest='excludes_filename',
|
||||
help='Deprecated in favor of exclude_patterns within configuration',
|
||||
)
|
||||
global_group.add_argument(
|
||||
'-n',
|
||||
'--dry-run',
|
||||
dest='dry_run',
|
||||
action='store_true',
|
||||
help='Go through the motions, but do not actually write to any repositories',
|
||||
)
|
||||
global_group.add_argument(
|
||||
'-nc', '--no-color', dest='no_color', action='store_true', help='Disable colored output'
|
||||
)
|
||||
global_group.add_argument(
|
||||
'-v',
|
||||
'--verbosity',
|
||||
type=int,
|
||||
choices=range(0, 3),
|
||||
default=0,
|
||||
help='Display verbose progress to the console (from none to lots: 0, 1, or 2)',
|
||||
)
|
||||
global_group.add_argument(
|
||||
'--syslog-verbosity',
|
||||
type=int,
|
||||
choices=range(0, 3),
|
||||
default=0,
|
||||
help='Display verbose progress to syslog (from none to lots: 0, 1, or 2). Ignored when console is interactive',
|
||||
)
|
||||
global_group.add_argument(
|
||||
'--version',
|
||||
dest='version',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Display installed version number of borgmatic and exit',
|
||||
)
|
||||
|
||||
top_level_parser = ArgumentParser(
|
||||
description='''
|
||||
A simple wrapper script for the Borg backup software that creates and prunes backups.
|
||||
If none of the action options are given, then borgmatic defaults to: prune, create, and
|
||||
check archives.
|
||||
''',
|
||||
parents=[global_parser],
|
||||
)
|
||||
|
||||
subparsers = top_level_parser.add_subparsers(
|
||||
title='actions',
|
||||
metavar='',
|
||||
help='Specify zero or more actions. Defaults to prune, create, and check. Use --help with action for details:',
|
||||
)
|
||||
init_parser = subparsers.add_parser(
|
||||
'init',
|
||||
aliases=SUBPARSER_ALIASES['init'],
|
||||
help='Initialize an empty Borg repository',
|
||||
description='Initialize an empty Borg repository',
|
||||
add_help=False,
|
||||
)
|
||||
init_group = init_parser.add_argument_group('init arguments')
|
||||
init_group.add_argument(
|
||||
'-e',
|
||||
'--encryption',
|
||||
dest='encryption_mode',
|
||||
help='Borg repository encryption mode',
|
||||
required=True,
|
||||
)
|
||||
init_group.add_argument(
|
||||
'--append-only',
|
||||
dest='append_only',
|
||||
action='store_true',
|
||||
help='Create an append-only repository',
|
||||
)
|
||||
init_group.add_argument(
|
||||
'--storage-quota',
|
||||
dest='storage_quota',
|
||||
help='Create a repository with a fixed storage quota',
|
||||
)
|
||||
init_group.add_argument('-h', '--help', action='help', help='Show this help message and exit')
|
||||
|
||||
prune_parser = subparsers.add_parser(
|
||||
'prune',
|
||||
aliases=SUBPARSER_ALIASES['prune'],
|
||||
help='Prune archives according to the retention policy',
|
||||
description='Prune archives according to the retention policy',
|
||||
add_help=False,
|
||||
)
|
||||
prune_group = prune_parser.add_argument_group('prune arguments')
|
||||
prune_group.add_argument(
|
||||
'--stats',
|
||||
dest='stats',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Display statistics of archive',
|
||||
)
|
||||
prune_group.add_argument('-h', '--help', action='help', help='Show this help message and exit')
|
||||
|
||||
create_parser = subparsers.add_parser(
|
||||
'create',
|
||||
aliases=SUBPARSER_ALIASES['create'],
|
||||
help='Create archives (actually perform backups)',
|
||||
description='Create archives (actually perform backups)',
|
||||
add_help=False,
|
||||
)
|
||||
create_group = create_parser.add_argument_group('create arguments')
|
||||
create_group.add_argument(
|
||||
'--progress',
|
||||
dest='progress',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Display progress for each file as it is processed',
|
||||
)
|
||||
create_group.add_argument(
|
||||
'--stats',
|
||||
dest='stats',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Display statistics of archive',
|
||||
)
|
||||
create_group.add_argument(
|
||||
'--json', dest='json', default=False, action='store_true', help='Output results as JSON'
|
||||
)
|
||||
create_group.add_argument('-h', '--help', action='help', help='Show this help message and exit')
|
||||
|
||||
check_parser = subparsers.add_parser(
|
||||
'check',
|
||||
aliases=SUBPARSER_ALIASES['check'],
|
||||
help='Check archives for consistency',
|
||||
description='Check archives for consistency',
|
||||
add_help=False,
|
||||
)
|
||||
check_group = check_parser.add_argument_group('check arguments')
|
||||
check_group.add_argument(
|
||||
'--only',
|
||||
metavar='CHECK',
|
||||
choices=('repository', 'archives', 'data', 'extract'),
|
||||
dest='only',
|
||||
action='append',
|
||||
help='Run a particular consistency check (repository, archives, data, or extract) instead of configured checks; can specify flag multiple times',
|
||||
)
|
||||
check_group.add_argument('-h', '--help', action='help', help='Show this help message and exit')
|
||||
|
||||
extract_parser = subparsers.add_parser(
|
||||
'extract',
|
||||
aliases=SUBPARSER_ALIASES['extract'],
|
||||
help='Extract a named archive to the current directory',
|
||||
description='Extract a named archive to the current directory',
|
||||
add_help=False,
|
||||
)
|
||||
extract_group = extract_parser.add_argument_group('extract arguments')
|
||||
extract_group.add_argument(
|
||||
'--repository',
|
||||
help='Path of repository to extract, defaults to the configured repository if there is only one',
|
||||
)
|
||||
extract_group.add_argument('--archive', help='Name of archive to operate on', required=True)
|
||||
extract_group.add_argument(
|
||||
'--restore-path',
|
||||
nargs='+',
|
||||
dest='restore_paths',
|
||||
help='Paths to restore from archive, defaults to the entire archive',
|
||||
)
|
||||
extract_group.add_argument(
|
||||
'--progress',
|
||||
dest='progress',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Display progress for each file as it is processed',
|
||||
)
|
||||
extract_group.add_argument(
|
||||
'-h', '--help', action='help', help='Show this help message and exit'
|
||||
)
|
||||
|
||||
list_parser = subparsers.add_parser(
|
||||
'list',
|
||||
aliases=SUBPARSER_ALIASES['list'],
|
||||
help='List archives',
|
||||
description='List archives or the contents of an archive',
|
||||
add_help=False,
|
||||
)
|
||||
list_group = list_parser.add_argument_group('list arguments')
|
||||
list_group.add_argument(
|
||||
'--repository',
|
||||
help='Path of repository to list, defaults to the configured repository if there is only one',
|
||||
)
|
||||
list_group.add_argument('--archive', help='Name of archive to list')
|
||||
list_group.add_argument(
|
||||
'--short', default=False, action='store_true', help='Output only archive or path names'
|
||||
)
|
||||
list_group.add_argument('--format', help='Format for file listing')
|
||||
list_group.add_argument(
|
||||
'--json', default=False, action='store_true', help='Output results as JSON'
|
||||
)
|
||||
list_group.add_argument(
|
||||
'-P', '--prefix', help='Only list archive names starting with this prefix'
|
||||
)
|
||||
list_group.add_argument(
|
||||
'-a', '--glob-archives', metavar='GLOB', help='Only list archive names matching this glob'
|
||||
)
|
||||
list_group.add_argument(
|
||||
'--successful',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Only list archive names of successful (non-checkpoint) backups',
|
||||
)
|
||||
list_group.add_argument(
|
||||
'--sort-by', metavar='KEYS', help='Comma-separated list of sorting keys'
|
||||
)
|
||||
list_group.add_argument(
|
||||
'--first', metavar='N', help='List first N archives after other filters are applied'
|
||||
)
|
||||
list_group.add_argument(
|
||||
'--last', metavar='N', help='List last N archives after other filters are applied'
|
||||
)
|
||||
list_group.add_argument(
|
||||
'-e', '--exclude', metavar='PATTERN', help='Exclude paths matching the pattern'
|
||||
)
|
||||
list_group.add_argument(
|
||||
'--exclude-from', metavar='FILENAME', help='Exclude paths from exclude file, one per line'
|
||||
)
|
||||
list_group.add_argument('--pattern', help='Include or exclude paths matching a pattern')
|
||||
list_group.add_argument(
|
||||
'--patterns-from',
|
||||
metavar='FILENAME',
|
||||
help='Include or exclude paths matching patterns from pattern file, one per line',
|
||||
)
|
||||
list_group.add_argument('-h', '--help', action='help', help='Show this help message and exit')
|
||||
|
||||
info_parser = subparsers.add_parser(
|
||||
'info',
|
||||
aliases=SUBPARSER_ALIASES['info'],
|
||||
help='Display summary information on archives',
|
||||
description='Display summary information on archives',
|
||||
add_help=False,
|
||||
)
|
||||
info_group = info_parser.add_argument_group('info arguments')
|
||||
info_group.add_argument(
|
||||
'--repository',
|
||||
help='Path of repository to show info for, defaults to the configured repository if there is only one',
|
||||
)
|
||||
info_group.add_argument('--archive', help='Name of archive to show info for')
|
||||
info_group.add_argument(
|
||||
'--json', dest='json', default=False, action='store_true', help='Output results as JSON'
|
||||
)
|
||||
info_group.add_argument(
|
||||
'-P', '--prefix', help='Only show info for archive names starting with this prefix'
|
||||
)
|
||||
info_group.add_argument(
|
||||
'-a',
|
||||
'--glob-archives',
|
||||
metavar='GLOB',
|
||||
help='Only show info for archive names matching this glob',
|
||||
)
|
||||
info_group.add_argument(
|
||||
'--sort-by', metavar='KEYS', help='Comma-separated list of sorting keys'
|
||||
)
|
||||
info_group.add_argument(
|
||||
'--first',
|
||||
metavar='N',
|
||||
help='Show info for first N archives after other filters are applied',
|
||||
)
|
||||
info_group.add_argument(
|
||||
'--last', metavar='N', help='Show info for first N archives after other filters are applied'
|
||||
)
|
||||
info_group.add_argument('-h', '--help', action='help', help='Show this help message and exit')
|
||||
|
||||
arguments = parse_subparser_arguments(unparsed_arguments, subparsers)
|
||||
arguments['global'] = parse_global_arguments(unparsed_arguments, top_level_parser, subparsers)
|
||||
|
||||
if arguments['global'].excludes_filename:
|
||||
raise ValueError(
|
||||
'The --excludes option has been replaced with exclude_patterns in configuration'
|
||||
)
|
||||
|
||||
if 'init' in arguments and arguments['global'].dry_run:
|
||||
raise ValueError('The init action cannot be used with the --dry-run option')
|
||||
|
||||
if 'list' in arguments and arguments['list'].glob_archives and arguments['list'].successful:
|
||||
raise ValueError('The --glob-archives and --successful options cannot be used together')
|
||||
|
||||
if (
|
||||
'list' in arguments
|
||||
and 'info' in arguments
|
||||
and arguments['list'].json
|
||||
and arguments['info'].json
|
||||
):
|
||||
raise ValueError('With the --json option, list and info actions cannot be used together')
|
||||
|
||||
return arguments
|
||||
452
borgmatic/commands/borgmatic.py
Normal file
452
borgmatic/commands/borgmatic.py
Normal file
|
|
@ -0,0 +1,452 @@
|
|||
import collections
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from subprocess import CalledProcessError
|
||||
|
||||
import colorama
|
||||
import pkg_resources
|
||||
|
||||
from borgmatic.borg import check as borg_check
|
||||
from borgmatic.borg import create as borg_create
|
||||
from borgmatic.borg import environment as borg_environment
|
||||
from borgmatic.borg import extract as borg_extract
|
||||
from borgmatic.borg import info as borg_info
|
||||
from borgmatic.borg import init as borg_init
|
||||
from borgmatic.borg import list as borg_list
|
||||
from borgmatic.borg import prune as borg_prune
|
||||
from borgmatic.commands.arguments import parse_arguments
|
||||
from borgmatic.config import checks, collect, convert, validate
|
||||
from borgmatic.hooks import command, healthchecks, postgresql
|
||||
from borgmatic.logger import configure_logging, should_do_markup
|
||||
from borgmatic.signals import configure_signals
|
||||
from borgmatic.verbosity import verbosity_to_log_level
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
LEGACY_CONFIG_PATH = '/etc/borgmatic/config'
|
||||
|
||||
|
||||
def run_configuration(config_filename, config, arguments):
|
||||
'''
|
||||
Given a config filename, the corresponding parsed config dict, and command-line arguments as a
|
||||
dict from subparser name to a namespace of parsed arguments, execute its defined pruning,
|
||||
backups, consistency checks, and/or other actions.
|
||||
|
||||
Yield a combination of:
|
||||
|
||||
* JSON output strings from successfully executing any actions that produce JSON
|
||||
* logging.LogRecord instances containing errors from any actions or backup hooks that fail
|
||||
'''
|
||||
(location, storage, retention, consistency, hooks) = (
|
||||
config.get(section_name, {})
|
||||
for section_name in ('location', 'storage', 'retention', 'consistency', 'hooks')
|
||||
)
|
||||
global_arguments = arguments['global']
|
||||
|
||||
local_path = location.get('local_path', 'borg')
|
||||
remote_path = location.get('remote_path')
|
||||
borg_environment.initialize(storage)
|
||||
encountered_error = None
|
||||
error_repository = ''
|
||||
|
||||
if 'create' in arguments:
|
||||
try:
|
||||
command.execute_hook(
|
||||
hooks.get('before_backup'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'pre-backup',
|
||||
global_arguments.dry_run,
|
||||
)
|
||||
postgresql.dump_databases(
|
||||
hooks.get('postgresql_databases'), config_filename, global_arguments.dry_run
|
||||
)
|
||||
healthchecks.ping_healthchecks(
|
||||
hooks.get('healthchecks'), config_filename, global_arguments.dry_run, 'start'
|
||||
)
|
||||
except (OSError, CalledProcessError) as error:
|
||||
encountered_error = error
|
||||
yield from make_error_log_records(
|
||||
'{}: Error running pre-backup hook'.format(config_filename), error
|
||||
)
|
||||
|
||||
if not encountered_error:
|
||||
for repository_path in location['repositories']:
|
||||
try:
|
||||
yield from run_actions(
|
||||
arguments=arguments,
|
||||
location=location,
|
||||
storage=storage,
|
||||
retention=retention,
|
||||
consistency=consistency,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
repository_path=repository_path,
|
||||
)
|
||||
except (OSError, CalledProcessError) as error:
|
||||
encountered_error = error
|
||||
error_repository = repository_path
|
||||
yield from make_error_log_records(
|
||||
'{}: Error running actions for repository'.format(repository_path), error
|
||||
)
|
||||
|
||||
if 'create' in arguments and not encountered_error:
|
||||
try:
|
||||
command.execute_hook(
|
||||
hooks.get('after_backup'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'post-backup',
|
||||
global_arguments.dry_run,
|
||||
)
|
||||
postgresql.remove_database_dumps(
|
||||
hooks.get('postgresql_databases'), config_filename, global_arguments.dry_run
|
||||
)
|
||||
healthchecks.ping_healthchecks(
|
||||
hooks.get('healthchecks'), config_filename, global_arguments.dry_run
|
||||
)
|
||||
except (OSError, CalledProcessError) as error:
|
||||
encountered_error = error
|
||||
yield from make_error_log_records(
|
||||
'{}: Error running post-backup hook'.format(config_filename), error
|
||||
)
|
||||
|
||||
if encountered_error:
|
||||
try:
|
||||
command.execute_hook(
|
||||
hooks.get('on_error'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'on-error',
|
||||
global_arguments.dry_run,
|
||||
repository=error_repository,
|
||||
error=encountered_error,
|
||||
output=getattr(encountered_error, 'output', ''),
|
||||
)
|
||||
healthchecks.ping_healthchecks(
|
||||
hooks.get('healthchecks'), config_filename, global_arguments.dry_run, 'fail'
|
||||
)
|
||||
except (OSError, CalledProcessError) as error:
|
||||
yield from make_error_log_records(
|
||||
'{}: Error running on-error hook'.format(config_filename), error
|
||||
)
|
||||
|
||||
|
||||
def run_actions(
|
||||
*,
|
||||
arguments,
|
||||
location,
|
||||
storage,
|
||||
retention,
|
||||
consistency,
|
||||
local_path,
|
||||
remote_path,
|
||||
repository_path
|
||||
): # pragma: no cover
|
||||
'''
|
||||
Given parsed command-line arguments as an argparse.ArgumentParser instance, several different
|
||||
configuration dicts, local and remote paths to Borg, and a repository name, run all actions
|
||||
from the command-line arguments on the given repository.
|
||||
|
||||
Yield JSON output strings from executing any actions that produce JSON.
|
||||
'''
|
||||
repository = os.path.expanduser(repository_path)
|
||||
global_arguments = arguments['global']
|
||||
dry_run_label = ' (dry run; not making any changes)' if global_arguments.dry_run else ''
|
||||
if 'init' in arguments:
|
||||
logger.info('{}: Initializing repository'.format(repository))
|
||||
borg_init.initialize_repository(
|
||||
repository,
|
||||
arguments['init'].encryption_mode,
|
||||
arguments['init'].append_only,
|
||||
arguments['init'].storage_quota,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
)
|
||||
if 'prune' in arguments:
|
||||
logger.info('{}: Pruning archives{}'.format(repository, dry_run_label))
|
||||
borg_prune.prune_archives(
|
||||
global_arguments.dry_run,
|
||||
repository,
|
||||
storage,
|
||||
retention,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
stats=arguments['prune'].stats,
|
||||
)
|
||||
if 'create' in arguments:
|
||||
logger.info('{}: Creating archive{}'.format(repository, dry_run_label))
|
||||
json_output = borg_create.create_archive(
|
||||
global_arguments.dry_run,
|
||||
repository,
|
||||
location,
|
||||
storage,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
progress=arguments['create'].progress,
|
||||
stats=arguments['create'].stats,
|
||||
json=arguments['create'].json,
|
||||
)
|
||||
if json_output:
|
||||
yield json.loads(json_output)
|
||||
if 'check' in arguments and checks.repository_enabled_for_checks(repository, consistency):
|
||||
logger.info('{}: Running consistency checks'.format(repository))
|
||||
borg_check.check_archives(
|
||||
repository,
|
||||
storage,
|
||||
consistency,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
only_checks=arguments['check'].only,
|
||||
)
|
||||
if 'extract' in arguments:
|
||||
if arguments['extract'].repository is None or repository == arguments['extract'].repository:
|
||||
logger.info(
|
||||
'{}: Extracting archive {}'.format(repository, arguments['extract'].archive)
|
||||
)
|
||||
borg_extract.extract_archive(
|
||||
global_arguments.dry_run,
|
||||
repository,
|
||||
arguments['extract'].archive,
|
||||
arguments['extract'].restore_paths,
|
||||
location,
|
||||
storage,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
progress=arguments['extract'].progress,
|
||||
)
|
||||
if 'list' in arguments:
|
||||
if arguments['list'].repository is None or repository == arguments['list'].repository:
|
||||
logger.info('{}: Listing archives'.format(repository))
|
||||
json_output = borg_list.list_archives(
|
||||
repository,
|
||||
storage,
|
||||
list_arguments=arguments['list'],
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
)
|
||||
if json_output:
|
||||
yield json.loads(json_output)
|
||||
if 'info' in arguments:
|
||||
if arguments['info'].repository is None or repository == arguments['info'].repository:
|
||||
logger.info('{}: Displaying summary info for archives'.format(repository))
|
||||
json_output = borg_info.display_archives_info(
|
||||
repository,
|
||||
storage,
|
||||
info_arguments=arguments['info'],
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
)
|
||||
if json_output:
|
||||
yield json.loads(json_output)
|
||||
|
||||
|
||||
def load_configurations(config_filenames):
|
||||
'''
|
||||
Given a sequence of configuration filenames, load and validate each configuration file. Return
|
||||
the results as a tuple of: dict of configuration filename to corresponding parsed configuration,
|
||||
and sequence of logging.LogRecord instances containing any parse errors.
|
||||
'''
|
||||
# Dict mapping from config filename to corresponding parsed config dict.
|
||||
configs = collections.OrderedDict()
|
||||
logs = []
|
||||
|
||||
# Parse and load each configuration file.
|
||||
for config_filename in config_filenames:
|
||||
try:
|
||||
configs[config_filename] = validate.parse_configuration(
|
||||
config_filename, validate.schema_filename()
|
||||
)
|
||||
except (ValueError, OSError, validate.Validation_error) as error:
|
||||
logs.extend(
|
||||
[
|
||||
logging.makeLogRecord(
|
||||
dict(
|
||||
levelno=logging.CRITICAL,
|
||||
levelname='CRITICAL',
|
||||
msg='{}: Error parsing configuration file'.format(config_filename),
|
||||
)
|
||||
),
|
||||
logging.makeLogRecord(
|
||||
dict(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error)
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
return (configs, logs)
|
||||
|
||||
|
||||
def make_error_log_records(message, error=None):
|
||||
'''
|
||||
Given error message text and an optional exception object, yield a series of logging.LogRecord
|
||||
instances with error summary information.
|
||||
'''
|
||||
if not error:
|
||||
yield logging.makeLogRecord(
|
||||
dict(levelno=logging.CRITICAL, levelname='CRITICAL', msg=message)
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
raise error
|
||||
except CalledProcessError as error:
|
||||
yield logging.makeLogRecord(
|
||||
dict(levelno=logging.CRITICAL, levelname='CRITICAL', msg=message)
|
||||
)
|
||||
yield logging.makeLogRecord(
|
||||
dict(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error.output)
|
||||
)
|
||||
yield logging.makeLogRecord(dict(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error))
|
||||
except (ValueError, OSError) as error:
|
||||
yield logging.makeLogRecord(
|
||||
dict(levelno=logging.CRITICAL, levelname='CRITICAL', msg=message)
|
||||
)
|
||||
yield logging.makeLogRecord(dict(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error))
|
||||
except: # noqa: E722
|
||||
# Raising above only as a means of determining the error type. Swallow the exception here
|
||||
# because we don't want the exception to propagate out of this function.
|
||||
pass
|
||||
|
||||
|
||||
def collect_configuration_run_summary_logs(configs, arguments):
|
||||
'''
|
||||
Given a dict of configuration filename to corresponding parsed configuration, and parsed
|
||||
command-line arguments as a dict from subparser name to a parsed namespace of arguments, run
|
||||
each configuration file and yield a series of logging.LogRecord instances containing summary
|
||||
information about each run.
|
||||
|
||||
As a side effect of running through these configuration files, output their JSON results, if
|
||||
any, to stdout.
|
||||
'''
|
||||
# Run cross-file validation checks.
|
||||
if 'extract' in arguments:
|
||||
repository = arguments['extract'].repository
|
||||
elif 'list' in arguments and arguments['list'].archive:
|
||||
repository = arguments['list'].repository
|
||||
else:
|
||||
repository = None
|
||||
|
||||
if repository:
|
||||
try:
|
||||
validate.guard_configuration_contains_repository(repository, configs)
|
||||
except ValueError as error:
|
||||
yield from make_error_log_records(str(error))
|
||||
return
|
||||
|
||||
if not configs:
|
||||
yield from make_error_log_records(
|
||||
'{}: No configuration files found'.format(' '.join(arguments['global'].config_paths))
|
||||
)
|
||||
return
|
||||
|
||||
if 'create' in arguments:
|
||||
try:
|
||||
for config_filename, config in configs.items():
|
||||
hooks = config.get('hooks', {})
|
||||
command.execute_hook(
|
||||
hooks.get('before_everything'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'pre-everything',
|
||||
arguments['global'].dry_run,
|
||||
)
|
||||
except (CalledProcessError, ValueError, OSError) as error:
|
||||
yield from make_error_log_records('Error running pre-everything hook', error)
|
||||
return
|
||||
|
||||
# Execute the actions corresponding to each configuration file.
|
||||
json_results = []
|
||||
for config_filename, config in configs.items():
|
||||
results = list(run_configuration(config_filename, config, arguments))
|
||||
error_logs = tuple(result for result in results if isinstance(result, logging.LogRecord))
|
||||
|
||||
if error_logs:
|
||||
yield from make_error_log_records(
|
||||
'{}: Error running configuration file'.format(config_filename)
|
||||
)
|
||||
yield from error_logs
|
||||
else:
|
||||
yield logging.makeLogRecord(
|
||||
dict(
|
||||
levelno=logging.INFO,
|
||||
levelname='INFO',
|
||||
msg='{}: Successfully ran configuration file'.format(config_filename),
|
||||
)
|
||||
)
|
||||
if results:
|
||||
json_results.extend(results)
|
||||
|
||||
if json_results:
|
||||
sys.stdout.write(json.dumps(json_results))
|
||||
|
||||
if 'create' in arguments:
|
||||
try:
|
||||
for config_filename, config in configs.items():
|
||||
hooks = config.get('hooks', {})
|
||||
command.execute_hook(
|
||||
hooks.get('after_everything'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'post-everything',
|
||||
arguments['global'].dry_run,
|
||||
)
|
||||
except (CalledProcessError, ValueError, OSError) as error:
|
||||
yield from make_error_log_records('Error running post-everything hook', error)
|
||||
|
||||
|
||||
def exit_with_help_link(): # pragma: no cover
|
||||
'''
|
||||
Display a link to get help and exit with an error code.
|
||||
'''
|
||||
logger.critical('')
|
||||
logger.critical('Need some help? https://torsion.org/borgmatic/#issues')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(): # pragma: no cover
|
||||
configure_signals()
|
||||
|
||||
try:
|
||||
arguments = parse_arguments(*sys.argv[1:])
|
||||
except ValueError as error:
|
||||
configure_logging(logging.CRITICAL)
|
||||
logger.critical(error)
|
||||
exit_with_help_link()
|
||||
except SystemExit as error:
|
||||
if error.code == 0:
|
||||
raise error
|
||||
configure_logging(logging.CRITICAL)
|
||||
logger.critical('Error parsing arguments: {}'.format(' '.join(sys.argv)))
|
||||
exit_with_help_link()
|
||||
|
||||
global_arguments = arguments['global']
|
||||
if global_arguments.version:
|
||||
print(pkg_resources.require('borgmatic')[0].version)
|
||||
sys.exit(0)
|
||||
|
||||
config_filenames = tuple(collect.collect_config_filenames(global_arguments.config_paths))
|
||||
configs, parse_logs = load_configurations(config_filenames)
|
||||
|
||||
colorama.init(autoreset=True, strip=not should_do_markup(global_arguments.no_color, configs))
|
||||
configure_logging(
|
||||
verbosity_to_log_level(global_arguments.verbosity),
|
||||
verbosity_to_log_level(global_arguments.syslog_verbosity),
|
||||
)
|
||||
|
||||
logger.debug('Ensuring legacy configuration is upgraded')
|
||||
convert.guard_configuration_upgraded(LEGACY_CONFIG_PATH, config_filenames)
|
||||
|
||||
summary_logs = list(collect_configuration_run_summary_logs(configs, arguments))
|
||||
|
||||
logger.info('')
|
||||
logger.info('summary:')
|
||||
[
|
||||
logger.handle(log)
|
||||
for log in parse_logs + summary_logs
|
||||
if log.levelno >= logger.getEffectiveLevel()
|
||||
]
|
||||
|
||||
if any(log.levelno == logging.CRITICAL for log in summary_logs):
|
||||
exit_with_help_link()
|
||||
108
borgmatic/commands/convert_config.py
Normal file
108
borgmatic/commands/convert_config.py
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
import os
|
||||
import sys
|
||||
import textwrap
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from ruamel import yaml
|
||||
|
||||
from borgmatic.config import convert, generate, legacy, validate
|
||||
|
||||
DEFAULT_SOURCE_CONFIG_FILENAME = '/etc/borgmatic/config'
|
||||
DEFAULT_SOURCE_EXCLUDES_FILENAME = '/etc/borgmatic/excludes'
|
||||
DEFAULT_DESTINATION_CONFIG_FILENAME = '/etc/borgmatic/config.yaml'
|
||||
|
||||
|
||||
def parse_arguments(*arguments):
|
||||
'''
|
||||
Given command-line arguments with which this script was invoked, parse the arguments and return
|
||||
them as an ArgumentParser instance.
|
||||
'''
|
||||
parser = ArgumentParser(
|
||||
| ||||