dar-backup 1.0.0.1__py3-none-any.whl → 1.0.1__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/Changelog.md +35 -1
- dar_backup/README.md +283 -22
- dar_backup/__about__.py +3 -1
- dar_backup/cleanup.py +153 -38
- dar_backup/command_runner.py +135 -102
- dar_backup/config_settings.py +143 -0
- dar_backup/dar-backup.conf +11 -0
- dar_backup/dar-backup.conf.j2 +42 -0
- dar_backup/dar_backup.py +391 -90
- dar_backup/manager.py +9 -3
- dar_backup/util.py +383 -130
- {dar_backup-1.0.0.1.dist-info → dar_backup-1.0.1.dist-info}/METADATA +284 -23
- dar_backup-1.0.1.dist-info/RECORD +25 -0
- {dar_backup-1.0.0.1.dist-info → dar_backup-1.0.1.dist-info}/WHEEL +1 -1
- dar_backup-1.0.0.1.dist-info/RECORD +0 -25
- {dar_backup-1.0.0.1.dist-info → dar_backup-1.0.1.dist-info}/entry_points.txt +0 -0
- {dar_backup-1.0.0.1.dist-info → dar_backup-1.0.1.dist-info}/licenses/LICENSE +0 -0
dar_backup/Changelog.md
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
<!-- markdownlint-disable MD024 -->
|
|
2
2
|
# dar-backup Changelog
|
|
3
3
|
|
|
4
|
+
## v2-1.0.1 - 2026-01-09
|
|
5
|
+
|
|
6
|
+
### Added
|
|
7
|
+
|
|
8
|
+
- Cleanup `--dry-run` to preview archive, PAR2, and catalog deletions.
|
|
9
|
+
- Completion: `cleanup` supports comma-separated archive lists with whitespace normalization.
|
|
10
|
+
- Completion: `cleanup` now offers archive-only suggestions after `--cleanup-specific-archives`.
|
|
11
|
+
- Tests for completion list parsing and cleanup dry-run.
|
|
12
|
+
- Optional Discord webhook notifications: `send_discord_message` helper with config-over-env precedence (`DAR_BACKUP_DISCORD_WEBHOOK_URL`), JSON payload, timeout, and detailed error logging (HTTP body).
|
|
13
|
+
- Backup runs now emit a per-backup-definition status message (`YYYY-MM-DD_HH:MM - dar-backup, <backup definition>: SUCCESS|FAILURE`).
|
|
14
|
+
- dar-backup `--list-definitions` option to list backup definitions from `BACKUP.D_DIR`.
|
|
15
|
+
- Test coverage: webhook unit tests plus optional live Discord test (guarded by `live_discord` marker).
|
|
16
|
+
- Automatic preflight checks now run before every invocation (or standalone via `--preflight-check`) to verify required directories, write access, and availability of `dar`/`par2` binaries.
|
|
17
|
+
- PAR2 enhancements: optional PAR2_DIR storage, per-archive parity mode, per-backup overrides, and parity manifests to support verify/repair against archives in a different directory.
|
|
18
|
+
- New tests for PAR2_DIR + per-archive verify/repair flow, per-backup overrides.
|
|
19
|
+
- Documentation: new config options and per-backup overrides are documented in the README “Config changes” section.
|
|
20
|
+
- Restore test filters: optional case-insensitive prefix/suffix/regex exclusions for restore-test file sampling, plus a dedicated unit test.
|
|
21
|
+
- Env var `DAR_BACKUP_CONFIG_FILE` now supported.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Completion: `dar-backup -l -d <def>` and `cleanup --cleanup-specific-archives -d <def>` now narrow archive suggestions by definition and prefix.
|
|
26
|
+
- Pytest defaults exclude live Discord tests; enable with `-m live_discord` when a webhook is available.
|
|
27
|
+
- Skip Discord notifications for the demo/example backup definition to avoid spam during sample runs.
|
|
28
|
+
- Discord backup status now includes WARNING when a backup is skipped because it already exists.
|
|
29
|
+
- Completer logging now uses a per-user logfile and falls back safely if the completer logger setup fails.
|
|
30
|
+
- Verification failures and existing-backup skips now emit exit code 2 (warning), while errors continue to emit exit code 1.
|
|
31
|
+
- Cleanup deletion hardening (Snyk): validate archive names and enforce safe, base-dir-bound file deletions.
|
|
32
|
+
- Snyk badge links to [Snyk dar-backup page](https://security.snyk.io/vuln/?search=dar-backup)
|
|
33
|
+
- Removed the rich progress bar wrapper from backup/verify runs to simplify core execution.
|
|
34
|
+
- PAR2 tests now align with per-archive parity flow (single create command, repair via `.par2` set).
|
|
35
|
+
- Slice-order test reads slice numbers from the logged `par2 create` command output.
|
|
36
|
+
- CommandRunner now restores terminal attributes after subprocesses and runs with stdin set to `/dev/null` by default to avoid terminal echo issues.
|
|
37
|
+
|
|
4
38
|
## v2-1.0.0 - 2025-10-09
|
|
5
39
|
|
|
6
40
|
Github link: [v2-1.0.0](https://github.com/per2jensen/dar-backup/tree/v2-1.0.0/v2)
|
|
@@ -364,4 +398,4 @@ Github link: [v2-alpha-0.6.0](https://github.com/per2jensen/dar-backup/tree/v2-a
|
|
|
364
398
|
- FIX: ensure run_command() works correctly when a command writes a lot of data to stdout
|
|
365
399
|
- updated README with details on --restore-dir option
|
|
366
400
|
|
|
367
|
-
<!-- markdownlint-enable MD024 -->
|
|
401
|
+
<!-- markdownlint-enable MD024 -->
|
dar_backup/README.md
CHANGED
|
@@ -4,17 +4,19 @@
|
|
|
4
4
|
**Reliable DAR backups, automated in clean Python**
|
|
5
5
|
|
|
6
6
|
[](https://codecov.io/gh/per2jensen/dar-backup)
|
|
7
|
-
[](https://snyk.io/
|
|
7
|
+
[](https://security.snyk.io/vuln/?search=dar-backup)
|
|
8
8
|

|
|
9
9
|
[](https://pypi.org/project/dar-backup/)
|
|
10
10
|
[](https://pypi.org/project/dar-backup/)
|
|
11
|
-
[](https://github.com/per2jensen/dar-backup/blob/main/clonepulse/weekly_clones.png)
|
|
12
|
+
[](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**](
|
|
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)
|
|
@@ -103,12 +110,19 @@ 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
|
-
|
|
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)
|
|
112
126
|
|
|
113
127
|
## My use case
|
|
114
128
|
|
|
@@ -118,7 +132,7 @@ I needed the following:
|
|
|
118
132
|
- Backup primarily photos, home made video and different types of documents
|
|
119
133
|
- 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
134
|
|
|
121
|
-
- Backup cloud storage (cloud is convenient, but I want control over my backups)
|
|
135
|
+
- Backup my cloud storage (cloud is convenient, but I want control over my backups)
|
|
122
136
|
- A non-privileged user can perform a mount
|
|
123
137
|
- A privileged user cannot look into the filesystem --> a backup script running as root is not suitable
|
|
124
138
|
|
|
@@ -129,6 +143,48 @@ I needed the following:
|
|
|
129
143
|
|
|
130
144
|
I do not need the encryption features of dar, as all storage is already encrypted.
|
|
131
145
|
|
|
146
|
+
## My setup
|
|
147
|
+
|
|
148
|
+
1. Primary backup to server with an ext4 file system on mdadm RAID1
|
|
149
|
+
|
|
150
|
+
2. Secondary copies to multiple USB disks / cloud
|
|
151
|
+
|
|
152
|
+
3. Archive integrity verification anywhere using [Par2](#par2) and `dar -t`.
|
|
153
|
+
|
|
154
|
+
4. Archive repair anywhere if needed. By default `dar-backup` creates par2 redundancy files with 5% coverage. Enough to fix localized bitrot.
|
|
155
|
+
|
|
156
|
+
5. No dependency on original system
|
|
157
|
+
|
|
158
|
+
### Why PAR2 is especially good for portable / offsite copies
|
|
159
|
+
|
|
160
|
+
PAR2 parity is:
|
|
161
|
+
|
|
162
|
+
> Self-contained (travels with the data)
|
|
163
|
+
>
|
|
164
|
+
>Format-agnostic (works on any filesystem)
|
|
165
|
+
>
|
|
166
|
+
>Location-agnostic (local disk, USB, cloud object storage)
|
|
167
|
+
>
|
|
168
|
+
>Tool-stable (PAR2 spec has not changed in years)
|
|
169
|
+
>
|
|
170
|
+
>That means:
|
|
171
|
+
>
|
|
172
|
+
>**Integrity protection moves with the archive**.
|
|
173
|
+
|
|
174
|
+
### Design choices
|
|
175
|
+
|
|
176
|
+
My design choices are boring, proven and pragmatic:
|
|
177
|
+
>
|
|
178
|
+
>mdadm handles disks
|
|
179
|
+
>
|
|
180
|
+
>PAR2 handles data integrity
|
|
181
|
+
>
|
|
182
|
+
>You control when and how verification happens
|
|
183
|
+
>
|
|
184
|
+
>Errors have a fair chance of being diagnosed and fixed, due to well known tooling.
|
|
185
|
+
>
|
|
186
|
+
>No hidden magic, no lock-in
|
|
187
|
+
|
|
132
188
|
## Features
|
|
133
189
|
|
|
134
190
|
- The battle tested [dar](https://github.com/Edrusb/DAR) Disk Archiver is used for the actual backups - it comes highly recommended.
|
|
@@ -151,7 +207,7 @@ I needed the following:
|
|
|
151
207
|
## License
|
|
152
208
|
|
|
153
209
|
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"](
|
|
210
|
+
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
211
|
|
|
156
212
|
## Quick Guide
|
|
157
213
|
|
|
@@ -496,7 +552,7 @@ This python version is v2 of dar-backup, v1 is made in bash.
|
|
|
496
552
|
|
|
497
553
|
## Community
|
|
498
554
|
|
|
499
|
-
Please review the [Code of Conduct](
|
|
555
|
+
Please review the [Code of Conduct](CODE_OF_CONDUCT.md) to help keep this project welcoming and focused.
|
|
500
556
|
|
|
501
557
|
## Requirements
|
|
502
558
|
|
|
@@ -516,7 +572,7 @@ On Ubuntu, install the requirements this way:
|
|
|
516
572
|
|
|
517
573
|
### dar-backup overview
|
|
518
574
|
|
|
519
|
-
](v2/doc/dar-backup-overview.png)
|
|
520
576
|
|
|
521
577
|
### dar-backup
|
|
522
578
|
|
|
@@ -545,6 +601,15 @@ The `cleanup` application deletes DIFF and INCR if the archives are older than t
|
|
|
545
601
|
|
|
546
602
|
`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
603
|
|
|
604
|
+
Use `--dry-run` to preview which archives, PAR2 files, and catalogs would be removed without deleting anything.
|
|
605
|
+
|
|
606
|
+
Examples:
|
|
607
|
+
|
|
608
|
+
```bash
|
|
609
|
+
cleanup --dry-run -d media-files --log-stdout
|
|
610
|
+
cleanup --dry-run --cleanup-specific-archives -d media-files media-files_INCR_2025-12-22
|
|
611
|
+
```
|
|
612
|
+
|
|
548
613
|
### manager
|
|
549
614
|
|
|
550
615
|
`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 +753,7 @@ deactivate
|
|
|
688
753
|
|
|
689
754
|
The configuration file's default location is: ~/.config/dar-backup/dar-backup.conf
|
|
690
755
|
|
|
691
|
-
If you have your config file somewhere else, use the `--config` option to point to it.
|
|
756
|
+
If you have your config file somewhere else, use the `--config-file` option to point to it.
|
|
692
757
|
|
|
693
758
|
Tilde `~` and environment variables can be used in the paths for various file locations.
|
|
694
759
|
|
|
@@ -724,6 +789,19 @@ INCR_AGE = 40
|
|
|
724
789
|
[PAR2]
|
|
725
790
|
ERROR_CORRECTION_PERCENT = 5
|
|
726
791
|
ENABLED = True
|
|
792
|
+
# Optional PAR2 configuration
|
|
793
|
+
# PAR2_DIR = /path/to/par2-store
|
|
794
|
+
# PAR2_MODE = per-slice
|
|
795
|
+
# PAR2_RATIO_FULL = 10
|
|
796
|
+
# PAR2_RATIO_DIFF = 5
|
|
797
|
+
# PAR2_RATIO_INCR = 5
|
|
798
|
+
# PAR2_RUN_VERIFY = false
|
|
799
|
+
|
|
800
|
+
# Optional per-backup overrides (section name = backup definition)
|
|
801
|
+
[media-files]
|
|
802
|
+
PAR2_DIR = /mnt/par2/media-files
|
|
803
|
+
PAR2_MODE = per-archive
|
|
804
|
+
PAR2_RATIO_FULL = 10
|
|
727
805
|
|
|
728
806
|
# scripts to run before the backup to setup the environment
|
|
729
807
|
[PREREQ]
|
|
@@ -735,6 +813,15 @@ SCRIPT_1 = df -h
|
|
|
735
813
|
#SCRIPT_2 = another_script.sh
|
|
736
814
|
```
|
|
737
815
|
|
|
816
|
+
PAR2 notes:
|
|
817
|
+
|
|
818
|
+
- If `PAR2_DIR` is unset, par2 files are created next to the archive slices (legacy behavior) and no manifest is written
|
|
819
|
+
- When `PAR2_DIR` is set, dar-backup writes a manifest next to the par2 set:
|
|
820
|
+
`archive_base.par2.manifest.ini`
|
|
821
|
+
- Verify or repair using:
|
|
822
|
+
`par2 verify -B <archive_dir> <par2_set.par2>`
|
|
823
|
+
`par2 repair -B <archive_dir> <par2_set.par2>`
|
|
824
|
+
|
|
738
825
|
### .darrc
|
|
739
826
|
|
|
740
827
|
The package includes a default `darrc` file which configures `dar`.
|
|
@@ -1182,9 +1269,39 @@ If you need to use this option, un-comment it in the [.darrc](#darrc) file (loca
|
|
|
1182
1269
|
|
|
1183
1270
|
## Par2
|
|
1184
1271
|
|
|
1272
|
+
Why keep PAR2 on a different storage device:
|
|
1273
|
+
|
|
1274
|
+
- Reduces single-disk failure impact: bitrot on the archive disk does not affect the parity.
|
|
1275
|
+
- Easier offsite rotation: you can sync only the PAR2 sets to a different failure domain.
|
|
1276
|
+
|
|
1277
|
+
Redundancy guidance:
|
|
1278
|
+
|
|
1279
|
+
- FULL backups: 10% is a practical default for larger data sets and longer retention.
|
|
1280
|
+
- DIFF/INCR: 5% is often enough because the delta is smaller and easier to re-create.
|
|
1281
|
+
- Increase the ratio if the storage is flaky or the backup is hard to re-run.
|
|
1282
|
+
|
|
1283
|
+
Rule of thumb table:
|
|
1284
|
+
|
|
1285
|
+
| Backup type | Suggested PAR2 ratio | Notes |
|
|
1286
|
+
|-------------|----------------------|-------|
|
|
1287
|
+
| FULL | 10% | Longer retention, larger data set |
|
|
1288
|
+
| DIFF | 5% | Smaller delta |
|
|
1289
|
+
| INCR | 5% | Smaller delta |
|
|
1290
|
+
|
|
1291
|
+
>
|
|
1292
|
+
>For large, contiguous archives on reliable local storage, 7–8% has proven sufficient in practice; 10% remains a conservative default.
|
|
1293
|
+
>
|
|
1294
|
+
|
|
1295
|
+
Cloud sync / air-gap note:
|
|
1296
|
+
|
|
1297
|
+
- Syncing PAR2 sets to a different device or remote store protects against bitrot and small corruption, but it cannot recover a completely lost archive.
|
|
1298
|
+
- An air-gapped PAR2 store is useful when the archive disk is exposed to ransomware or accidental deletion.
|
|
1299
|
+
|
|
1185
1300
|
### Par2 to verify/repair
|
|
1186
1301
|
|
|
1187
|
-
|
|
1302
|
+
#### Par2 files kept with archives
|
|
1303
|
+
|
|
1304
|
+
If PAR2 files are stored next to the archives (legacy per-slice behavior), you can verify like this:
|
|
1188
1305
|
|
|
1189
1306
|
```bash
|
|
1190
1307
|
for file in <archive>*.dar.par2; do
|
|
@@ -1198,6 +1315,14 @@ if there are problems with a slice, try to repair it like this:
|
|
|
1198
1315
|
par2 repair <archive>.<slice number>.dar.par2
|
|
1199
1316
|
```
|
|
1200
1317
|
|
|
1318
|
+
#### Par2 files in separate directory
|
|
1319
|
+
|
|
1320
|
+
See [docs on disk layout matters](v2/doc/portable-par2-layout.md)
|
|
1321
|
+
|
|
1322
|
+
>Test case proving this flow:
|
|
1323
|
+
>
|
|
1324
|
+
>[tests/test_par2_manifest.py](v2/tests/test_par2_manifest.py)
|
|
1325
|
+
|
|
1201
1326
|
### Par2 create redundancy files
|
|
1202
1327
|
|
|
1203
1328
|
If you have merged archives, you will need to create the .par2 redundency files manually.
|
|
@@ -1211,6 +1336,15 @@ done
|
|
|
1211
1336
|
|
|
1212
1337
|
where "c" is create, -r5 is 5% redundency and -n1 is 1 redundency file
|
|
1213
1338
|
|
|
1339
|
+
If you want to create a single parity set for all slices in an archive:
|
|
1340
|
+
|
|
1341
|
+
```bash
|
|
1342
|
+
par2 create -B <archive_dir> -r5 <par2_dir>/<archive_base>.par2 <archive_dir>/<archive_base>.*.dar
|
|
1343
|
+
```
|
|
1344
|
+
|
|
1345
|
+
**OBSERVE** [docs on disk layout matters](v2/doc/portable-par2-layout.md)
|
|
1346
|
+
|
|
1347
|
+
|
|
1214
1348
|
## Points of interest
|
|
1215
1349
|
|
|
1216
1350
|
### Limitations on File Names with Special Characters
|
|
@@ -1591,15 +1725,15 @@ One backup definition per file
|
|
|
1591
1725
|
|
|
1592
1726
|
### CLI Tools Overview
|
|
1593
1727
|
|
|
1594
|
-
| Command
|
|
1595
|
-
|
|
1596
|
-
| [dar-backup](#dar-backup-options)| Perform full, differential, or incremental backups with verification and restore testing |
|
|
1597
|
-
| [manager](#manager-options)
|
|
1598
|
-
| [cleanup](#cleanup-options)
|
|
1599
|
-
| [clean-log](#clean-log-options)
|
|
1728
|
+
| Command | Description |
|
|
1729
|
+
| --- | --- |
|
|
1730
|
+
| [dar-backup](#dar-backup-options) | Perform full, differential, or incremental backups with verification and restore testing |
|
|
1731
|
+
| [manager](#manager-options) | Maintain and query catalog databases for archives |
|
|
1732
|
+
| [cleanup](#cleanup-options) | Remove outdated DIFF/INCR archives (and optionally FULLs) |
|
|
1733
|
+
| [clean-log](#clean-log-options) | Clean up excessive log output from dar command logs |
|
|
1600
1734
|
| [dar-backup-systemd](#dar-backup-systemd-options) | Generate (and optionally install) systemd timers and services for automated backups |
|
|
1601
|
-
| [installer](#installer-options)
|
|
1602
|
-
| [demo](#demo-options)
|
|
1735
|
+
| [installer](#installer-options) | Set up directories and optionally create catalog databases according to a config file |
|
|
1736
|
+
| [demo](#demo-options) | Set up required directories and config files for a demo|
|
|
1603
1737
|
|
|
1604
1738
|
### test coverage
|
|
1605
1739
|
|
|
@@ -1654,6 +1788,7 @@ Available options:
|
|
|
1654
1788
|
--examples Show examples of using dar-backup.py.
|
|
1655
1789
|
-l, --list List available backups.
|
|
1656
1790
|
--list-contents <archive> List the contents of a specified archive.
|
|
1791
|
+
--list-definitions List backup definitions from BACKUP.D_DIR.
|
|
1657
1792
|
--selection <params> Define file selection for listing/restoring.
|
|
1658
1793
|
--restore <archive> Restore a specified archive.
|
|
1659
1794
|
-r, --restore <archive> Restore archive.
|
|
@@ -1663,6 +1798,7 @@ Available options:
|
|
|
1663
1798
|
--log-level <level> `debug` or `trace`, default is `info`.
|
|
1664
1799
|
--log-stdout Also print log messages to stdout.
|
|
1665
1800
|
--do-not-compare Do not compare restores to file system.
|
|
1801
|
+
--preflight-check Run preflight checks and exit (runs automatically; this flag just exits after checks).
|
|
1666
1802
|
--examples Show examples of using dar-backup.
|
|
1667
1803
|
--readme Print README.md and exit
|
|
1668
1804
|
--readme-pretty Print README.md with Markdown styling and exit
|
|
@@ -1671,6 +1807,22 @@ Available options:
|
|
|
1671
1807
|
-v, --version Show version and license information.
|
|
1672
1808
|
```
|
|
1673
1809
|
|
|
1810
|
+
#### Dar-backup exit codes
|
|
1811
|
+
|
|
1812
|
+
- 0: Success.
|
|
1813
|
+
- 1: Error (backup/restore/preflight failure).
|
|
1814
|
+
- 2: Warning (restore test failed or backup already exists and is skipped).
|
|
1815
|
+
- 127: Typically an error during startup, file or config value missing
|
|
1816
|
+
- if the `dar -t` test fails, exit code 1 is emitted
|
|
1817
|
+
- restore tests could fail if the source file has changed after the backup
|
|
1818
|
+
|
|
1819
|
+
#### Dar-backup env vars
|
|
1820
|
+
|
|
1821
|
+
| Env var | Value | Description |
|
|
1822
|
+
| --- | --- | --- |
|
|
1823
|
+
| DAR_BACKUP_CONFIG_FILE | Full path to config file | Overrides built-in default, overridden by --config-file |
|
|
1824
|
+
| DAR_BACKUP_DISCORD_WEBHOOK_URL | https://discord.com/api/webhooks/\<userID\>/\<webhook UUID\> | The full url |
|
|
1825
|
+
|
|
1674
1826
|
### Manager Options
|
|
1675
1827
|
|
|
1676
1828
|
This script manages `dar` databases and catalogs.
|
|
@@ -1690,7 +1842,12 @@ Available options:
|
|
|
1690
1842
|
--find-file <file> Search catalogs for a specific file.
|
|
1691
1843
|
--verbose Enable verbose output.
|
|
1692
1844
|
--log-level <level> Set log level (`debug` or `trace`, default is `info`).
|
|
1693
|
-
|
|
1845
|
+
|
|
1846
|
+
#### Manager env vars
|
|
1847
|
+
|
|
1848
|
+
| Env var | Value | Description |
|
|
1849
|
+
| --- | --- | --- |
|
|
1850
|
+
| DAR_BACKUP_CONFIG_FILE | path to the config file | Default is $HOME/.config/dar-backup/dar-backup.conf |```
|
|
1694
1851
|
|
|
1695
1852
|
### Cleanup options
|
|
1696
1853
|
|
|
@@ -1707,12 +1864,19 @@ Supported options:
|
|
|
1707
1864
|
--alternate-archive-dir Clean up in this directory instead of the default one.
|
|
1708
1865
|
--cleanup-specific-archives "<archive>, <>, ..." Comma separated list of archives to cleanup.
|
|
1709
1866
|
-l, --list List available archives (filter using the -d option).
|
|
1867
|
+
--dry-run Show what would be deleted without removing files.
|
|
1710
1868
|
--verbose Print various status messages to screen.
|
|
1711
1869
|
--log-level <level> `debug` or `trace`, default is `info`", default="info".
|
|
1712
1870
|
--log-stdout Print log messages to stdout.
|
|
1713
1871
|
--test-mode This is used when running pytest test cases
|
|
1714
1872
|
```
|
|
1715
1873
|
|
|
1874
|
+
#### Cleanup env vars
|
|
1875
|
+
|
|
1876
|
+
| Env var | Value | Description |
|
|
1877
|
+
| --- | --- | --- |
|
|
1878
|
+
| DAR_BACKUP_CONFIG_FILE | path to the config file | Default is $HOME/.config/dar-backup/dar-backup.conf |
|
|
1879
|
+
|
|
1716
1880
|
### Clean-log options
|
|
1717
1881
|
|
|
1718
1882
|
This script removes excessive logging output from `dar` logs, improving readability and efficiency. Available options:
|
|
@@ -1762,8 +1926,8 @@ Create directories:
|
|
|
1762
1926
|
- ~/.config/dar-backup/
|
|
1763
1927
|
- ~/.config/dar-backup/backup.d/
|
|
1764
1928
|
- ~/dar-backup/
|
|
1765
|
-
- ~/dar-backup/backups
|
|
1766
|
-
- ~/dar-backup/restore
|
|
1929
|
+
- ~/dar-backup/backups/
|
|
1930
|
+
- ~/dar-backup/restore/
|
|
1767
1931
|
|
|
1768
1932
|
Sets up demo config files:
|
|
1769
1933
|
|
|
@@ -1782,3 +1946,100 @@ Sets up demo config files:
|
|
|
1782
1946
|
-v, --version Display version and licensing information.
|
|
1783
1947
|
-h, --help Displays usage info
|
|
1784
1948
|
```
|
|
1949
|
+
|
|
1950
|
+
### Config changes
|
|
1951
|
+
|
|
1952
|
+
#### 1.0.1
|
|
1953
|
+
|
|
1954
|
+
##### DISCORD WEBHOOK
|
|
1955
|
+
|
|
1956
|
+
For Discord notifications use the `DAR_BACKUP_DISCORD_WEBHOOK_URL` environment variable. It should not be placed in the config file.
|
|
1957
|
+
|
|
1958
|
+
DAR_BACKUP_DISCORD_WEBHOOK_URL is the entire endpoint like this:
|
|
1959
|
+
|
|
1960
|
+
```bash
|
|
1961
|
+
export DAR_BACKUP_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/\<userId\>/\<uuid\>
|
|
1962
|
+
```
|
|
1963
|
+
|
|
1964
|
+
##### Restore test config
|
|
1965
|
+
|
|
1966
|
+
Restore tests choose random files from the archive and compare them with the live filesystem.
|
|
1967
|
+
To avoid noisy paths (caches, temp files, logs), you can exclude candidates before the random
|
|
1968
|
+
selection happens. All matching is case-insensitive.
|
|
1969
|
+
|
|
1970
|
+
Config keys (in [MISC]):
|
|
1971
|
+
|
|
1972
|
+
- RESTORETEST_EXCLUDE_PREFIXES: comma-separated path prefixes to skip. Matches from the start of
|
|
1973
|
+
the path (after trimming a leading "/"). Use trailing "/" for directories.
|
|
1974
|
+
- RESTORETEST_EXCLUDE_SUFFIXES: comma-separated filename suffixes to skip.
|
|
1975
|
+
- RESTORETEST_EXCLUDE_REGEX: optional regex to skip anything matching the path.
|
|
1976
|
+
|
|
1977
|
+
Example:
|
|
1978
|
+
|
|
1979
|
+
```ini
|
|
1980
|
+
[MISC]
|
|
1981
|
+
RESTORETEST_EXCLUDE_PREFIXES = .cache/, .local/share/Trash/, .mozilla/, snap/firefox/common/.mozilla/
|
|
1982
|
+
RESTORETEST_EXCLUDE_SUFFIXES = .sqlite-wal, .sqlite-shm, .log, .tmp, .lock, .journal
|
|
1983
|
+
RESTORETEST_EXCLUDE_REGEX = (^|/)(Cache|cache|Logs|log)/
|
|
1984
|
+
```
|
|
1985
|
+
|
|
1986
|
+
Regex tips (case-insensitive):
|
|
1987
|
+
|
|
1988
|
+
- Match common cache/log directories anywhere:
|
|
1989
|
+
`(^|/)(cache|logs)/`
|
|
1990
|
+
- Skip thumbnails and temp dirs:
|
|
1991
|
+
`(^|/)(thumbnails|tmp|temp)/`
|
|
1992
|
+
- Exclude browser profile noise while keeping other files:
|
|
1993
|
+
`(^|/)\.mozilla/|/snap/firefox/common/\.mozilla/`
|
|
1994
|
+
|
|
1995
|
+
##### Par2
|
|
1996
|
+
|
|
1997
|
+
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).
|
|
1998
|
+
|
|
1999
|
+
| Name | Description | When it is in effect | Suggested value |
|
|
2000
|
+
|------|-------------|----------------------|-----------------|
|
|
2001
|
+
| PAR2_DIR | Directory to store .par2 and .vol*.par2 files | When set | A different device or mount from BACKUP_DIR |
|
|
2002
|
+
| PAR2_RATIO_FULL | Redundancy percent for FULL | When set | 10 (%) |
|
|
2003
|
+
| PAR2_RATIO_DIFF | Redundancy percent for DIFF | When set | 5 (%)|
|
|
2004
|
+
| PAR2_RATIO_INCR | Redundancy percent for INCR | When set | 5 (%)|
|
|
2005
|
+
| PAR2_RUN_VERIFY | Verify after create | When set | false |
|
|
2006
|
+
|
|
2007
|
+
Notes:
|
|
2008
|
+
|
|
2009
|
+
- PAR2_RATIO_*, and PAR2_RUN_VERIFY apply even if PAR2_DIR is not set (i.e. par2 output stays next to the archives).
|
|
2010
|
+
|
|
2011
|
+
Per-backup overrides use a section named after the backup definition with the same PAR2_* keys:
|
|
2012
|
+
|
|
2013
|
+
```text
|
|
2014
|
+
|
|
2015
|
+
######################################################################
|
|
2016
|
+
# Per-backup configuration example overrides
|
|
2017
|
+
######################################################################
|
|
2018
|
+
|
|
2019
|
+
# --------------------------------------------------------------------
|
|
2020
|
+
# Per-backup overrides (section name must match backup.d filename stem)
|
|
2021
|
+
# Example: backup.d/home.conf -> [home]
|
|
2022
|
+
# --------------------------------------------------------------------
|
|
2023
|
+
|
|
2024
|
+
#[home]
|
|
2025
|
+
# Disable PAR2 entirely for this backup definition
|
|
2026
|
+
PAR2_ENABLED = false
|
|
2027
|
+
#
|
|
2028
|
+
#[media]
|
|
2029
|
+
# Store PAR2 files in a separate location for this backup definition
|
|
2030
|
+
#PAR2_DIR = /samba/par2/media
|
|
2031
|
+
# Raise redundancy only for FULL
|
|
2032
|
+
#
|
|
2033
|
+
[documents]
|
|
2034
|
+
# Run verify par2 sets after creation
|
|
2035
|
+
PAR2_RUN_VERIFY = true
|
|
2036
|
+
#
|
|
2037
|
+
#[etc]
|
|
2038
|
+
# Keep global PAR2 settings but tweak ratios for this backup definition
|
|
2039
|
+
# RATIO is i percent number
|
|
2040
|
+
#PAR2_RATIO_FULL = 15
|
|
2041
|
+
#PAR2_RATIO_DIFF = 8
|
|
2042
|
+
#PAR2_RATIO_INCR = 8
|
|
2043
|
+
```
|
|
2044
|
+
|
|
2045
|
+
[Per-backup override test case: `tests/test_par2_overrides.py`](v2/tests/test_par2_overrides.py)
|
dar_backup/__about__.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
__version__ = "1.0.
|
|
1
|
+
__version__ = "1.0.1"
|
|
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.
|