That is exactly what I'm doing now: only summarizing the space used by the last_snapshot/backup directory.
I actually go a bit further, to handle the case where a backintime rsync might
complete in the middle of a du scan. I determine the actual current snapshot
directory with:
snapshots=( $( ls -d ${BASE}/*/root/*/last_snapshot/backup ) )
for index in "${!snapshots[@]}" ;
do
snapshot=${snapshots[${index}]}
realdir=$( /usr/bin/realpath ${snapshot} )
result=$( /usr/bin/du -sx ${realdir} )
# ... display stuff from $result
done
That works, and is relatively fast.
But what I'd like to know is how much _actual_ disk space is being used by the
historical snapshots as compared to the latest one. Arithmetically, what I'm
looking for is this pseudo-code:
totalsystem=$( du -sx ${BASE}/$somesystem/root/ )
totallatest=$( du -sx ${BASE}/$somesystem/root/*/last_snapshot/backup )
snapshots_space=$(( totalsystem - totallatest ))
It's the "du" for totalsystem that takes an extremely long time, for the reason
you gave. However, it gives the correct actual disk usage.
I was hoping for some clever way to calculate this without having to recurse
through the entire filesystem for each snapshot.
What I'm trying now is to use the "duc" utility <https://github.com/zevv/duc> to index the entire disk. The "duc
info" command is very fast, but indexing the drive with "duc index" takes as long as running "du". I've set up
a monthly job to run "duc index" over my entire drive, which will take many days to execute. Afterwards, I'll hopefully be
able to get an accurate measure of snapshot disk-space use... but only once a month.
On 2/5/25 8:08 AM, o.stebliuk--- via Bit-dev wrote:
It seems like the du command is slow over multiple snapshots because it's scanning the entire file system, including old snapshots. To speed things up, consider using the --summarize option to reduce the output. Additionally, excluding snapshot directories using --exclude might help if you know where they are. _______________________________________________ Bit-dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/bit-dev.python.org/ Member address: [email protected]
-- -- Bill
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ Bit-dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/bit-dev.python.org/ Member address: [email protected]
