Giter Site home page Giter Site logo

i13e / timeshift-autosnap-wrapper Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 49 KB

⌛ Take only one snapshot per system update.

License: GNU General Public License v3.0

Shell 100.00%
yay paru timeshift timeshift-autosnap hook wrapper arch snapshot update aur-helper

timeshift-autosnap-wrapper's Introduction

timeshift-autosnap-wrapper

This script serves as a wrapper for timeshift-autosnap, designed to run before package upgrades using a Pacman hook. Its primary purpose is to prevent the creation of multiple snapshots when combining timeshift-autosnap with AUR helpers. To execute a system update with this wrapper, simply run autosnap-wrapper.

Supported AUR Helpers

  • Paru
  • Yay

Features

  • Creates Timeshift snapshots with unique comments.
  • Deletes old snapshots generated by this script.
  • Automatically generates Grub entries if the grub-btrfs package is installed.
  • Can be manually triggered by running the timeshift-autosnap command with elevated privileges.
  • Allows temporarily skipping the autosnapshot by setting the SKIP_AUTOSNAP environment variable (e.g., sudo SKIP_AUTOSNAP= pacman -Syu).
  • Ensures only one snapshot is taken when using AUR helpers yay and paru.

/etc/timeshift-autosnap.conf Options

  • skipAutosnap - If set to true, the script won't be executed.
  • deleteSnapshots - If set to false, old snapshots won't be deleted.
  • maxSnapshots - Specifies the maximum number of old snapshots to keep.
  • updateGrub - If set to false, Grub entries won't be generated.
  • snapshotDescription - Specifies the value used to differentiate snapshots created using timeshift-autosnap.

What Was Patched

AUR helpers invoke Pacman multiple times during any system update, and the timeshift-autosnap hook runs each time Pacman updates packages. This often results in the creation of multiple partial-update snapshots during an upgrade, making timeshift-autosnap's function less useful and cluttering the system.

Our Solution

To address this issue, we've implemented a way to signal to the various spawned Pacman processes whether a snapshot has been taken during an update. Initially, we set up a location for a lockfile, the presence of which indicates that a snapshot has been created. We save this information in an environment variable and pass it to each instance of Pacman spawned by our AUR helper.

On the first run, the autosnap hook detects that our environment variable is declared, but the file does not yet exist. In this case, we touch the file as the user who called Pacman via sudo and then proceed with the update. On subsequent runs, the lockfile exists, so we set the SKIP_AUTOSNAP variable before running timeshift-autosnap, preventing the creation of additional snapshots. After our AUR helper completes its tasks, our wrapper script removes the lockfile as a final cleanup step.

It's important to note that all these actions occur only when our AUR helper is launched through autosnap-wrapper and when __AUTOSNAP_LOCK is defined. Otherwise, timeshift-autosnap is invoked normally without modification.

Notes

  • This script works in both BTRFS and RSYNC modes.
  • While it was designed with Arch and Arch-based distributions in mind, it can be easily adapted for other Linux distributions.
  • You can manually specify the AUR helper you are using by adding the following line to your ~/.profile: export AUR_HELPER=EXAMPLE, replacing EXAMPLE with your chosen AUR helper name in lowercase.

Contribution

We welcome all new ideas and contributions! If you have suggestions to make this patch easier to use or want to implement support for additional AUR helpers, please feel free to get involved. Your contributions are greatly appreciated.

timeshift-autosnap-wrapper's People

Contributors

i13e avatar

Watchers

 avatar

timeshift-autosnap-wrapper's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.