Hey guys, im trying to backup all of my installed packages on my computer in case I ever have to go and reinstall the OS. Anyone know how to do this?
You can save the list of all explicitly installed packages to a file:
pacman -Qeq > pkglist.txt
You can also save the foreign packages with:
pacman -Qmq > pkgforeign.txt
Then you can install all repo packages from the list with:
sudo pacman -S --needed $(comm -12 <(pacman -Slq | sort) <(sort pkglist.txt))
This will make sure to exclude all foreign packages from
You can then install the foreign packages manually, one by one. This is recommended, rather than doing it all together, as you might want to inspect each PKGBUILD file, and you will probably use
yay to install the packages from the AUR.
Is it possible to install AURS in a single go? I have alot of apps that are only available on AUR
Yes, but it’s a terrible idea to do so, as it is a huge security concern. Definitely not recommended.
Why is it considered a security concern? Just curious
Because you should inspect each PKGBUILD file when installing from the AUR, to make sure there isn’t anything malicious in them. Anyone can add packages to the AUR, and packages change maintainers.
What makes the AUR safe to use is the fact the Arch package build system is so transparent and allows the user to know exactly what goes into which package. But if you automate that process, that all goes away.
pacman -Qnq > pkglist.txt instead of
pacman -Qeq > pkglist.txt to save only repo packages in the first place . And keep separate file for foreign packages . That’s the way I use .
Edit : I actually use it to compare new installs for unnecessary packages . So that I can remove them easily . I have a habit of reinstalling system many times and distro hopping
Yes. It’s a matter of preference, really.
However, you should really save only explicitly installed packages, not the complete list, as dependencies will be pulled automatically. It’s not a good idea to explicitly install dependencies.
pacman -Qneq > pkglist.txt
This way is simpler because then the reinstall command is easy to remember:
sudo pacman -S --needed < pkglist.txt
Cool, thanks for the info! Um, is there a way to automate this? Im using the program Grsync and there’s an option to execute commands before and after Rsync starts
Yes, write those exact commands in a bash script and execute it from that program. The script can generate those two lists of packages and save them somewhere in your home directory before rsync and then rsync will save them on your backup drive.
There doesn’t seem to be an option to input a bash script <_>
The command is:
Updated my method . Thanks @Kresimir
Just in case you mean the package files, then you can find them all under
/var/cache/pacman/pkg/ . Just copy those somewhere else and you have a backup. This is probably more useful for AUR packages (those which require time for compilation) more than repo packages, though, as it’s trivial to recover a copy of repo packages.
Sorry for the delay! Unfornately I discovered that Rsync doesn’t allow me to backup on samba drives, particuarally it wont let me preserve permissions for all of the folders V_V So I had to switch back to Deja Dup but that program doesn’t support running scripts… how do I make a script that automatically generates a list of all of the packages installed so I can just plug in and run pacman to download everything?
Far from my work, but I think this explains what you are looking for:
No like, im wondering how do I make it autostart when I run a backup for Deja Dup? or is there any software out there that works with Samba shares and allows me to backup the entire home folder?
Those are two very different questions, which implies you’re not quite certain what you’re trying to accomplish.
The initial question about how to “backup all of my installed packages” has been answered, and there is no better way of doing that than the answer already provided.
If you want to create a shell script, or run a command periodically or under certain conditions, then that’s a different question for which the starting point should be, as always, a web search.
Then, once you have an idea about what you’re trying to do and have questions about that, a new thread will give you the opportunity to ask for purposeful help.
I eventually managed to create a NFS file server and got Grsync setup, so Im making the first post as the solution as the script worked