Created
January 11, 2012 21:13
-
-
Save paulbarbu/1596790 to your computer and use it in GitHub Desktop.
Pacman pkg back-up and recovery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Backing up and retrieving a list of installed packages | |
It is good practice to keep periodic backups of all pacman-installed packages. In the event of a system crash which is unrecoverable by other means, pacman can then easily reinstall the very same packages onto a new installation. | |
First, backup the current list of non-local packages: | |
$ comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > pkglist | |
Store the pkglist on a USB key or other convenient medium or gist.github.com or evernote or dropbox. | |
Copy the pkglist file to the new installation, and navigate to the directory containing it. | |
Issue the following command to install from the backup list: | |
# pacman -S $(< pkglist) | |
In the case you have a list which was not generated like mentioned above, there may be foreign packages in it (i.e. packages not belonging to any repos you have configured, or packages from the AUR). | |
In such a case, you may still want to install all available packages from that list: | |
# pacman -S --needed $(diff <(cat badpkglist|sort) <(diff <(cat badpkglist|sort) <(pacman -Slq|sort)|grep \<|cut -f2 -d' ')|grep \<|cut -f2 -d' ') | |
Explanation: | |
pacman -Slq lists all available softwares, but the list is sorted by repository first, hence the sort command | |
Sorted files are required in order to make the diff command work. | |
The first diff returns all unavailable packages; the second all available packages. | |
The --needed switch is used to skip already installed packages. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment