CyberShadow/btdu

Ehancement suggestion : Add export/import functionnality ?

Closed this issue ยท 17 comments

esp13 commented

Hello,

I like the export/import ability of ncdu, I export the scans of drives so I can quickly search what is taking space without plugging the drive or launching a new scan.

I wonder if it could be possible to do the same with btdu for btrfs?
It would maybe be harder to set because there are extra steps : let the scan running to wanted size level then press "p" key and "enter" key.

Thanks for the suggestion. I've been thinking about some kind of import/export functionality.

Would you mind elaborating in a bit more detail of how you use the ncdu feature? Do you run it in headless mode to collect results on one machine, and then view them on another?

esp13 commented

Oh thank you for the fast answer :)

As I have a lot of drives with a lot of files I don't modify often, I like to scan all drives from one computer, and then store the exports and display them later from this computer or from an other when I'm trying to find something or want to reorganize stuff between drives.

I export with this command:
ncdu -1xo- -e /foldertoscan/ | gzip > scanexport.ncdu.gz

and to display the scan with this one:
zcat scanexport.ncdu.gz | ncdu -f- -e

What I found nice too : I can add aespipe inside the command to crypt and protect the result.

OK, here's an initial implementation: https://github.com/CyberShadow/btdu/compare/next

It should be comparable with ncdu's, though btdu can't read saved results from standard input.

Run with --export and --headless; you can use --max-samples / --max-time / --min-resolution to control for how long btdu runs, or you can just press Ctrl+C to stop it.

Edit: needs some dependency updates to get it to build, WIP...

esp13 commented

Nice :)

I get a "floating point exception" is there a way to add debug output? I tried the -v and --verbose option without success.

What do you do to get it?

You'd need a debug build for a useful stack trace...

esp13 commented

I think it was my fault I didn't put the last "/" on btrfs filesystem path:

./btdu-static-x86_64 --export=/outputpath/test.btdu --headless --minresolution=500 mnt_btrfs2

With this it seems running:
./btdu-static-x86_64 --export=/outputpath/test.btdu --headless --minresolution=500 mnt_btrfs2/

esp13 commented

It works great, thank you much :)

I changed min resolution to 500 000 (500KB)

I tried
./btdu-static-x86_64 --expert --export=/outputpath/test.btdu --headless --minresolution=500000 mnt_btrfs2/ | gzip > test.btdu.gz
but this doesn't work

I tried
./btdu-static-x86_64 --expert --export=/outputpath/test.btdu --headless --minresolution=500000 mnt_btrfs2/ | gzip > test.btdu.gz
but this doesn't work

Maybe try --export=- (or -o-), like ncdu?

esp13 commented

Maybe try --export=- (or -o-), like ncdu?

Yes this works :)
./btdu-static-x86_64 --expert -o- --headless --minresolution=500000 mnt_btrfs2/ | gzip > test.btdu.gz

But how to import? I tried :
zcat test.btdu.gz | ./btdu-static-x86_64 -f-
=> Unrecognized option -
or
zcat test.btdu.gz | ./btdu-static-x86_64 -f
=> No path specified

It's not possible to import from standard input at the moment. The data must be in a real file.

esp13 commented

ok ๐Ÿ‘

It should be comparable with ncdu's, though btdu can't read saved results from standard input.

Sorry I just understand now what you was saying with the standard input

esp13 commented

Off topic question:

I had to mount the btrfs path with:

mount /dev/mapper/vercacrypt ~/mntbtrfs/ -o subvolid=5

Is there a way to run the scan from a deeper folder level of the btrfs volume?

No, it's not possible (due to how the algorithm works). See second item in "It differs from classic analyzers through the following properties:" in the README.

esp13 commented

oups sorry ๐Ÿ˜ฌ ๐Ÿ˜‡

No, the API we use does not give btdu this information. It would have to perform one more filesystem call using a completely different API to obtain it.

I'm closing this issue as the feature has been implemented but feel free to post any additional feedback or questions.