Timeshift integration

#1

Why is Timeshift not part of the live-system?
I think restoring snapshots is a common task for a live-system.

Is it possible to (optionally) integrate Timeshift in the package mangement tool stack?
Creating snapshots before installing system updates is a good life insurance.

2 Likes

Some questions about TimeShift as auto backup from the Manjaro
#2

Like Yast and Snapper do in (open)SUSE.

0 Likes

#3

That sounds like a good idea!

0 Likes

#4

And make it optional too of course

0 Likes

#5

That sounds as if you don’t like the idea, but yes, optional would be the best.
I have also never liked a program like Timeshift, but as experiment I have started to use it on my laptop and I use it full time. I can always go back to a previous state, just did so this morning after I was trying out some new icon themes. I found out I lost several icons, the ones for typical KDE programs. Didn’t matter which one I chose, they were not there, so I restored yesterdays state of the system and now all is working well. Took maybe 2 minutes to do so, including the necessary reboot.

1 Like

#6

I actually like the idea, but there’s always gonna be someone who just doesn’t want to use that feature because of X problem.

0 Likes

#7

For Manjaro Gnome it is and it is super helpful. Super easy to restore backups if you have a Manjaro Gnome live usb.

0 Likes

#8

Good to know. The XFCE edition does not include it.

0 Likes

#9

Exactly, please do not force anyone to use it, but offer it as an easy to use option

0 Likes

#10

Manjaro 18: I recently took a look on the GNOME Edition it has timeshift bundled in the live-system, but it seems that the XFCE one is missing it.

Please bundled it to the live-system in all spins. This thing can be a live saver for common-users getting problems in his updates.

I really like how Linux Mint uses Timeshift in their system. Especially for rolling distros I consider it a good idea having this for people wanting to rescue their system easily.

0 Likes

#11

Are you saying to get prompted by pacman to update timeshift snapshot right before running pacman -Syyu I would agree to that as long as the user is given the option to disable that prompt if they want.

Also I totally agree with your first point.

0 Likes

#12

If you wanted an automatic snapshot created prior to updating, I think that could be accomplished by writing a pacman hook. I’m no expert on pacman hooks, but they are fairly simple to write.

2 Likes

#13

thanks for the suggestion, looks really easy

[Trigger]
Operation = Upgrade
Type = Package
Target = *

[Action]
Depends = timeshift
When = PreTransaction
Exec = /usr/bin/timeshift --create --comments "from pacman hook"

How often is the hook triggered, for every package or once per pacman -Syyu?
it will try it out

2 Likes

#14

I belive if you use:

Target = * 

It will invoke the hook at any package upgrade operation. Test it out and let us know how it worked.

1 Like

#15

That seems to work. I downgraded two installed packages and run pacman -Syyu
Only one snapshot was created :slight_smile:
But there is one side effect, downgrades trigger also the upgrade hook .
I can live with that behavior, definitely a nice solution!

Pacman output
sudo pacman -Syyu
:: Synchronizing package databases...
 core                                           147,4 KiB  2,88M/s 00:00 [#########################################] 100%
 extra                                         1852,6 KiB  11,1M/s 00:00 [#########################################] 100%
 community                                        5,1 MiB  11,8M/s 00:00 [#########################################] 100%
 multilib                                       184,7 KiB  13,9M/s 00:00 [#########################################] 100%
:: Starting full system upgrade...
warning: lib32-systemd: local (239.303-1) is newer than multilib (239.6-2)
warning: libsystemd: local (239.303-1) is newer than core (239.6-2)
warning: systemd: local (239.303-1) is newer than core (239.6-2)
warning: systemd-sysvcompat: local (239.303-1) is newer than core (239.6-2)
resolving dependencies...
looking for conflicting packages...

Packages (2) rclone-1.45-1  rsnapshot-1.4.2-3

Total Installed Size:  35,55 MiB
Net Upgrade Size:       2,97 MiB

:: Proceed with installation? [Y/n] y
(2/2) checking keys in keyring                                           [#########################################] 100%
(2/2) checking package integrity                                         [#########################################] 100%
(2/2) loading package files                                              [#########################################] 100%
(2/2) checking for file conflicts                                        [#########################################] 100%
(2/2) checking available disk space                                      [#########################################] 100%
:: Running pre-transaction hooks...
(1/1) pacman-timeshift.hook
------------------------------------------------------------------------------
Creating new snapshot...(RSYNC)
Saving to device: /dev/sda1, mounted at path: /home
Linking from snapshot: 2018-12-24_10-50-39
Synching files with rsync...
Created control file: /home/timeshift/snapshots/2018-12-24_13-49-27/info.json   
RSYNC Snapshot saved successfully (4s)
Tagged snapshot '2018-12-24_13-49-27': ondemand
------------------------------------------------------------------------------
:: Processing package changes...
(1/2) upgrading rclone                                                   [#########################################] 100%
(2/2) upgrading rsnapshot                                                [#########################################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
3 Likes

#16

Just thought I’d mention for those searching for this solution that naming of the file is very important. The hooks are run in alphabetical order, so you must ensure the timeshift hook is the first hook run. To make sure this happens preface the name with a number lower than any other hooks, such as:

/usr/share/libalpm/hooks/50-timeshift.hook

Sorry for waking an old thread, but with recent update troubles I thought this might be worth mentioning.

2 Likes

#17

Good point, that should be better kept in mind.
Currently there are not so many PreTransaction hooks, looks still relative harmless, that should no create any new drama :thinking:

$ find /usr/share/libalpm/hooks -type f -print0 | xargs -0 grep -i PreTransaction

/usr/share/libalpm/hooks/texinfo-remove.hook:When = PreTransaction
/usr/share/libalpm/hooks/gconf-remove.hook:When = PreTransaction
0 Likes

#18

Well my kernel hooks start at 60-. They seem to uninstall first, so you definitely want your snapshot taken before pre-transaction uninstalls are performed. Otherwise things could possibly get dramatic.

0 Likes

#19

You can try this script:
timeshift-autosnap

2 Likes

#20

Oh wow this seems to be what I was looking for. Testing it! Thank you!

0 Likes