hirak99 / yabsnap

Btrfs Scheduled Snapshot Manager for Arch
Apache License 2.0
62 stars 2 forks source link

Post-Transaction Script #24

Closed GhostNaN closed 10 months ago

GhostNaN commented 10 months ago

Would it be possible to add a way to run a script after creating/removing a snapshot?

I have a cron job to run a fish script to populate a refind config with options to boot into snapshots. It's this if you are curious: create-refind-fallbacks.txt But it would be far better if it just ran after yabsnap made a modification to the root snapshots. This could also allow me to have a script show a notification when it ran.

Some kind of implementation could look like this in the config:

post_transaction_script = /root/scripts/create-refind-fallbacks.fish

Or is there another way without having to implement it in yabsnap?

Thank you for your time and effort!

hirak99 commented 10 months ago

Yes, this should be fairly easy to implement.

I will do it.

On Sun, Nov 12, 2023, 21:12 GhostNaN @.***> wrote:

Would it be possible to add a way to run a script after creating/removing a snapshot?

I have a cron job to run a fish script to populate a refind config with options to boot into snapshots. It's this if you are curious: create-refind-fallbacks.txt https://github.com/hirak99/yabsnap/files/13328431/create-refind-fallbacks.txt But it would be far better if it just ran after yabsnap made a modification to the root snapshots. This could also allow me to have a script show a notification when it ran.

Some kind of implementation could look like this in the config:

post_transaction_script = /root/scripts/create-refind-fallbacks.fish

Or is there another way without having to implement it in yabsnap?

Thank you for your time and effort!

— Reply to this email directly, view it on GitHub https://github.com/hirak99/yabsnap/issues/24, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACN3FYWL46HJCDQS4D4YHILYEDU7XAVCNFSM6AAAAAA7IC2U3SVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE4DSNBVGY2TONY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

GhostNaN commented 10 months ago

Thank you!

hirak99 commented 10 months ago

Implemented in 2.0.14. Hope it works for you!

Some additional notes -

  1. The parameter is _post_transactionscripts (plural). More than one script may be provided if desired.
  2. Each script will be called once per config, even if an operation makes multiple changes (e.g. once after scheduled operation completes all deletion and creation).
  3. It will not trigger if there is no change (e.g. if a schedule runs, but does not result in any change).
GhostNaN commented 10 months ago

Works flawlessly!