krystiand / borg-ncdu-analyzer Goto Github PK
View Code? Open in Web Editor NEWAnalyze Borg Backup archives space usage (with ncdu tool).
License: MIT License
Analyze Borg Backup archives space usage (with ncdu tool).
License: MIT License
I used borg-ncdu-analyzer
succesfully before, but it crashes on my most recent backup (the JSON output lines are debug output from a print(line)
I inserted into the code):
martin borg # python3 /home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py ./::archive
Dumping and processing archive...
b'{"type": "d", "mode": "drwxr-xr-x", "user": "root", "group": "root", "uid": 0, "gid": 0, "path": ".", "healthy": true, "source": "", "linktarget": "", "flags": null, "mtime": "2020-05-24T18:56:04.382781", "size": 0}\n'
b'{"type": "d", "mode": "drwx------", "user": "root", "group": "root", "uid": 0, "gid": 0, "path": "lost+found", "healthy": true, "source": "", "linktarget": "", "flags": null, "mtime": "2011-10-24T23:20:06.000000", "size": 0}\n'
b'{"type": "-", "mode": "-rw-------", "user": "root", "group": "root", "uid": 0, "gid": 0, "path": ".bash_history", "healthy": true, "source": "", "linktarget": "", "flags": null, "mtime": "2015-10-11T17:48:52.276437", "size": 52}\n'
Received SIGTERM
Traceback (most recent call last):
File "/home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py", line 179, in <module>
main()
File "/home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py", line 143, in main
analyzer.process_lines(read_lines_from_process(p))
File "/home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py", line 94, in process_lines
self._fs_cache[parent_dir].add_entry(entry)
KeyError: ''
I believe it crashes on files that were in /
when the backup ran, in this case .bash_history
. The parent_dir
of these files is ""
, but as that has never been added as a directory, the code crashes here.
I tried this on Ubuntu 18.04, but it won't run:
martin borg # python3 /home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py ./::archive
Traceback (most recent call last):
File "/home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py", line 6, in <module>
from dataclasses import dataclass
ModuleNotFoundError: No module named 'dataclasses'
To get it working, I haphazardly removed the dependency:
martin@martin ~/borg-ncdu-analyzer % git diff
diff --git a/borg_ncdu_analyzer.py b/borg_ncdu_analyzer.py
old mode 100644
new mode 100755
index 034264b..2d9b049
--- a/borg_ncdu_analyzer.py
+++ b/borg_ncdu_analyzer.py
@@ -1,18 +1,22 @@
+#!/usr/bin/python3
import os
import signal
import subprocess
import json
import tempfile
-from dataclasses import dataclass
from typing import List, Dict, Iterator, Tuple, Iterable
-@dataclass
class FSEntry:
name: str
size: int
sub: List['FSEntry']
+ def __init__(self, name: str, size: int, sub: List['FSEntry']):
+ self.name = name
+ self.size = size
+ self.sub = sub
+
def add_entry(self, entry: 'FSEntry'):
self.sub.append(entry)
Seems to work ¯\(ツ)/¯
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.