This item is more of a script than a function, but it seems to me that it fits here better than in a wiki entry! Essentially, it automates the Arch “Wayback Machine” or, as I have called it ShiftTime What this ‘Machine’ does essentially, is take your system back to the date that you specify - by reverting, or downgrading all the packages that have been updated after that date.
I decided I would try to make the script accessible, so here I will describe setting it up as a button in the Welcome app - although of course it would work fine if just called from the command line. Or, of course, you could carefully read the Archwiki entry on reverting your package status to a previous date, and follow the steps as they describe them.
Essentially, there are 2 pieces to the setup - the script itself, and the .desktop file that describes it. The locations they need to be in may have to be created if they do not already exist:
- $ mkdir -p ~/.local/share/applications
This command will create this directory if it does not already exist. The following .desktop file goes in it - with the name ShiftTime.desktop suggested.
.desktop
[Desktop Entry]
Name=ShiftTime
Comment=Revert pkg state to a previous date.
GenericName=Revert pkg state to a previous date
Exec=RunInTerminal shifttime
Icon=system-software-install
Type=Application
NoDisplay=true
StartupNotify=true
Categories=Utility
- Then you create a file called shifttime with the following content:
ShiftTime script
#!/bin/bash
# This script enables an after-the-fact timeshift equivalent for Arch systems
# Give it a date (as in 2020-09-20) and it will use the Arch archive repos
# to revert to that date's package state.
#
# 21 September 2020 - freebird54
echo "Select the date to revert your packages to. Press ENTER when ready"
read
REVERTDATE=`yad --calendar --date-format=%C%y/%m/%d`
echo " "
echo "Packages will be reverted to the state they were in on $REVERTDATE."
echo " "
echo "Ready to copy /etc/pacman.d/mirrorlist to backup"
sudo mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup_st
# building the repo entry for the specified date, and making it the mirrorlist temoporarily
echo "Server=https://archive.archlinux.org/repos/$REVERTDATE/\$repo/os/\$arch" > /tmp/mirrorlistchk
sudo cp /tmp/mirrorlistchk /etc/pacman.d/mirrorlist
rm /tmp/mirrorlistchk
echo " "
echo "Here is the reversion mirrorlist"
cat /etc/pacman.d/mirrorlist
echo "If the date shown is correct please press ENTER"
read
echo " "
# run the 'downdate' command
sudo pacman -Syyuu
echo " "
echo "Restoring the backup mirrorlist..."
sudo cp /etc/pacman.d/mirrorlist.backup_st /etc/pacman.d/mirrorlist
echo " "
echo "Done. Press ENTER to exit."
read
-
Make the file executable:
$ chmod +x shifttime -
Copy the file to somewhere on your path:
$ sudo cp shifttime /usr/bin -
Start up the Welcome app, choose the ‘Tips’ tab, and click on the Personal Command drag&drop button - which will open up a window. Open your File Browser, navigate to ~/.local/share/applications, and drag ShiftTime.desktop over to and drop it in the window that Welcome opened up.
-
That’s it! Once Welcome comes back, it will have a Personal Commands tab (if it didn’t already) and ShiftTime will be waiting for you to click on the button showing its name to run the script. Pacman will be called to determine which packages need to be downgraded to revert your system to the way it was at the date you specified. You can interact with pacman as usual to decide whether or not to proceed with the downgrade. The pacman ‘control’ files that the script modifies will be returned to normal after the modified ones have been used.
Again, this does nothing you could not do directly yourself by following the Archwiki - but it saves typing (or looking it up again) if you happen to need it. This also shows how easy it is to add your own ideas to the buttons on the Welcome app! Essentially, for most things, all you need to do is create an appropriate .desktop file, and drop it in the drag&drop window. Enjoy, and I hope you don’t need it.