`kup` is nice and i like it... but pruning is a pain

the GUI lacks any kind of automatic pruning capability and when they build up, trying to prune a bunch of them at once really bogs down the GUI to the point you are not ever sure it’s still working.

since kup is just a front end to bup, how difficult would it be to script and schedule your own auto prune routine that would quietly go in there and nip out the older saves?

seems like it should be doable

now i only have ver 0.33.3 and i understand ver 0.33.7+ have a “prune” feature built in, but the doc say it’s equvilant to a bup rm followed by a bup gc which are supported in my version.

so anyone doing this?

I haven’t looked at using bup directly in many years, though I have complied it and Kup before neon started providing an updated Kup. I use the cli to manually fsck a backup set once, but it was quite some time ago.

I have no issues with Kup being slow, though I do use an external drive or NFS share for the backups. Yes, it is a slower process sometimes, and I do wish it had some automatic pruning option in the UI. The slowness I think is part of the incremental nature of the backups.

You should have the bup-prune-older command in bup 33.3.

You can find the exact bup commands that Kup used for the backups, which can be used to help set up a custom script for what you want to do.

~/.cache/kup is where the logs for the backup plans are kept, which shows the commands.

As a test, I manually compiled the latest bup - quite easy to do, actually. It seems to load the backup a bit faster to me, though I can’t verify this as a fact.

1 Like

ah, you are right… don’t know why i thought prune-older was not available on earlier versions.

well that simplifies things considerably.

my goal is to schedule a script to prune and run diagnostics/repair on the archive every week so i don’t have to manually prune it using the GUI.

there is also the matter of the $BUP_DIR
currently if i use echo $BUP_DIR, i get a blank line in return.

is .profile a good place to assign the variable?

putting export $BUP_DIR= in my .profile is working

a couple other questions tho, if you happen to have a ready answer

the kup advanced options have two check boxes that i currently leave unchecked because they make the backup process too intrusive when it runs and it can run 3 or 4 times a day depending on my usage, so it’s too disruptive to just leave on.

but i could build these into my pruning script and still get the benefit of them without the disruption by running it only once per day or even once a week.

Verify integrity of backup
Checks the whole backup archive for corruption every time you save new data.

can i take this to be the same as bup fsck -r?
attempt to repair any damaged packs using existing recovery blocks.

Generate recovery information
This will make it possible to recover from a partially corrupted backup.

can i take this to be the same as bup fsck -g?
generate recovery blocks for any packs that don’t already have them.

Here is a sanitized and shorted version main backup plan’s log, which has both enabled:

Kup is starting bup backup job at Tuesday, June 3, 2025 10:22:29 PM Eastern Daylight Time

bup "-d" "$BUP_DIR" "init"
bup "-d" "$BUP_DIR" "fsck" "--quick" "-j" "4"
Exit code: 0
bup "-d" "$BUP_DIR" "index" "-u" "--exclude" "$HOME.local/share/Steam"  "--exclude" "$HOME.steam" "--exclude" "$HOMEPublic/Cadmium" "--exclude" "$HOMEPublic/imagebuilder-main" "$HOME"
Exit code: 0
bup "-d" "$BUP_DIR" "save" "-n" "kup" "-vv" "$HOME"
Saving: 100.00% (2948750/2948750k, 502946/502946 files), done.    
Exit code: 0
bup "-d" "$BUP_DIR" "fsck" "-g" "-j" "4"

So it does these steps:

  1. init the backup
  2. A quick fsck (fsck --quick -j 4)
  3. It completes this successfully
  4. Indexes my $HOME, excluding the specified dirs
  5. it completes successfully
  6. Saves the changed things to the backup
  7. It completes this successfully
  8. Recovery info is created (fsck -g -j 4)

I’d wager that the fsck actions will be 'invasive" for you even without the gui. I don’t notice this unless I look at my notifications which I have modified so I only see popups for errors or failures, but as mentioned I do back up to external drive or a network share and don’t notice this, or see much of it. For your scripting, adjusting ‘-j’ might help. I run an older lower-power i5-7500t, which only has 4 cores, so I assume the number of jobs for me equals the core count.

ok that makes sense and you must have both check boxes checked… because when i look at my log is has neither of these lines in it.

so the bup "-d" "$BUP_DIR" "fsck" "--quick" "-j" "4" is the first box

and bup "-d" "$BUP_DIR" "fsck" "-g" "-j" "4" is the other one.

to reduce disruption, my plan is to have the script run at a known time and it will not be sending me popups… should be much less invasive compared to the Kup GUI doing it.

still think i’ll run the full bup fsck -r tho instead of --quick to make sure it handles any errors it finds without me needing to be involved.

thanks for you help with this, much appreciated.

The docs hint that --quick may be preferable, but doing it your way at an idle time probably won’t be an issue. For me, 'quick" is relative, so the normal route will be slowwoww.

1 Like

so this is what i came up with and i have it scheduled to go off everyday at 4:20 (idle time :wink:

the notification for some reason doesn’t popup when cron starts the job, but it will if i run the script in a console… not a big deal but, it’s not obvious why that would matter.

when it runs it’s hardly noticeable in terms of CPU usage or fan noise, and it takes about 2 min to complete if i’m watching the task manager.

all in all a pretty nice addition to using Kup for my backup program (or at least one of them).

#!/bin/bash

# script performs maintenance on the Kup
# archive that Kup does not provide

notify-send --urgency=low "Pruning Kup"

# prune operation on archive based on what to keep
# keep all backups less than:       1w old
# keep latest daily less than:      1m old
# keep latest monthly less than:    6m old
# keep latest annual less than:     1y old

bup prune-older --keep-all-for 1w  --keep-dailies-for 1m  --keep-monthlies-for 6m --keep-yearlies-for 1y --unsafe

# (-r) verify integrity of backups
# make repairs to any damaged packs using recovery blocks
# same as checking the 1st box in Kup advanced options
# (-g) generate recovery information for newly created packs
# make it possible to recover from a partially corrupted backup
# same as checking the 2nd box in Kup advanced options

bup fsck -rg

# task complete
1 Like

Kup makes the notification, while bup being a command line tool doesn’t connect to Plasma’s notification system. I’ll wager you can script that in, though, somehow.

I never notice the fsck or recover info, other than the notification popup, which I disabled ages ago. These take forever on some of my versioned plans when doing them over the network, but has never bogged things down. I’ll guess that not using the “j” option is reducing the number of processes for you, which probably helps.

If Kup were to add btrfs snapshot management similar to Timeshift, it would be the perfect single tool for me, or close enough.

that’s exactly what i did, with the line

notify-send --urgency=low "Pruning Kup"

but it only appears when i run the script manually in a console window

when cron runs the script on the timer in the background it doesn’t show, but it does everything else.