dar-backup 0.6.8__py3-none-any.whl → 0.6.10__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/__about__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.6.8"
1
+ __version__ = "0.6.10"
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ clean-log.py source code is here: https://github.com/per2jensen/dar-backup/tree/main/v2/src/dar_backup/clean-log.py
4
+ This script is part of dar-backup, a backup solution for Linux using dar and systemd.
5
+
6
+ Licensed under GNU GENERAL PUBLIC LICENSE v3, see the supplied file "LICENSE" for details.
7
+
8
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW,
9
+ not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See section 15 and section 16 in the supplied "LICENSE" file
11
+
12
+ This script can be used to remove (much of) the logged output from `dar`.
13
+ When `dar` verbose options are enabled, quite a lot of information is emitted.
14
+ """
15
+
16
+
17
+ import argparse
18
+ import re
19
+ import os
20
+ import sys
21
+
22
+ from . import __about__ as about
23
+ from dar_backup.config_settings import ConfigSettings
24
+
25
+ LICENSE = '''Licensed under GNU GENERAL PUBLIC LICENSE v3, see the supplied file "LICENSE" for details.
26
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27
+ See section 15 and section 16 in the supplied "LICENSE" file.'''
28
+
29
+ def clean_log_file(log_file_path, dry_run=False):
30
+ """Removes specific log lines from the given file using a memory-efficient streaming approach."""
31
+
32
+
33
+ if not os.path.isfile(log_file_path):
34
+ print(f"File '{log_file_path}' not found!")
35
+ sys.exit(1)
36
+
37
+ if not os.access(log_file_path, os.R_OK):
38
+ print(f"No read permission for '{log_file_path}'")
39
+ sys.exit(1)
40
+
41
+ if not os.access(log_file_path, os.W_OK):
42
+ print(f"Error: No write permission for '{log_file_path}'")
43
+ sys.exit(1)
44
+
45
+
46
+ if dry_run:
47
+ print(f"Performing a dry run on: {log_file_path}")
48
+
49
+ temp_file_path = log_file_path + ".tmp"
50
+
51
+ patterns = [
52
+ r"INFO\s*-\s*<File",
53
+ r"INFO\s*-\s*<Attributes",
54
+ r"INFO\s*-\s*</Directory",
55
+ r"INFO\s*-\s*<Directory",
56
+ r"INFO\s*-\s*</File",
57
+ r"INFO\s*-\s*Inspecting\s*directory",
58
+ r"INFO\s*-\s*Finished\s*Inspecting"
59
+ ]
60
+
61
+ try:
62
+ with open(log_file_path, "r", errors="ignore") as infile, open(temp_file_path, "w") as outfile:
63
+
64
+ for line in infile:
65
+ original_line = line # Store the original line before modifying it
66
+ matched = False # Track if a pattern is matched
67
+
68
+ for pattern in patterns:
69
+ if re.search(pattern, line): # Check if the pattern matches
70
+ if dry_run:
71
+ print(f"Would remove: {original_line.strip()}") # Print full line for dry-run
72
+ matched = True # Mark that a pattern matched
73
+ line = re.sub(pattern, "", line).strip() # Remove only matched part
74
+
75
+ if not dry_run and line: # In normal mode, only write non-empty lines
76
+ outfile.write(line.rstrip() + "\n")
77
+
78
+ if dry_run and matched:
79
+ continue # In dry-run mode, skip writing (since we’re just showing)
80
+
81
+
82
+ # Ensure the temp file exists before renaming
83
+ if not os.path.exists(temp_file_path):
84
+ open(temp_file_path, "w").close() # Create an empty file if nothing was written
85
+
86
+ os.replace(temp_file_path, log_file_path)
87
+ print(f"Successfully cleaned log file: {log_file_path}")
88
+
89
+ except Exception as e:
90
+ print(f"Error processing file: {e}")
91
+ sys.exit(1)
92
+
93
+
94
+
95
+ def main():
96
+ parser = argparse.ArgumentParser(
97
+ description="Clean dar-backup log file for `dar` output"
98
+ )
99
+ parser.add_argument(
100
+ "-f", "--file",
101
+ nargs="+",
102
+ type=str, help="Path(s) to the log file(s) that needs cleaning. Default is the log file specified in the configuration file."
103
+ )
104
+
105
+ parser.add_argument(
106
+ '-c', '--config-file',
107
+ type=str, help="Path to 'dar-backup.conf'",
108
+ default='~/.config/dar-backup/dar-backup.conf')
109
+
110
+ parser.add_argument(
111
+ "--dry-run",
112
+ action="store_true",
113
+ help="Show which lines would be removed without modifying the file."
114
+ )
115
+
116
+
117
+ parser.add_argument(
118
+ "-v", "--version",
119
+ action="version",
120
+ version=f"%(prog)s version {about.__version__}, {LICENSE}"
121
+ )
122
+
123
+ args = parser.parse_args()
124
+
125
+ config_settings = ConfigSettings(os.path.expanduser(args.config_file))
126
+
127
+ if not args.file:
128
+ args.file = [config_settings.logfile_location]
129
+
130
+ for file_path in args.file:
131
+ if not isinstance(file_path, (str, bytes, os.PathLike)):
132
+ print(f"Error: Invalid file path type: {file_path}")
133
+ sys.exit(1)
134
+
135
+ if not os.path.exists(file_path):
136
+ print(f"Error: Log file '{file_path}' does not exist.")
137
+ sys.exit(1)
138
+
139
+ if file_path.strip() == "":
140
+ print(f"Error: Invalid empty filename '{file_path}'.")
141
+ sys.exit(1)
142
+
143
+
144
+ # Run the log file cleaning function
145
+ for log_file in args.file:
146
+ clean_log_file(log_file, dry_run=args.dry_run)
147
+ print(f"Log file '{args.file}' has been cleaned successfully.")
148
+
149
+
150
+ if __name__ == "__main__":
151
+ main()
dar_backup/dar_backup.py CHANGED
@@ -322,7 +322,7 @@ def list_contents(backup_name, backup_dir, selection=None):
322
322
  stdout,stderr = process.stdout, process.stderr
323
323
  if process.returncode != 0:
324
324
  logger.error(f"Error listing contents of backup: '{backup_name}'")
325
- raise subprocess.CalledProcessError(str(process))
325
+ raise RuntimeError(str(process))
326
326
  for line in stdout.splitlines():
327
327
  if "[--- REMOVED ENTRY ----]" in line or "[Saved]" in line:
328
328
  print(line)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dar-backup
3
- Version: 0.6.8
3
+ Version: 0.6.10
4
4
  Summary: A script to do full, differential and incremental backups using dar. Some files are restored from the backups during verification, after which par2 redundancy files are created. The script also has a cleanup feature to remove old backups and par2 files.
5
5
  Project-URL: Homepage, https://github.com/per2jensen/dar-backup/tree/main/v2
6
6
  Project-URL: Changelog, https://github.com/per2jensen/dar-backup/blob/main/v2/Changelog.md
@@ -692,69 +692,114 @@ Description-Content-Type: text/markdown
692
692
 
693
693
  # Full, differential or incremental backups using 'dar'
694
694
 
695
- The wonderful 'dar' [Disk Archiver] (https://github.com/Edrusb/DAR) is used for
695
+ The wonderful 'dar' [Disk Archiver] (https://github.com/Edrusb/DAR) is used for
696
696
  the heavy lifting, together with the par2 suite in these scripts.
697
697
 
698
-
699
- # My use case
700
-
701
- 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
702
- - a non-privileged user (me :-)) can perform a mount
703
- - a privileged user cannot look into the filesystem --> a backup script running as root is not suitable
698
+ ## Table of Contents
699
+
700
+ - [Full, differential or incremental backups using 'dar'](#full-differential-or-incremental-backups-using-dar)
701
+ - [My use case](#my-use-case)
702
+ - [License](#license)
703
+ - [Status](#status)
704
+ - [Breaking change in version 0.6.0](#breaking-change-in-version-060)
705
+ - [Homepage - Github](#homepage---github)
706
+ - [Requirements](#requirements)
707
+ - [Config file](#config-file)
708
+ - [How to run](#how-to-run)
709
+ - [1](#1)
710
+ - [2](#2)
711
+ - [3](#3)
712
+ - [4](#4)
713
+ - [5](#5)
714
+ - [6](#6)
715
+ - [.darrc](#darrc)
716
+ - [Systemctl examples](#systemctl-examples)
717
+ - [Service: dar-back --incremental-backup](#service-dar-back---incremental-backup)
718
+ - [Timer: dar-back --incremental-backup](#timer-dar-back---incremental-backup)
719
+ - [List contents of an archive](#list-contents-of-an-archive)
720
+ - [dar file selection examples](#dar-file-selection-examples)
721
+ - [Select a directory](#select-a-directory)
722
+ - [Select file dates in the directory](#select-file-dates-in-the-directory)
723
+ - [Exclude .xmp files from that date](#exclude-xmp-files-from-that-date)
724
+ - [Restoring](#restoring)
725
+ - [Default location for restores](#default-location-for-restores)
726
+ - [--restore-dir option](#restore-dir-option)
727
+ - [A single file](#a-single-file)
728
+ - [A directory](#a-directory)
729
+ - [.NEF from a specific date](#nef-from-a-specific-date)
730
+ - [Points of interest](#points-of-interest)
731
+ - [dar manager databases](#dar-manager-databases)
732
+ - [.darrc sets -vd -vf (since v0.6.4)](#darrc-sets--vd--vf-since-v064)
733
+ - [Reference](#reference)
734
+ - [dar-backup.py](#dar-backuppy)
735
+ - [manager.py](#managerpy)
736
+ - [cleanup.py](#cleanuppy)
737
+ - [clean-log.py](#clean-logpy)
738
+
739
+ ## My use case
740
+
741
+ 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
742
+
743
+ - a non-privileged user (me :-)) can perform a mount
744
+ - a privileged user cannot look into the filesystem --> a backup script running as root is not suitable
704
745
 
705
746
  I needed the following:
706
- - Backup my cloud storage to something local (cloud is convenient, but I want control over my backups)
707
- - Backup primarily photos, video and different types of documents
708
- - Have a simple non-complicated way of restoring, possibly years into the future. 'dar' fits that scenario with a single statically linked binary (kept with the archives). There is no need install/configure anything - restoring is simple and works well.
709
- - During backup archives must be tested and a restore test (however small) performed
710
- - Archives stored on a server with a reliable file system (easy to mount a directory over sshfs)
711
- - Easy to verify archive's integrity, after being moved around.
747
+
748
+ - Backup my cloud storage to something local (cloud is convenient, but I want control over my backups)
749
+ - Backup primarily photos, video and different types of documents
750
+ - Have a simple non-complicated way of restoring, possibly years into the future. 'dar' fits that scenario with a single statically linked binary (kept with the archives). There is no need install/configure anything - restoring is simple and works well.
751
+ - During backup archives must be tested and a restore test (however small) performed
752
+ - Archives stored on a server with a reliable file system (easy to mount a directory over sshfs)
753
+ - Easy to verify archive's integrity, after being moved around.
712
754
 
713
755
  I do not need the encryption features of dar, as all storage is already encrypted.
714
-
715
756
 
716
- # License
757
+ ## License
717
758
 
718
759
  These scripts are licensed under the GPLv3 license.
719
760
  Read more here: 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.
720
761
 
762
+ ## Status
721
763
 
722
- # Status
723
764
  As of August 8, 2024 I am using the alpha versions of `dar-backup` (alpha-0.5.9 onwards) in my automated backup routine.
724
765
 
725
766
  As of February 13, 2025, I have changed the status from alpha --> beta, as the featureset is in place and the alphas have worked well for a very long time.
726
767
 
727
-
728
- **Breaking change in version 0.6.0**
768
+ ### Breaking change in version 0.6.0
729
769
 
730
770
  Version 0.6.0 and forwards requires the config variable *COMMAND_TIMEOUT_SECS* in the config file.
731
771
 
732
- # Homepage - Github
733
- This 'dar-backup' package lives at: https://github.com/per2jensen/dar-backup
772
+ ## Homepage - Github
773
+
774
+ This 'dar-backup' package lives at: https://github.com/per2jensen/dar-backup/tree/main/v2
734
775
 
735
776
  This python version is v2 of dar-backup, the first is made in bash.
736
777
 
737
- # Requirements
738
- - dar
739
- - par2
740
- - python3 :-)
778
+ ## Requirements
779
+
780
+ - dar
781
+ - par2
782
+ - python3 :-)
741
783
 
742
784
  On Ubuntu, install the requirements this way:
743
- ````
785
+
786
+ ```` bash
744
787
  sudo apt install dar par2 python3
745
- ````
788
+ ````
746
789
 
747
- # Config file
790
+ ## Config file
748
791
 
749
792
  The default configuration is expected here: ~/.config/dar-backup/dar-backup.conf
750
793
 
751
- # How to run
794
+ ## How to run
795
+
796
+ ### 1
752
797
 
753
- ## 1
754
798
  Config file default location is $HOME/.config/dar-backup/dar-backup.conf
755
799
 
756
800
  Example:
757
- ````
801
+
802
+ ```` code
758
803
  [MISC]
759
804
  LOGFILE_LOCATION=/home/user/dar-backup.log
760
805
  MAX_SIZE_VERIFICATION_MB = 20
@@ -791,9 +836,10 @@ ENABLED = True
791
836
  # SCRIPT_2 = <something>
792
837
  # ...
793
838
 
794
- ````
839
+ ````
840
+
841
+ ### 2
795
842
 
796
- ## 2
797
843
  Put your backup definitions in the directory $BACKUP.D_DIR (defined in the config file)
798
844
 
799
845
  The name of the file is the `backup definition` name.
@@ -803,7 +849,8 @@ Make as many backup definitions as you need. Run them all in one go, or run one
803
849
  The `dar` [documentation](http://dar.linux.free.fr/doc/man/dar.html#COMMANDS%20AND%20OPTIONS) has good information on file selection.
804
850
 
805
851
  Example of backup definition for a home directory
806
- ````
852
+
853
+ ```` code
807
854
 
808
855
  # Switch to ordered selection mode, which means that the following
809
856
  # options will be considered top to bottom
@@ -817,7 +864,7 @@ Example of backup definition for a home directory
817
864
  # if you want to take a backup of /home/user/Documents only, uncomment next line
818
865
  # -g Documents
819
866
 
820
- # Some directories to exclude below the Root dir
867
+ # Some directories to exclude below the Root dir (here Root directory is `/home/user` as set in the -R option)
821
868
  -P mnt
822
869
  -P tmp
823
870
  -P .cache
@@ -836,131 +883,93 @@ Example of backup definition for a home directory
836
883
  # size of each slice in the archive
837
884
  --slice 10G
838
885
 
839
- # see https://github.com/per2jensen/dar-backup?tab=readme-ov-file#restore-test-exit-code-4
840
- --comparison-field=ignore-owner
841
886
 
842
887
  # bypass directores marked as cache directories
843
888
  # http://dar.linux.free.fr/doc/Features.html
844
889
  --cache-directory-tagging
845
- ````
890
+ ````
846
891
 
892
+ ### 3
847
893
 
848
- ## 3
849
894
  Installation is currently in a venv. These commands are installed in the venv:
895
+
850
896
  - dar-back
851
897
  - cleanup
852
898
  - manager
899
+ - clean-log
853
900
 
854
901
  To install, create a venv and run pip:
855
- ````
902
+
903
+ ```` bash
856
904
  mkdir $HOME/tmp
857
905
  cd $HOME/tmp
858
906
  python3 -m venv venv # create the virtual environment
859
907
  . venv/bin/activate # activate the virtual env
860
908
  pip install dar-backup # run pip to install `dar-backup`
861
- ````
862
-
909
+ ````
863
910
 
864
911
  I have an alias in ~/.bashrc pointing to my venv:
865
- ````
912
+
913
+ ```` bash
866
914
  alias db=". ~/tmp/venv/bin/activate; dar-backup -v"
867
- ````
915
+ ````
868
916
 
869
917
  Typing `db` at the command line gives this
870
- ````
918
+
919
+ ```` bash
871
920
  (venv) user@machine:~$ db
872
- dar-backup 0.5.17
921
+ dar-backup 0.6.9
873
922
  dar-backup.py source code is here: https://github.com/per2jensen/dar-backup
874
923
  Licensed under GNU GENERAL PUBLIC LICENSE v3, see the supplied file "LICENSE" for details.
875
924
  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
876
925
  See section 15 and section 16 in the supplied "LICENSE" file.
877
926
  ````
878
927
 
879
- `dar-backup -h` gives the usage output:
880
- ````
881
- usage: dar-backup [-h] [-F] [-D] [-I] [-d BACKUP_DEFINITION]
882
- [--alternate-reference-archive ALTERNATE_REFERENCE_ARCHIVE] [-c CONFIG_FILE] [--darrc DARRC]
883
- [--examples] [-l] [--list-contents LIST_CONTENTS] [--selection SELECTION] [-r RESTORE]
884
- [--restore-dir RESTORE_DIR] [--verbose] [--log-level LOG_LEVEL] [--log-stdout]
885
- [--do-not-compare] [-v]
886
-
887
- Backup and verify using dar backup definitions.
888
-
889
- options:
890
- -h, --help show this help message and exit
891
- -F, --full-backup Perform a full backup.
892
- -D, --differential-backup
893
- Perform differential backup.
894
- -I, --incremental-backup
895
- Perform incremental backup.
896
- -d BACKUP_DEFINITION, --backup-definition BACKUP_DEFINITION
897
- Specific 'recipe' to select directories and files.
898
- --alternate-reference-archive ALTERNATE_REFERENCE_ARCHIVE
899
- DIFF or INCR compared to specified archive.
900
- -c CONFIG_FILE, --config-file CONFIG_FILE
901
- Path to 'dar-backup.conf'
902
- --darrc DARRC Optional path to .darrc
903
- --examples Examples of using dar-backup.py.
904
- -l, --list List available archives.
905
- --list-contents LIST_CONTENTS
906
- List the contents of the specified archive.
907
- --selection SELECTION
908
- dar file selection for listing/restoring specific files/directories.
909
- -r RESTORE, --restore RESTORE
910
- Restore specified archive.
911
- --restore-dir RESTORE_DIR
912
- Directory to restore files to.
913
- --verbose Print various status messages to screen
914
- --log-level LOG_LEVEL
915
- `debug` or `trace`
916
- --log-stdout also print log messages to stdout
917
- --do-not-compare do not compare restores to file system
918
- -v, --version Show version and license information.
919
- ````
920
-
921
- ## 4
928
+ ### 4
929
+
922
930
  Generate the archive catalog database(s).
923
931
  `dar-backup` expects the catalog databases to be in place, it does not automatically create them (by design)
924
932
 
925
- ````
926
- manager --create-db --config-file <path to config file> --log-level debug --log-stdout
927
- ````
928
-
929
-
933
+ ```` bash
934
+ manager --create-db
935
+ ````
930
936
 
937
+ ### 5
931
938
 
932
- ## 5
933
939
  You are ready to do backups of all your backup definitions, if your backup definitions are
934
940
  in place in BACKUP.D_DIR (see config file)
935
- ````
941
+
942
+ ```` bash
936
943
  dar-backup --full-backup
937
- ````
944
+ ````
945
+
938
946
  If you want to see dar-backup's log entries in the terminal, use the `--log-stdout` option. This is also useful if dar-backup is started by systemd.
939
947
 
940
948
  If you want more log messages, use the `--log-level debug` option.
941
949
 
942
-
943
950
  If you want a backup of a single definition, use the `-d <backup definition>` option. The definition's name is the filename of the definition in the `backup.d` config directory.
944
- ````
951
+
952
+ ```` bash
945
953
  dar-backup --full-backup -d <your backup definition>
946
954
  ````
947
955
 
948
- ## 6
956
+ ### 6
949
957
 
950
958
  Deactivate the virtual environment
951
- ````
959
+
960
+ ```` bash
952
961
  deactivate
953
962
  ````
954
963
 
964
+ ## .darrc
955
965
 
956
- # .darrc
957
966
  The package includes a default `.darrc` file which configures `dar`.
958
967
 
959
968
  You can override the default `.darrc` using the `--darrc` option.
960
969
 
961
970
  The default `.darrc` contents are as follows:
962
971
 
963
- ````
972
+ ```` code
964
973
  # .darrc configuration file for `dar` as used by the `dar-backup` script.
965
974
  # `dar-backup` lives here: https://github.com/per2jensen/dar-backup
966
975
 
@@ -998,19 +1007,21 @@ verbose:
998
1007
  # -va
999
1008
 
1000
1009
 
1001
- extract:
1010
+ restore-options:
1002
1011
  # don't restore File Specific Attributes
1003
1012
  #--fsa-scope none
1004
1013
 
1005
1014
  # ignore owner, useful when used by a non-privileged user
1006
1015
  --comparison-field=ignore-owner
1007
1016
 
1017
+
1018
+ # Exclude specific file types from compression
1019
+ compress-exclusion:
1020
+
1008
1021
  # First setting case insensitive mode on:
1009
1022
  -an
1010
1023
  -ag
1011
1024
 
1012
- # Exclude specific file types from compression
1013
- compress-exclusion:
1014
1025
  -Z "*.gz"
1015
1026
  -Z "*.bz2"
1016
1027
  -Z "*.xz"
@@ -1081,14 +1092,15 @@ compress-exclusion:
1081
1092
  -acase
1082
1093
  ````
1083
1094
 
1084
- # Systemctl examples
1095
+ ## Systemctl examples
1096
+
1085
1097
  I have dar-backup scheduled to run via systemd --user settings.
1086
1098
 
1087
1099
  The files are located in: ~/.config/systemd/user
1088
1100
 
1089
1101
  Once the .service and .timer files are in place, timers must be enabled and started.
1090
1102
 
1091
- ````
1103
+ ```` bash
1092
1104
  systemctl --user enable dar-inc-backup.timer
1093
1105
  systemctl --user start dar-inc-backup.timer
1094
1106
  systemctl --user daemon-reload
@@ -1096,15 +1108,15 @@ systemctl --user daemon-reload
1096
1108
 
1097
1109
  Verify your timers are set up as you want:
1098
1110
 
1099
- ````
1111
+ ```` bash
1100
1112
  systemctl --user list-timers
1101
1113
  ````
1102
1114
 
1103
-
1104
1115
  ## Service: dar-back --incremental-backup
1105
1116
 
1106
1117
  File: dar-inc-backup.service
1107
- ````
1118
+
1119
+ ```` code
1108
1120
  [Unit]
1109
1121
  Description=dar-backup INC
1110
1122
  StartLimitIntervalSec=120
@@ -1119,7 +1131,8 @@ ExecStart=/bin/bash -c '. /home/user/programmer/dar-backup.py/venv/bin/activate
1119
1131
  ## Timer: dar-back --incremental-backup
1120
1132
 
1121
1133
  File: dar-inc-backup.timer
1122
- ````
1134
+
1135
+ ```` code
1123
1136
  [Unit]
1124
1137
  Description=dar-backup INC timer
1125
1138
 
@@ -1131,15 +1144,17 @@ Persistent=true
1131
1144
  WantedBy=timers.target
1132
1145
  ````
1133
1146
 
1147
+ ## list contents of an archive
1134
1148
 
1135
- # list contents of an archive
1136
- ```
1149
+ ```` bash
1137
1150
  . <the virtual evn>/bin/activate
1138
1151
  dar-backup --list-contents example_FULL_2024-06-23 --selection "-X '*.xmp' -I '*2024-06-16*' -g home/pj/tmp/LUT-play"
1139
1152
  deactivate
1140
- ```
1153
+ ````
1154
+
1141
1155
  gives
1142
- ```
1156
+
1157
+ ``` code
1143
1158
  [Data ][D][ EA ][FSA][Compr][S]| Permission | User | Group | Size | Date | filename
1144
1159
  --------------------------------+------------+-------+-------+---------+-------------------------------+------------
1145
1160
  [Saved][-] [-L-][ 0%][ ] drwxr-xr-x root root 113 Mio Sat May 11 16:16:48 2024 home
@@ -1149,17 +1164,17 @@ gives
1149
1164
  [Saved][ ] [-L-][ 0%][X] -rw-rw-r-- pj pj 49 Mio Sun Jun 16 12:52:22 2024 home/pj/tmp/LUT-play/2024-06-16_12:52:22,15.NEF
1150
1165
  ```
1151
1166
 
1167
+ ## dar file selection exmaples
1152
1168
 
1169
+ ### select a directory
1153
1170
 
1154
-
1155
- # dar file selection exmaples
1156
-
1157
- ## select a directory
1158
- ```
1171
+ ``` bash
1159
1172
  dar -l /tmp/example_FULL_2024-06-23 -g home/pj/tmp/LUT-play
1160
1173
  ```
1174
+
1161
1175
  gives
1162
- ```
1176
+
1177
+ ```` code
1163
1178
  [Data ][D][ EA ][FSA][Compr][S]| Permission | User | Group | Size | Date | filename
1164
1179
  --------------------------------+------------+-------+-------+---------+-------------------------------+------------
1165
1180
  [Saved][-] [-L-][ 0%][ ] drwxr-xr-x root root 113 Mio Sat May 11 16:16:48 2024 home
@@ -1186,15 +1201,17 @@ gives
1186
1201
  [Saved][ ] [-L-][ 92%][ ] -rw-rw-r-- pj pj 24 kio Sat Jun 22 21:51:15 2024 home/pj/tmp/LUT-play/2024-06-16_12:52:22,15_16.NEF.xmp
1187
1202
  [Saved][ ] [-L-][ 92%][ ] -rw-rw-r-- pj pj 24 kio Sat Jun 22 21:50:48 2024 home/pj/tmp/LUT-play/2024-06-16_12:52:22,15_17.NEF.xmp
1188
1203
  [Saved][ ] [-L-][ 92%][ ] -rw-rw-r-- pj pj 24 kio Sat Jun 22 21:50:19 2024 home/pj/tmp/LUT-play/2024-06-16_12:52:22,15_18.NEF.xmp
1189
- ```
1204
+ ````
1190
1205
 
1206
+ ### select file dates in the directory:
1191
1207
 
1192
- ## select file dates in the directory:
1193
- ```
1208
+ ``` bash
1194
1209
  dar -l /tmp/example_FULL_2024-06-23 -I '*2024-06-16*' -g home/pj/tmp/LUT-play
1195
1210
  ```
1211
+
1196
1212
  gives
1197
- ```
1213
+
1214
+ ``` code
1198
1215
  [Data ][D][ EA ][FSA][Compr][S]| Permission | User | Group | Size | Date | filename
1199
1216
  --------------------------------+------------+-------+-------+---------+-------------------------------+------------
1200
1217
  [Saved][-] [-L-][ 0%][ ] drwxr-xr-x root root 113 Mio Sat May 11 16:16:48 2024 home
@@ -1223,12 +1240,16 @@ gives
1223
1240
  [Saved][ ] [-L-][ 92%][ ] -rw-rw-r-- pj pj 24 kio Sat Jun 22 21:50:19 2024 home/pj/tmp/LUT-play/2024-06-16_12:52:22,15_18.NEF.xmp
1224
1241
  ```
1225
1242
 
1226
- ## exclude .xmp files from that date
1227
- ```
1243
+ ### exclude .xmp files from that date
1244
+
1245
+ ``` bash
1228
1246
  dar -l /tmp/example_FULL_2024-06-23 -X '*.xmp' -I '*2024-06-16*' -g home/pj/tmp/LUT-play
1247
+
1229
1248
  ```
1249
+
1230
1250
  gives
1231
- ```
1251
+
1252
+ ``` code
1232
1253
  [Data ][D][ EA ][FSA][Compr][S]| Permission | User | Group | Size | Date | filename
1233
1254
  --------------------------------+------------+-------+-------+---------+-------------------------------+------------
1234
1255
  [Saved][-] [-L-][ 0%][ ] drwxr-xr-x root root 113 Mio Sat May 11 16:16:48 2024 home
@@ -1240,16 +1261,16 @@ gives
1240
1261
 
1241
1262
  Nice :-)
1242
1263
 
1264
+ ## Restoring
1243
1265
 
1266
+ ### default location for restores
1244
1267
 
1245
- # Restoring
1246
-
1247
- ## default location for restores
1248
1268
  dar-backup will use the TEST_RESTORE_DIR location as the Root for restores, if the --restore-dir option has not been supplied.
1249
1269
 
1250
1270
  See example below to see where files are restored to.
1251
1271
 
1252
- ## --restore-dir option
1272
+ ### --restore-dir option
1273
+
1253
1274
  When the --restore-dir option is used for restoring, a directory must be supplied.
1254
1275
 
1255
1276
  The directory supplied functions as the Root of the restore operation.
@@ -1257,41 +1278,122 @@ The directory supplied functions as the Root of the restore operation.
1257
1278
  **Example**:
1258
1279
 
1259
1280
  A backup has been taken using this backup definition:
1260
- ```
1281
+
1282
+ ``` code
1261
1283
  -R /
1262
1284
  -g home/user/Documents
1263
1285
  ```
1264
1286
 
1265
1287
  When restoring and using `/tmp` for --restore-dir, the restored files can be found in `/tmp/home/user/Documents`
1266
1288
 
1267
- ## a single file
1268
- ```
1289
+ ### a single file
1290
+
1291
+ ``` code
1269
1292
  . <the virtual env>/bin/activate
1270
1293
  dar-backup --restore <archive_name> --selection "-g path/to/file"
1271
1294
  deactivate
1295
+
1272
1296
  ```
1273
- ## a directory
1274
- ```
1297
+
1298
+ ### a directory
1299
+
1300
+ ``` bash
1275
1301
  . <the virtual env>/bin/activate
1276
1302
  dar-backup --restore <archive_name> --selection "-g path/to/directory"
1277
1303
  deactivate
1278
1304
  ```
1279
1305
 
1306
+ ### .NEF from a specific date
1280
1307
 
1281
- ## .NEF from a specific date
1282
- ```
1308
+ ``` bash
1283
1309
  . <the virtual env>/bin/activate
1284
1310
  dar-backup --restore <archive_name> --selection "-X '*.xmp' -I '*2024-06-16*' -g home/pj/tmp/LUT-play"
1285
1311
  deactivate
1286
1312
  ```
1287
1313
 
1314
+ ## Points of interest
1288
1315
 
1289
- # Points of interest
1290
-
1291
- ## .darrc sets -vd -vf (since v0.6.4)
1316
+ ### dar manager databases
1317
+
1318
+ `dar-backup` now saves archive catalogs in dar catalog databases.
1319
+
1320
+ This makes it easier to restore to a given date when having many FULL, DIFF and INCR archives.
1321
+
1322
+ ### .darrc sets -vd -vf (since v0.6.4)
1292
1323
 
1293
1324
  These .darrc settings make `dar` print the current directory being processed (-vd) and some stats after (-vf)
1294
1325
  This is very useful in very long running jobs to get an indication that the backup is proceeding normally.
1295
1326
 
1296
- if --log-stdout is used the information would be picked up by systemd and logged by journald
1327
+ if --log-stdout is used the information would be picked up by systemd and logged by journald
1328
+
1329
+ The log file can get quite cluttered, if you want the clutter to be removed, run the `clean-log`script.
1330
+
1331
+ ## Reference
1332
+
1333
+ ### dar-backup.py
1334
+
1335
+ This script is responsible for managing the backup creation and validation process. It supports the following options:
1336
+
1337
+ ``` code
1338
+ --full-backup Perform a full backup.
1339
+ --differential-backup Perform a differential backup.
1340
+ --incremental-backup Perform an incremental backup.
1341
+ --backup-definition <name> Specify the backup definition file.
1342
+ --alternate-reference-archive <file> Use a different archive for DIFF/INCR backups.
1343
+ --config-file <path> Specify the path to the configuration file.
1344
+ --darrc <path> Specify an optional path to .darrc.
1345
+ --examples Show examples of using dar-backup.py.
1346
+ --list List available backups.
1347
+ --list-contents <archive> List the contents of a specified archive.
1348
+ --selection <params> Define file selection for listing/restoring.
1349
+ --restore <archive> Restore a specified archive.
1350
+ --restore-dir <path> Directory to restore files to.
1351
+ --verbose Enable verbose output.
1352
+ --log-level <level> Set log level (debug, trace, etc.).
1353
+ --log-stdout Also print log messages to stdout.
1354
+ --do-not-compare Do not compare restores to file system.
1355
+ --version Show version and license information.
1356
+ ```
1357
+
1358
+ ### manager.py
1359
+
1360
+ This script manages `dar` databases and catalogs. Available options include:
1361
+
1362
+ ``` code
1363
+ --create-db Create missing databases for all backup definitions.
1364
+ --alternate-archive-dir <path> Use this directory instead of BACKUP_DIR in the config file.
1365
+ --add-dir <path> Add all archive catalogs in this directory to databases.
1366
+ -d, --backup-def <name> Restrict to work only on this backup definition.
1367
+ --add-specific-archive <file> Add this archive to the catalog database.
1368
+ --remove-specific-archive <file> Remove this archive from the catalog database.
1369
+ -l, --list-catalogs List catalogs in databases for all backup definitions.
1370
+ --list-catalog-contents <num> List contents of a catalog by archive number.
1371
+ --list-archive-contents <file> List contents of an archive’s catalog.
1372
+ --find-file <file> Search catalogs for a specific file.
1373
+ --verbose Enable verbose output.
1374
+ --log-level <level> Set log level.
1375
+ ```
1376
+
1377
+ ### cleanup.py
1297
1378
 
1379
+ This script cleans up old backups and manages storage. Supported options:
1380
+
1381
+ ``` code
1382
+ --prune-older-than <days> Remove backups older than the specified number of days.
1383
+ --keep-last <num> Retain only the last <num> backups.
1384
+ --dry-run Show what would be deleted without actually deleting.
1385
+ --backup-dir <path> Specify the backup directory.
1386
+ --verbose Enable verbose output.
1387
+ --help Show this help message and exit.
1388
+ ```
1389
+
1390
+ ### clean-log.py
1391
+
1392
+ This script removes excessive logging output from `dar` logs, improving readability and efficiency. Available options:
1393
+
1394
+ ``` code
1395
+ -f, --file <path> Specify the log file(s) to be cleaned.
1396
+ -c, --config-file <path> Specify the configuration file (default: ~/.config/dar-backup/dar-backup.conf).
1397
+ --dry-run Show which lines would be removed without modifying the file.
1398
+ -v, --version Display version and licensing information.
1399
+ ```
@@ -0,0 +1,14 @@
1
+ dar_backup/.darrc,sha256=-aerqivZmOsW_XBCh9IfbYTUvw0GkzDSr3Vx4GcNB1g,2113
2
+ dar_backup/__about__.py,sha256=G-zfU8sHQRTZnZK0te1cvbxqeLhT1z86XeAYFNUON6Q,22
3
+ dar_backup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ dar_backup/clean_log.py,sha256=VXKA2BMyQmaC6R08Bq9a3wP3mczdFb_moy6HkL-mnF8,5176
5
+ dar_backup/cleanup.py,sha256=9yEdRR84XPtEvBGc2QfwGBQl2tdTPttjetHeiSc_TsM,11419
6
+ dar_backup/config_settings.py,sha256=CBMUhLOOZ-x7CRdS3vBDk4TYaGqC4N1Ot8IMH-qPaI0,3617
7
+ dar_backup/dar_backup.py,sha256=hDy7aXU-XiWOtW40Pxql441liNkSYKGU76eOwy8m7fU,32714
8
+ dar_backup/manager.py,sha256=HDa8eYF89QFhlBRR4EWRzzmswOW00S_w8ToZ5SARO_o,21359
9
+ dar_backup/util.py,sha256=SSSJYM9lQZfubhTUBlX1xDGWmCpYEF3ePARmlY544xM,11283
10
+ dar_backup-0.6.10.dist-info/METADATA,sha256=CEgbqp93sB_cPnEDWuLn7gphZjdrn4zP_5dShC2Buv8,67980
11
+ dar_backup-0.6.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
12
+ dar_backup-0.6.10.dist-info/entry_points.txt,sha256=p6c4uQLjlTIVP1Od2iorGefrVUH0IWZdFRMl63mNaRg,164
13
+ dar_backup-0.6.10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
14
+ dar_backup-0.6.10.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  [console_scripts]
2
+ clean-log = dar_backup.clean_log:main
2
3
  cleanup = dar_backup.cleanup:main
3
4
  dar-backup = dar_backup.dar_backup:main
4
5
  manager = dar_backup.manager:main
@@ -1,13 +0,0 @@
1
- dar_backup/.darrc,sha256=-aerqivZmOsW_XBCh9IfbYTUvw0GkzDSr3Vx4GcNB1g,2113
2
- dar_backup/__about__.py,sha256=qbWTdDuFyvScwNj95KArnOcQph9tiLZZ8rgNJYlJ4AE,21
3
- dar_backup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- dar_backup/cleanup.py,sha256=9yEdRR84XPtEvBGc2QfwGBQl2tdTPttjetHeiSc_TsM,11419
5
- dar_backup/config_settings.py,sha256=CBMUhLOOZ-x7CRdS3vBDk4TYaGqC4N1Ot8IMH-qPaI0,3617
6
- dar_backup/dar_backup.py,sha256=VbpyiCnoVvJuMWS7LO9wo8WIcDegCPVjb5Q7xN9J9Gg,32731
7
- dar_backup/manager.py,sha256=HDa8eYF89QFhlBRR4EWRzzmswOW00S_w8ToZ5SARO_o,21359
8
- dar_backup/util.py,sha256=SSSJYM9lQZfubhTUBlX1xDGWmCpYEF3ePARmlY544xM,11283
9
- dar_backup-0.6.8.dist-info/METADATA,sha256=U3iy7Gzz-D6p5UePy0VLzX2lNbELs0teKBEZXr-sSqc,64610
10
- dar_backup-0.6.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
11
- dar_backup-0.6.8.dist-info/entry_points.txt,sha256=x9vnW-JEl8mpDJC69f_XBcn0mBSkV1U0cyvFV-NAP1g,126
12
- dar_backup-0.6.8.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
13
- dar_backup-0.6.8.dist-info/RECORD,,