Giter Site home page Giter Site logo

wmutschl / timeshift-autosnap-apt Goto Github PK

View Code? Open in Web Editor NEW
146.0 12.0 18.0 82 KB

Timeshift auto-snapshot script for Ubuntu and Debian based systems which creates snapshots of your system with timeshift before a package install, remove or upgrade using DPkg::Pre-Invoke hook in apt. Fork of timeshift-autosnap from AUR.

License: MIT License

Shell 86.98% Makefile 13.02%

timeshift-autosnap-apt's People

Contributors

shrirajhegde avatar wmutschl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

timeshift-autosnap-apt's Issues

snapshot pre and post package operation

This might be a daft question but, why not have 2 snapshots, one before the package operation and another one right after that operation, so that we can compare and rollback very closely what was done during some operation back in the past? This is the way apt-btrfs-snapper does it. Otherwise, it might be hard to know what really happened 2 weeks later, if more than the package operation is included, right?

Feature Request. Set a minimum amount of time between snapshots

I think it'd probably be a good idea to add an option to set a minimum amount of time taken between backups.

This way if someone is going ham in the PopShop and installs a bunch of programs in a short period of time, it'll only make one backup for it. That way if one of them goes sideways and breaks a bunch of stuff (LTT Linus style) there will still be an update old enough to rollback too.

So if the min time is set to 15 min and it's only 7 min since the last package was installed/updated then it won't bother making another backup since the one from 7 min ago should be good enough.

Error: Not a Btrfs Subvolume: Invalid argument

Rsyncing /boot into the filesystem before the call to timeshift.
Rsyncing /boot/efi into the filesystem before the call to timeshift.
Using system disk as snapshot device for creating snapshots in BTRFS mode

/dev/nvme0n1p5 is mounted at: /run/timeshift/backup, options: rw,relatime,compress=zstd:3,ssd,discard=async,space_cache=v2,commit=120,subvolid=5,subvol=/

Creating new backup...(BTRFS)
Saving to device: /dev/nvme0n1p5, mounted at path: /run/timeshift/backup
Created directory: /run/timeshift/backup/timeshift-btrfs/snapshots/2024-01-25_17-34-45
Created subvolume snapshot: /run/timeshift/backup/timeshift-btrfs/snapshots/2024-01-25_17-34-45/@
Created control file: /run/timeshift/backup/timeshift-btrfs/snapshots/2024-01-25_17-34-45/info.json
BTRFS Snapshot saved successfully (1s)
Tagged snapshot '2024-01-25_17-34-45': ondemand
------------------------------------------------------------------------------

/dev/nvme0n1p5 is mounted at: /run/timeshift/backup, options: rw,relatime,compress=zstd:3,ssd,discard=async,space_cache=v2,commit=120,subvolid=5,subvol=/

------------------------------------------------------------------------------
Removing snapshot: 2024-01-18_14-08-57
Deleting subvolume: @ (Id:266)
E: ERROR: Not a Btrfs subvolume: Invalid argument

E: Failed to delete snapshot nested subvolume: '/run/timeshift/backup/timeshift-btrfs/snapshots/2024-01-18_14-08-57/@'
E: Failed to remove snapshot: 2024-01-18_14-08-57
------------------------------------------------------------------------------

This occurs when timeshift-autosnap-apt is triggered (manually or automatically). Clearly it's a misconfiguration, but do you have quick advice before I spend hours trying to figure it out?

Snapshot Description

Is possible to set the description to the command that call autosnap?
Instead of {timeshift-autosnap-apt} {created before call to APT} something like sudo apt install gnome-tweak-tool as snapshot description.

Improve documentation for snapshot settings

I'm not sure how I should configure these:

snapshotBoot: If set to true /boot folder will be cloned with rsync into /boot.backup before the call to Timeshift. Note that this will not include the /boot/efi folder. Default: true

snapshotEFI: If set to true /boot/efi folder will be cloned with rsync into /boot.backup/efi before the call to Timeshift. Default: true

For both options, please update the README to describe when users might want to set either of these options to false.

I am running Debian Testing on an EFI install using BTRFS for my only Linux partition. I have a separate BTRFS subvol for /home.

To set scheduled backups

Can you add an option like to set auto backup every "n" days.that will be very usefull. right now its only backing up if we call 'apt' related actions. if we can schedule autobackup using timeshift it will worth and save our time.

An example..if we lost some configs when we playing with server,and if we dont called an 'apt' method recently the last backup file will be far away. instead if you add an option for backing up "n" days, probably if we choosed every one day we can easily restore the latest backup file. hope you understand.

Thank you

#feature

Prevent certain snapshots from being deleted

Hello! Is there a way to mark a snapshot created by this script to not be automatically removed?

Currently I'm troubleshooting nvidia drivers, which involves multiple apt operations, so I want to keep the very first autosnap that was taken around just in case I need to revert. I changed the comment in the timeshift gui, but I'm not sure if that's enough to make the script pass over it when performing its automatic deletion operations.

Thanks for your help!

EDIT: Looking at the script, it seems that it indeed does search for the autosnap comment when deciding what to delete, but I'm not 100% certain in my analysis.

Stop autosnap if no packages are upgraded

Is it possible to abort a snapshot if there's no packages to be upgraded/installed? I manually run my updates, usually on a daily basis. Many times there are no updates, but the autosnap is still being generated:

$ sudo aptitude safe-upgrade
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
Rsyncing /boot into the filesystem before the call to timeshift.
Rsyncing /boot/efi into the filesystem before the call to timeshift.
Using system disk as snapshot device for creating snapshots in BTRFS mode
Mounted '/dev/sdb4' at '/mnt/timeshift/backup'
Creating new backup...(BTRFS)
Saving to device: /dev/sdb4, mounted at path: /mnt/timeshift/backup
Created directory: /mnt/timeshift/backup/timeshift-btrfs/snapshots/2020-09-13_16-52-40
Created subvolume snapshot: /mnt/timeshift/backup/timeshift-btrfs/snapshots/2020-09-13_16-52-40/@
Created control file: /mnt/timeshift/backup/timeshift-btrfs/snapshots/2020-09-13_16-52-40/info.json
BTRFS Snapshot saved successfully (0s)
Tagged snapshot '2020-09-13_16-52-40': ondemand

errors generated but seems to work

I've had sucess with timeshift-autosnap-apt on Ubuntu,Linuxmint, and LMDE5, but I'm trying today to use it on the RC1 of Debian 12 Bookworm. Timeshift works, grub-btrfs works and when I install a package with apt I get a snapshot in my list of timeshift snapshots with the comment: {timeshift-autosnap-apt} {created before call to APT}

This is the log I get when I run sudo timeshift-autosnap-apt

Found 10 snapshot(s)
Unmount /tmp/grub-btrfs.Y6qbVK8sWN .. Success
grep: /boot/grub/grub.cfg.new: No such file or directory
chmod: cannot access '/boot/grub/grub.cfg.new': No such file or directory
cannot open `/boot/grub/grub.cfg.new': No such file or directoryUsage: /usr/bin/grub-script-check [OPTION...] [PATH]
Try '/usr/bin/grub-script-check --help' or '/usr/bin/grub-script-check
--usage' for more information.
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.

Have script pause and notify user, then retry after x seconds if timeshift is open instead of just bailing.

I happened to have timeshift open but not doing anything and tried to process an upgrade. Couldn't the script prompt the user and wait 60 seconds or so before retrying at least once? This could also potentially handle the issue where the user has closed timeshift but it's slow to actually exit. Thanks for providing this script!

Rsyncing /boot into the filesystem before the call to timeshift.
Rsyncing /boot/efi into the filesystem before the call to timeshift.
Another instance of this application is running (PID=2012046)
Unable to run timeshift-autosnap-apt! Please close Timeshift and try again. Script will now exit...
E: Problem executing scripts DPkg::Pre-Invoke '/usr/bin/timeshift-autosnap-apt'
E: Sub-process returned an error code

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.