Simple Manjaro Package List Backup and Restore

Easier for future re-installation

17 Sep 2018
Back to blog

I have composed a pretty simple script that would assist you on installing packages automatically for you when you need it.

There are 2 scripts, one is to save all the packages names into a file, and the other is used to install those packages after reading from the file.

AUR Compatibility

This script will of course back up the AUR packages names and also restore them when ran. The script however will attempt to install an AUR helper yay first in order to fully automatically install AUR packages with minimal user interaction.

Some might think: we already have pamac-cli, why must use an AUR helper? The answer is because pamac-cli asks every single time if you want to install a package, and this is rather annoying. AUR helpers do not do this, and I have chosen yay for my needs.

If you wish to use pamac-cli, simply loop each line from the zpkglist.txt file and pass to (where var is the variable containing the line):

pamac build ${var}

Use on Arch

As Manjaro is an Arch derivative, this script can also be used with Arch. However, you will need to figure out on how to install yay from the AUR for your Arch installation. If you are a strictly-repository-person, you may change yay to pacman in Don't forget to also remove the relevant line in the snippet below.


b=$(tput bold)
n=$(tput sgr0)
function divider {
    echo "--------------------------------------------------------------------------------"
title="Restore (Install) Packages"
echo -ne "\033]0;${title}\007"
echo "================================================================================"
echo " ${b}${title}${n}"
echo "================================================================================"
echo "Making sure all currently installed packages are updated"
if hash yay; then
    pacman -Syu
    echo "Installing yay AUR helper"
    pamac build yay-bin
echo "Removing packages not present in backup"
yay -Rsun --noconfirm $(comm -23 <(yay -Qq | sort) <(sort zpkglist.txt))
echo "Restoring"
yay -S --needed --noconfirm - < zpkglist.txt
echo "Clearing cache"
yay -Scc
echo "Restoration completed!"
zenity --info --ellipsize --title="${title}" --text="Restoration completed!"


echo "Storing list of repo packages to pkglist.txt"
pacman -Qqen > zpkglist.txt || { echo "Error occured here. ENTER to continue" && read; }
echo "Storing list of AUR packages to pkglist.txt"
pacman -Qqem >> zpkglist.txt || { echo "Error occured here. ENTER to continue" && read; }

Published on:

Get notified of new posts