This was asked in the LinuxQuestions forum and I replied there. The main idea is to make an exact copy of Arch Linux install from machine A to machine B. This includes all the packages of Machine A [excluding AUR] to be installed in Machine B. Why can’t we do that using AUR? SInce technically you are not using pacman to download and then install them, you are rather compiling the AUR packages yourself and installing them using pacman to keep a track of this package in your machine. Alright, let’s proceed. All your cache packages are stored in /var/cache/pacman/pkg by default unless you set another directory in your /etc/pacman.conf.First do this in your Machine A where Arch is installed with all your packages:
1. Get root privilege using “su”.
cp -r /var/cache/pacman/pkg/ /path/to/your/backup/dir
comm -13 <(pacman -Qmq | sort) <(pacman -Qqe | sort) > /path/to/backup/dir/pkglist
4. Now, install Arch in Machine B as you do.
5. Copy paste the contents of pkg from your backup directory to the /var/cache/pacman/pkg of your newly installed Arch in Machine B or create a custom repo. How to create a custom Arch repo? Simply edit /etc/pacman.d/mirrorlist and add at the top:
Server = file:///path/to/your/pkgs
Now pacman will look for packages from your backup directory instead of an internet mirror.
6. Finally re-install everything of Machine A to B [if you just want to install selected packages, either edit pkglist file that you had backed up previously or issue individual commands as you would do normally.]
pacman -S $(cat pkglist)