dar-backup 1.0.0.1__py3-none-any.whl → 1.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dar_backup/README.md CHANGED
@@ -4,17 +4,19 @@
4
4
  **Reliable DAR backups, automated in clean Python**
5
5
 
6
6
  [![Codecov](https://codecov.io/gh/per2jensen/dar-backup/branch/main/graph/badge.svg)](https://codecov.io/gh/per2jensen/dar-backup)
7
- [![Snyk Vuln findings](https://snyk.io/test/github/per2jensen/dar-backup/badge.svg)](https://snyk.io/test/github/per2jensen/dar-backup)
7
+ [![Snyk Vuln findings](https://snyk.io/test/github/per2jensen/dar-backup/badge.svg)](https://security.snyk.io/vuln/?search=dar-backup)
8
8
  ![CI](https://github.com/per2jensen/dar-backup/actions/workflows/py-tests.yml/badge.svg)
9
9
  [![PyPI version](https://img.shields.io/pypi/v/dar-backup.svg)](https://pypi.org/project/dar-backup/)
10
10
  [![PyPI downloads](https://img.shields.io/badge/dynamic/json?color=blue&label=PyPI%20downloads&query=total&url=https%3A%2F%2Fraw.githubusercontent.com%2Fper2jensen%2Fdar-backup%2Fmain%2Fdownloads.json)](https://pypi.org/project/dar-backup/)
11
- [![# clones](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/per2jensen/dar-backup/main/v2/doc/badges/badge_clones.json)](https://github.com/per2jensen/dar-backup/blob/main/v2/doc/weekly_clones.png)
12
- [![Milestone](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/per2jensen/dar-backup/main/v2/doc/badges/milestone_badge.json)](https://github.com/per2jensen/dar-backup/blob/main/v2/doc/weekly_clones.png) <sub>🎯 Stats powered by [ClonePulse](https://github.com/per2jensen/clonepulse)</sub>
11
+ [![# clones](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/per2jensen/dar-backup/main/clonepulse/badge_clones.json)](https://github.com/per2jensen/dar-backup/blob/main/clonepulse/weekly_clones.png)
12
+ [![Milestone](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/per2jensen/dar-backup/main/clonepulse/milestone_badge.json)](https://github.com/per2jensen/dar-backup/blob/main/clonepulse/weekly_clones.png) <sub>🎯 Stats powered by [ClonePulse](https://github.com/per2jensen/clonepulse)</sub>
13
13
 
14
14
  The wonderful 'dar' [Disk Archiver](https://github.com/Edrusb/DAR) is used for
15
15
  the heavy lifting, together with the [parchive](https://github.com/Parchive/par2cmdline) suite in these scripts.
16
16
 
17
- This is the `Python` based [**version 2**](https://github.com/per2jensen/dar-backup/tree/main/v2) of `dar-backup`.
17
+ This is the `Python` based [**version 2**](v2) of `dar-backup`.
18
+
19
+ You can see the [v2 Changelog](v2/Changelog.md) for details on features and progress.
18
20
 
19
21
  ## TL;DR
20
22
 
@@ -28,6 +30,9 @@ Version **1.0.0** was reached on October 9, 2025.
28
30
  - [TL;DR](#tldr)
29
31
  - [Table of Contents](#table-of-contents)
30
32
  - [My use case](#my-use-case)
33
+ - [My setup](#my-setup)
34
+ - [Why PAR2 is especially good for portable / offsite copies](#why-par2-is-especially-good-for-portable--offsite-copies)
35
+ - [Design choices](#design-choices)
31
36
  - [Features](#features)
32
37
  - [License](#license)
33
38
  - [Quick Guide](#quick-guide)
@@ -71,6 +76,8 @@ Version **1.0.0** was reached on October 9, 2025.
71
76
  - [restore test fails with exit code 5](#restore-test-fails-with-exit-code-5)
72
77
  - [Par2](#par2)
73
78
  - [Par2 to verify/repair](#par2-to-verifyrepair)
79
+ - [Par2 files kept with archives](#par2-files-kept-with-archives)
80
+ - [Par2 files in separate directory](#par2-files-in-separate-directory)
74
81
  - [Par2 create redundancy files](#par2-create-redundancy-files)
75
82
  - [Points of interest](#points-of-interest)
76
83
  - [Limitations on File Names with Special Characters](#limitations-on-file-names-with-special-characters)
@@ -88,8 +95,8 @@ Version **1.0.0** was reached on October 9, 2025.
88
95
  - [Performance tip due to par2](#performance-tip-due-to-par2)
89
96
  - [.darrc sets -vd -vf (since v0.6.4)](#darrc-sets--vd--vf-since-v064)
90
97
  - [Separate log file for command output](#separate-log-file-for-command-output)
98
+ - [Trace Logging (Debug details)](#trace-logging-debug-details)
91
99
  - [Skipping cache directories](#skipping-cache-directories)
92
- - [Progress bar and current directory](#progress-bar-and-current-directory)
93
100
  - [Shell autocompletion](#shell-autocompletion)
94
101
  - [Use it](#use-it)
95
102
  - [Archive name completion (smart, context-aware)](#archive-name-completion-smart-context-aware)
@@ -103,12 +110,22 @@ Version **1.0.0** was reached on October 9, 2025.
103
110
  - [CLI Tools Overview](#cli-tools-overview)
104
111
  - [test coverage](#test-coverage)
105
112
  - [Dar-backup options](#dar-backup-options)
113
+ - [Dar-backup exit codes](#dar-backup-exit-codes)
114
+ - [Dar-backup env vars](#dar-backup-env-vars)
106
115
  - [Manager Options](#manager-options)
107
- - [Cleanup options](#cleanup-options)
116
+ - [Cleanup env vars](#cleanup-env-vars)
108
117
  - [Clean-log options](#clean-log-options)
109
118
  - [Dar-backup-systemd options](#dar-backup-systemd-options)
110
119
  - [Installer options](#installer-options)
111
120
  - [Demo options](#demo-options)
121
+ - [Config changes](#config-changes)
122
+ - [1.0.1](#101)
123
+ - [DISCORD WEBHOOK](#discord-webhook)
124
+ - [Restore test config](#restore-test-config)
125
+ - [Par2](#par2-1)
126
+ - [1.0.2](#102)
127
+ - [Trace Logging](#trace-logging)
128
+ - [Command output Capture](#command-output-capture)
112
129
 
113
130
  ## My use case
114
131
 
@@ -118,7 +135,7 @@ I needed the following:
118
135
  - Backup primarily photos, home made video and different types of documents
119
136
  - I have cloud storage mounted on a directory within my home dir. The filesystem is [FUSE based](https://www.kernel.org/doc/html/latest/filesystems/fuse.html), which gives it a few special features
120
137
 
121
- - Backup cloud storage (cloud is convenient, but I want control over my backups)
138
+ - Backup my cloud storage (cloud is convenient, but I want control over my backups)
122
139
  - A non-privileged user can perform a mount
123
140
  - A privileged user cannot look into the filesystem --> a backup script running as root is not suitable
124
141
 
@@ -129,6 +146,48 @@ I needed the following:
129
146
 
130
147
  I do not need the encryption features of dar, as all storage is already encrypted.
131
148
 
149
+ ## My setup
150
+
151
+ 1. Primary backup to server with an ext4 file system on mdadm RAID1
152
+
153
+ 2. Secondary copies to multiple USB disks / cloud
154
+
155
+ 3. Archive integrity verification anywhere using [Par2](#par2) and `dar -t`.
156
+
157
+ 4. Archive repair anywhere if needed. By default `dar-backup` creates par2 redundancy files with 5% coverage. Enough to fix localized bitrot.
158
+
159
+ 5. No dependency on original system
160
+
161
+ ### Why PAR2 is especially good for portable / offsite copies
162
+
163
+ PAR2 parity is:
164
+
165
+ > Self-contained (travels with the data)
166
+ >
167
+ >Format-agnostic (works on any filesystem)
168
+ >
169
+ >Location-agnostic (local disk, USB, cloud object storage)
170
+ >
171
+ >Tool-stable (PAR2 spec has not changed in years)
172
+ >
173
+ >That means:
174
+ >
175
+ >**Integrity protection moves with the archive**.
176
+
177
+ ### Design choices
178
+
179
+ My design choices are boring, proven and pragmatic:
180
+ >
181
+ >mdadm handles disks
182
+ >
183
+ >PAR2 handles data integrity
184
+ >
185
+ >You control when and how verification happens
186
+ >
187
+ >Errors have a fair chance of being diagnosed and fixed, due to well known tooling.
188
+ >
189
+ >No hidden magic, no lock-in
190
+
132
191
  ## Features
133
192
 
134
193
  - The battle tested [dar](https://github.com/Edrusb/DAR) Disk Archiver is used for the actual backups - it comes highly recommended.
@@ -151,7 +210,7 @@ I needed the following:
151
210
  ## License
152
211
 
153
212
  These scripts are licensed under the GPLv3 license.
154
- Read more here: [GNU GPL3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), or have a look at the ["LICENSE"](https://github.com/per2jensen/dar-backup/blob/main/LICENSE) file in this repository.
213
+ Read more here: [GNU GPL3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), or have a look at the ["LICENSE"](LICENSE) file in this repository.
155
214
 
156
215
  ## Quick Guide
157
216
 
@@ -496,7 +555,7 @@ This python version is v2 of dar-backup, v1 is made in bash.
496
555
 
497
556
  ## Community
498
557
 
499
- Please review the [Code of Conduct](https://github.com/per2jensen/dar-backup/blob/main/CODE_OF_CONDUCT.md) to help keep this project welcoming and focused.
558
+ Please review the [Code of Conduct](CODE_OF_CONDUCT.md) to help keep this project welcoming and focused.
500
559
 
501
560
  ## Requirements
502
561
 
@@ -516,7 +575,7 @@ On Ubuntu, install the requirements this way:
516
575
 
517
576
  ### dar-backup overview
518
577
 
519
- ![dar-backup overview](https://github.com/per2jensen/dar-backup/blob/main/v2/doc/dar-backup-overview.svg)
578
+ [![dar-backup overview](v2/doc/dar-backup-overview-small.png)](v2/doc/dar-backup-overview.png)
520
579
 
521
580
  ### dar-backup
522
581
 
@@ -545,6 +604,15 @@ The `cleanup` application deletes DIFF and INCR if the archives are older than t
545
604
 
546
605
  `cleanup` will only remove FULL archives if the option `--cleanup-specific-archives` is used. It requires the user to confirm deletion of FULL archives.
547
606
 
607
+ Use `--dry-run` to preview which archives, PAR2 files, and catalogs would be removed without deleting anything.
608
+
609
+ Examples:
610
+
611
+ ```bash
612
+ cleanup --dry-run -d media-files --log-stdout
613
+ cleanup --dry-run --cleanup-specific-archives -d media-files media-files_INCR_2025-12-22
614
+ ```
615
+
548
616
  ### manager
549
617
 
550
618
  `dar`has the concept of catalogs which can be exported and optionally be added to a catalog database. That database makes it much easier to restore the correct version of a backed up file if for example a target date has been set.
@@ -688,7 +756,7 @@ deactivate
688
756
 
689
757
  The configuration file's default location is: ~/.config/dar-backup/dar-backup.conf
690
758
 
691
- If you have your config file somewhere else, use the `--config` option to point to it.
759
+ If you have your config file somewhere else, use the `--config-file` option to point to it.
692
760
 
693
761
  Tilde `~` and environment variables can be used in the paths for various file locations.
694
762
 
@@ -724,6 +792,17 @@ INCR_AGE = 40
724
792
  [PAR2]
725
793
  ERROR_CORRECTION_PERCENT = 5
726
794
  ENABLED = True
795
+ # Optional PAR2 configuration
796
+ # PAR2_DIR = /path/to/par2-store
797
+ # PAR2_RATIO_FULL = 10
798
+ # PAR2_RATIO_DIFF = 5
799
+ # PAR2_RATIO_INCR = 5
800
+ # PAR2_RUN_VERIFY = false
801
+
802
+ # Optional per-backup overrides (section name = backup definition)
803
+ [media-files]
804
+ PAR2_DIR = /mnt/par2/media-files
805
+ PAR2_RATIO_FULL = 10
727
806
 
728
807
  # scripts to run before the backup to setup the environment
729
808
  [PREREQ]
@@ -735,6 +814,16 @@ SCRIPT_1 = df -h
735
814
  #SCRIPT_2 = another_script.sh
736
815
  ```
737
816
 
817
+ PAR2 notes:
818
+
819
+ - If `PAR2_DIR` is unset, par2 files are created next to the archive slices (legacy behavior) and no manifest is written
820
+ - When `PAR2_DIR` is set, dar-backup writes a manifest next to the par2 set:
821
+ `archive_base.par2.manifest.ini`
822
+ - When generating a par2 set, par2 reads all archive slices before writing any output files; for large backups, this initial read can take hours
823
+ - Verify or repair using:
824
+ `par2 verify -B <archive_dir> <par2_set.par2>`
825
+ `par2 repair -B <archive_dir> <par2_set.par2>`
826
+
738
827
  ### .darrc
739
828
 
740
829
  The package includes a default `darrc` file which configures `dar`.
@@ -1056,6 +1145,25 @@ This happens when the shell splits the quoted string or interprets globs before
1056
1145
 
1057
1146
  > 💡 **Tip:** See [dar's documentation](http://dar.linux.free.fr/doc/man/dar.html#COMMANDS%20AND%20OPTIONS)
1058
1147
 
1148
+ >
1149
+ > 💡💡 **Tip:** To filter all the empty directories away that `dar` emits when listing contents, append this grep:
1150
+ >
1151
+ > ```bash
1152
+ > |grep -vE '\s+d[rwx-]{9}\s'
1153
+ >```
1154
+ >
1155
+ >Example using the grep to discard directory noise from `dar's` output:
1156
+ >
1157
+ > ```bash
1158
+ > dar-backup --list-contents media-files_INCR_2025-05-10 --selection="-I '*Z50*' -X '*.xmp'" | grep -vE '\s+d[rwx-]{9}\s'
1159
+ >[Saved][ ] [-L-][ 0%][X] -rw-rw-r-- user user 26 Mio Fri May 9 11:26:16 2025 home/user/data/2025/2025-05-09-Roskilde-Nordisk-udstilling/Z50_0633.NEF
1160
+ >[Saved][ ] [-L-][ 0%][X] -rw-rw-r-- user user 26 Mio Fri May 9 11:26:16 2025 home/user/data/2025/2025-05-09-Roskilde-Nordisk-udstilling/Z50_0632.NEF
1161
+ >[Saved][ ] [-L-][ 0%][X] -rw-rw-r-- user user 28 Mio Fri May 9 11:09:04 2025 home/user/data/2025/2025-05-09-Roskilde-Nordisk-udstilling/Z50_0631.NEF
1162
+ >[Saved][ ] [-L-][ 0%][X] -rw-rw-r-- user user 29 Mio Fri May 9 11:09:03 2025 home/user/data/2025/2025-05-09-Roskilde-Nordisk-udstilling/Z50_0630.NEF
1163
+ >[Saved][ ] [-L-][ 0%][X] -rw-rw-r-- user user 29 Mio Fri May 9 11:09:03 2025 home/user/data/2025/2025-05-09-Roskilde-Nordisk-udstilling/Z50_0629.NEF
1164
+ >...
1165
+ >```
1166
+
1059
1167
  ### select a directory
1060
1168
 
1061
1169
  Select files and sub directories in `home/user/data/2025/2025-05-09-Roskilde-Nordisk-udstilling`
@@ -1182,9 +1290,39 @@ If you need to use this option, un-comment it in the [.darrc](#darrc) file (loca
1182
1290
 
1183
1291
  ## Par2
1184
1292
 
1293
+ Why keep PAR2 on a different storage device:
1294
+
1295
+ - Reduces single-disk failure impact: bitrot on the archive disk does not affect the parity.
1296
+ - Easier offsite rotation: you can sync only the PAR2 sets to a different failure domain.
1297
+
1298
+ Redundancy guidance:
1299
+
1300
+ - FULL backups: 10% is a practical default for larger data sets and longer retention.
1301
+ - DIFF/INCR: 5% is often enough because the delta is smaller and easier to re-create.
1302
+ - Increase the ratio if the storage is flaky or the backup is hard to re-run.
1303
+
1304
+ Rule of thumb table:
1305
+
1306
+ | Backup type | Suggested PAR2 ratio | Notes |
1307
+ |-------------|----------------------|-------|
1308
+ | FULL | 10% | Longer retention, larger data set |
1309
+ | DIFF | 5% | Smaller delta |
1310
+ | INCR | 5% | Smaller delta |
1311
+
1312
+ >
1313
+ >For large, contiguous archives on reliable local storage, 7–8% has proven sufficient in practice; 10% remains a conservative default.
1314
+ >
1315
+
1316
+ Cloud sync / air-gap note:
1317
+
1318
+ - Syncing PAR2 sets to a different device or remote store protects against bitrot and small corruption, but it cannot recover a completely lost archive.
1319
+ - An air-gapped PAR2 store is useful when the archive disk is exposed to ransomware or accidental deletion.
1320
+
1185
1321
  ### Par2 to verify/repair
1186
1322
 
1187
- You can run a par2 verification on an archive like this:
1323
+ #### Par2 files kept with archives
1324
+
1325
+ If PAR2 files are stored next to the archives (legacy per-slice behavior), you can verify like this:
1188
1326
 
1189
1327
  ```bash
1190
1328
  for file in <archive>*.dar.par2; do
@@ -1198,6 +1336,14 @@ if there are problems with a slice, try to repair it like this:
1198
1336
  par2 repair <archive>.<slice number>.dar.par2
1199
1337
  ```
1200
1338
 
1339
+ #### Par2 files in separate directory
1340
+
1341
+ See [docs on disk layout matters](v2/doc/portable-par2-layout.md)
1342
+
1343
+ >Test case proving this flow:
1344
+ >
1345
+ >[tests/test_par2_manifest.py](v2/tests/test_par2_manifest.py)
1346
+
1201
1347
  ### Par2 create redundancy files
1202
1348
 
1203
1349
  If you have merged archives, you will need to create the .par2 redundency files manually.
@@ -1211,6 +1357,15 @@ done
1211
1357
 
1212
1358
  where "c" is create, -r5 is 5% redundency and -n1 is 1 redundency file
1213
1359
 
1360
+ If you want to create a single parity set for all slices in an archive:
1361
+
1362
+ ```bash
1363
+ par2 create -B <archive_dir> -r5 <par2_dir>/<archive_base>.par2 <archive_dir>/<archive_base>.*.dar
1364
+ ```
1365
+
1366
+ **OBSERVE** [docs on disk layout matters](v2/doc/portable-par2-layout.md)
1367
+
1368
+
1214
1369
  ## Points of interest
1215
1370
 
1216
1371
  ### Limitations on File Names with Special Characters
@@ -1365,23 +1520,29 @@ In order to not clutter that log file with the output of commands being run, a n
1365
1520
 
1366
1521
  The secondary log file can get quite cluttered, if you want to remove the clutter, run the `clean-log`script with the `--file` option, or simply delete it.
1367
1522
 
1368
- ### Skipping cache directories
1523
+ ### Trace Logging (Debug details)
1369
1524
 
1370
- The author uses the `--cache-directory-tagging` option in his [backup definitions](#backup-definition-example).
1525
+ To keep the main log file clean while preserving essential debugging information, `dar-backup` creates a separate trace log file (e.g., `dar-backup.trace.log`) alongside the main log.
1371
1526
 
1372
- The effect is that directories with the [CACHEDIR.TAG](https://bford.info/cachedir/) file are not backed up. Those directories contain content fetched from the net, which is of an ephemeral nature and probably not what you want to back up.
1527
+ - **Main Log (`dar-backup.log`)**: Contains clean, human-readable INFO/ERROR messages. Stack traces are suppressed here.
1528
+ - **Trace Log (`dar-backup.trace.log`)**: Captures ALL messages at `DEBUG` level, including full exception stack traces. Use this file for debugging crashes or unexpected behavior.
1373
1529
 
1374
- If the option is not in the backup definition, the cache directories are backed up as any other.
1530
+ You can configure the rotation of this file in `[MISC]`:
1531
+
1532
+ ```ini
1533
+ [MISC]
1534
+ # ... other settings ...
1535
+ TRACE_LOG_MAX_BYTES = 10485760 # 10 MB default
1536
+ TRACE_LOG_BACKUP_COUNT = 1 # Keep 1 old trace file (default)
1537
+ ```
1375
1538
 
1376
- ### Progress bar and current directory
1539
+ ### Skipping cache directories
1377
1540
 
1378
- If you run dar-backup interactively in a "normal" console on your computer,
1379
- dar-backup displays 2 visual artifacts to show progress.
1541
+ The author uses the `--cache-directory-tagging` option in his [backup definitions](#backup-definition-example).
1380
1542
 
1381
- 1. a progress bar that fills up and starts over
1382
- 2. a status line showing the directory being backed up. If the directory is big and takes time to backup, the line is not changing, but you will probably know there is a lot to backup.
1543
+ The effect is that directories with the [CACHEDIR.TAG](https://bford.info/cachedir/) file are not backed up. Those directories contain content fetched from the net, which is of an ephemeral nature and probably not what you want to back up.
1383
1544
 
1384
- The indicators are not shown if dar-backup is run from systemd or if it is used in terminal multiplexers like `tmux` or `screen`. So no polluting of journald logs.
1545
+ If the option is not in the backup definition, the cache directories are backed up as any other.
1385
1546
 
1386
1547
  ### Shell autocompletion
1387
1548
 
@@ -1566,7 +1727,6 @@ pytest # run the test suite
1566
1727
 
1567
1728
  - Perhaps look into pre-processing backup definitions. As `dar` does not expand env vars
1568
1729
  `dar-backup` could do so and feed the result to `dar`.
1569
- - When run interactively, a progress bar during test and par2 generation would be nice.
1570
1730
  - Look into a way to move the .par2 files away from the `dar` slices, to maximize chance of good redundancy.
1571
1731
  - Add option to dar-backup to use the `dar` option `--fsa-scope none`
1572
1732
 
@@ -1591,15 +1751,15 @@ One backup definition per file
1591
1751
 
1592
1752
  ### CLI Tools Overview
1593
1753
 
1594
- | Command | Description |
1595
- |----------------------|-------------------------------------------|
1596
- | [dar-backup](#dar-backup-options)| Perform full, differential, or incremental backups with verification and restore testing |
1597
- | [manager](#manager-options) | Maintain and query catalog databases for archives |
1598
- | [cleanup](#cleanup-options) | Remove outdated DIFF/INCR archives (and optionally FULLs) |
1599
- | [clean-log](#clean-log-options) | Clean up excessive log output from dar command logs |
1754
+ | Command | Description |
1755
+ | --- | --- |
1756
+ | [dar-backup](#dar-backup-options) | Perform full, differential, or incremental backups with verification and restore testing |
1757
+ | [manager](#manager-options) | Maintain and query catalog databases for archives |
1758
+ | [cleanup](#cleanup-options) | Remove outdated DIFF/INCR archives (and optionally FULLs) |
1759
+ | [clean-log](#clean-log-options) | Clean up excessive log output from dar command logs |
1600
1760
  | [dar-backup-systemd](#dar-backup-systemd-options) | Generate (and optionally install) systemd timers and services for automated backups |
1601
- | [installer](#installer-options) | Set up directories and optionally create catalog databases according to a config file |
1602
- | [demo](#demo-options) | Set up required directories and config files for a demo|
1761
+ | [installer](#installer-options) | Set up directories and optionally create catalog databases according to a config file |
1762
+ | [demo](#demo-options) | Set up required directories and config files for a demo|
1603
1763
 
1604
1764
  ### test coverage
1605
1765
 
@@ -1654,6 +1814,7 @@ Available options:
1654
1814
  --examples Show examples of using dar-backup.py.
1655
1815
  -l, --list List available backups.
1656
1816
  --list-contents <archive> List the contents of a specified archive.
1817
+ --list-definitions List backup definitions from BACKUP.D_DIR.
1657
1818
  --selection <params> Define file selection for listing/restoring.
1658
1819
  --restore <archive> Restore a specified archive.
1659
1820
  -r, --restore <archive> Restore archive.
@@ -1663,6 +1824,7 @@ Available options:
1663
1824
  --log-level <level> `debug` or `trace`, default is `info`.
1664
1825
  --log-stdout Also print log messages to stdout.
1665
1826
  --do-not-compare Do not compare restores to file system.
1827
+ --preflight-check Run preflight checks and exit (runs automatically; this flag just exits after checks).
1666
1828
  --examples Show examples of using dar-backup.
1667
1829
  --readme Print README.md and exit
1668
1830
  --readme-pretty Print README.md with Markdown styling and exit
@@ -1671,6 +1833,22 @@ Available options:
1671
1833
  -v, --version Show version and license information.
1672
1834
  ```
1673
1835
 
1836
+ #### Dar-backup exit codes
1837
+
1838
+ - 0: Success.
1839
+ - 1: Error (backup/restore/preflight failure).
1840
+ - 2: Warning (restore test failed or backup already exists and is skipped).
1841
+ - 127: Typically an error during startup, file or config value missing
1842
+ - if the `dar -t` test fails, exit code 1 is emitted
1843
+ - restore tests could fail if the source file has changed after the backup
1844
+
1845
+ #### Dar-backup env vars
1846
+
1847
+ | Env var | Value | Description |
1848
+ | --- | --- | --- |
1849
+ | DAR_BACKUP_CONFIG_FILE | Full path to config file | Overrides built-in default, overridden by --config-file |
1850
+ | DAR_BACKUP_DISCORD_WEBHOOK_URL | https://discord.com/api/webhooks/\<userID\>/\<webhook UUID\> | The full url |
1851
+
1674
1852
  ### Manager Options
1675
1853
 
1676
1854
  This script manages `dar` databases and catalogs.
@@ -1690,7 +1868,12 @@ Available options:
1690
1868
  --find-file <file> Search catalogs for a specific file.
1691
1869
  --verbose Enable verbose output.
1692
1870
  --log-level <level> Set log level (`debug` or `trace`, default is `info`).
1693
- ```
1871
+
1872
+ #### Manager env vars
1873
+
1874
+ | Env var | Value | Description |
1875
+ | --- | --- | --- |
1876
+ | DAR_BACKUP_CONFIG_FILE | path to the config file | Default is $HOME/.config/dar-backup/dar-backup.conf |```
1694
1877
 
1695
1878
  ### Cleanup options
1696
1879
 
@@ -1707,12 +1890,19 @@ Supported options:
1707
1890
  --alternate-archive-dir Clean up in this directory instead of the default one.
1708
1891
  --cleanup-specific-archives "<archive>, <>, ..." Comma separated list of archives to cleanup.
1709
1892
  -l, --list List available archives (filter using the -d option).
1893
+ --dry-run Show what would be deleted without removing files.
1710
1894
  --verbose Print various status messages to screen.
1711
1895
  --log-level <level> `debug` or `trace`, default is `info`", default="info".
1712
1896
  --log-stdout Print log messages to stdout.
1713
1897
  --test-mode This is used when running pytest test cases
1714
1898
  ```
1715
1899
 
1900
+ #### Cleanup env vars
1901
+
1902
+ | Env var | Value | Description |
1903
+ | --- | --- | --- |
1904
+ | DAR_BACKUP_CONFIG_FILE | path to the config file | Default is $HOME/.config/dar-backup/dar-backup.conf |
1905
+
1716
1906
  ### Clean-log options
1717
1907
 
1718
1908
  This script removes excessive logging output from `dar` logs, improving readability and efficiency. Available options:
@@ -1762,8 +1952,8 @@ Create directories:
1762
1952
  - ~/.config/dar-backup/
1763
1953
  - ~/.config/dar-backup/backup.d/
1764
1954
  - ~/dar-backup/
1765
- - ~/dar-backup/backups
1766
- - ~/dar-backup/restore
1955
+ - ~/dar-backup/backups/
1956
+ - ~/dar-backup/restore/
1767
1957
 
1768
1958
  Sets up demo config files:
1769
1959
 
@@ -1782,3 +1972,134 @@ Sets up demo config files:
1782
1972
  -v, --version Display version and licensing information.
1783
1973
  -h, --help Displays usage info
1784
1974
  ```
1975
+
1976
+ ### Config changes
1977
+
1978
+ #### 1.0.1
1979
+
1980
+ ##### DISCORD WEBHOOK
1981
+
1982
+ For Discord notifications use the `DAR_BACKUP_DISCORD_WEBHOOK_URL` environment variable. It should not be placed in the config file.
1983
+
1984
+ DAR_BACKUP_DISCORD_WEBHOOK_URL is the entire endpoint like this:
1985
+
1986
+ ```bash
1987
+ export DAR_BACKUP_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/\<userId\>/\<uuid\>
1988
+ ```
1989
+
1990
+ ##### Restore test config
1991
+
1992
+ Restore tests choose random files from the archive and compare them with the live filesystem.
1993
+ To avoid noisy paths (caches, temp files, logs), you can exclude candidates before the random
1994
+ selection happens. All matching is case-insensitive.
1995
+
1996
+ Config keys (in [MISC]):
1997
+
1998
+ - RESTORETEST_EXCLUDE_PREFIXES: comma-separated path prefixes to skip. Matches from the start of
1999
+ the path (after trimming a leading "/"). Use trailing "/" for directories.
2000
+ - RESTORETEST_EXCLUDE_SUFFIXES: comma-separated filename suffixes to skip.
2001
+ - RESTORETEST_EXCLUDE_REGEX: optional regex to skip anything matching the path.
2002
+
2003
+ Example:
2004
+
2005
+ ```ini
2006
+ [MISC]
2007
+ RESTORETEST_EXCLUDE_PREFIXES = .cache/, .local/share/Trash/, .mozilla/, snap/firefox/common/.mozilla/
2008
+ RESTORETEST_EXCLUDE_SUFFIXES = .sqlite-wal, .sqlite-shm, .log, .tmp, .lock, .journal
2009
+ RESTORETEST_EXCLUDE_REGEX = (^|/)(Cache|cache|Logs|log)/
2010
+ ```
2011
+
2012
+ Regex tips (case-insensitive):
2013
+
2014
+ - Match common cache/log directories anywhere:
2015
+ `(^|/)(cache|logs)/`
2016
+ - Skip thumbnails and temp dirs:
2017
+ `(^|/)(thumbnails|tmp|temp)/`
2018
+ - Exclude browser profile noise while keeping other files:
2019
+ `(^|/)\.mozilla/|/snap/firefox/common/\.mozilla/`
2020
+
2021
+ ##### Par2
2022
+
2023
+ New optional PAR2 settings were added to the config file. If none of these keys are added, dar-backup behaves exactly as before (PAR2 files next to archives, per-slice parity).
2024
+
2025
+ | Name | Description | When it is in effect | Suggested value |
2026
+ |------|-------------|----------------------|-----------------|
2027
+ | PAR2_DIR | Directory to store .par2 and .vol*.par2 files | When set | A different device or mount from BACKUP_DIR |
2028
+ | PAR2_RATIO_FULL | Redundancy percent for FULL | When set | 10 (%) |
2029
+ | PAR2_RATIO_DIFF | Redundancy percent for DIFF | When set | 5 (%)|
2030
+ | PAR2_RATIO_INCR | Redundancy percent for INCR | When set | 5 (%)|
2031
+ | PAR2_RUN_VERIFY | Verify after create | When set | false |
2032
+
2033
+ Notes:
2034
+
2035
+ - PAR2_RATIO_*, and PAR2_RUN_VERIFY apply even if PAR2_DIR is not set (i.e. par2 output stays next to the archives).
2036
+
2037
+ Per-backup overrides use a section named after the backup definition with the same PAR2_* keys:
2038
+
2039
+ ```text
2040
+
2041
+ ######################################################################
2042
+ # Per-backup configuration example overrides
2043
+ ######################################################################
2044
+
2045
+ # --------------------------------------------------------------------
2046
+ # Per-backup overrides (section name must match backup.d filename stem)
2047
+ # Example: backup.d/home.conf -> [home]
2048
+ # --------------------------------------------------------------------
2049
+
2050
+ #[home]
2051
+ # Disable PAR2 entirely for this backup definition
2052
+ PAR2_ENABLED = false
2053
+ #
2054
+ #[media]
2055
+ # Store PAR2 files in a separate location for this backup definition
2056
+ #PAR2_DIR = /samba/par2/media
2057
+ # Raise redundancy only for FULL
2058
+ #
2059
+ [documents]
2060
+ # Run verify par2 sets after creation
2061
+ PAR2_RUN_VERIFY = true
2062
+ #
2063
+ #[etc]
2064
+ # Keep global PAR2 settings but tweak ratios for this backup definition
2065
+ # RATIO is given in percent (%)
2066
+ #PAR2_RATIO_FULL = 15
2067
+ #PAR2_RATIO_DIFF = 8
2068
+ #PAR2_RATIO_INCR = 8
2069
+ ```
2070
+
2071
+ [Per-backup override test case: `tests/test_par2_overrides.py`](v2/tests/test_par2_overrides.py)
2072
+
2073
+ #### 1.0.2
2074
+
2075
+ ##### Trace Logging
2076
+
2077
+ To support debugging without cluttering the main log file, a secondary trace log is now created (e.g., `dar-backup.trace.log`).
2078
+ This file captures all `DEBUG` level messages and full exception stack traces.
2079
+
2080
+ You can configure its rotation in the `[MISC]` section:
2081
+
2082
+ - `TRACE_LOG_MAX_BYTES`: Max size of the trace log file in bytes. Default is `10485760` (10 MB).
2083
+ - `TRACE_LOG_BACKUP_COUNT`: Number of rotated trace log files to keep. Default is `1`.
2084
+
2085
+ Example:
2086
+
2087
+ ```ini
2088
+ [MISC]
2089
+ TRACE_LOG_MAX_BYTES = 10485760
2090
+ TRACE_LOG_BACKUP_COUNT = 1
2091
+ ```
2092
+
2093
+ ##### Command output Capture
2094
+
2095
+ - New optional `[MISC]` setting: `COMMAND_CAPTURE_MAX_BYTES` (default 102400).
2096
+ - Limits how much stdout/stderr is kept in memory per command while still logging full output.
2097
+ - Set to `0` to disable buffering entirely. Command output is still streamed to dar-backup-commands.log
2098
+ - If set to `0`, the calling function cannot rely on output from the executed command. The exit value is the only result provided.
2099
+
2100
+ Example:
2101
+
2102
+ ```ini
2103
+ [MISC]
2104
+ COMMAND_CAPTURE_MAX_BYTES = 102400
2105
+ ```
dar_backup/__about__.py CHANGED
@@ -1,6 +1,7 @@
1
- __version__ = "1.0.0.1"
1
+ __version__ = "1.0.2"
2
+
3
+ __author__ = "Per Jensen"
2
4
 
3
5
  __license__ = '''Licensed under GNU GENERAL PUBLIC LICENSE v3, see the supplied file "LICENSE" for details.
4
6
  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5
7
  See section 15 and section 16 in the supplied "LICENSE" file.'''
6
-