26 Dec


Me again.

For Christmas this year my stuffed tiger and life long guardian Dr. Tigums purchased me one shiny new X1 Carbon 8th gen to use as a personal laptop as I begin to re-imagine my career in tech. I had a 7th gen at my last job a security engineer and I absolutely loved it for so many reasons.

Anyway if you know anything about me you know that I have about a dozen arch linux computers here at the house, most of which are servers. However, there are a number of machines (my new laptop included) that I use as a personal work machine.

So. How do I backup and persist my arch linux installations across machines such that I can rebuild quickly and reliably?

The Kernel

I run the same kernel across all my development machines. Unless of course I am working on something that requires a specific kernel version, in which case I will flip out a new image for the afternoon typically compiled from source. Also all my computers are named after common transgender women names. You know. Just because. My new laptop is named Emma.

I maintain this by keeping my packages up to date using the built in pacman package manager. For AUR packages I use pacaur and always make it a point to view the source before compiling.

Installing pacaur on a fresh system

Getting pacaur set up for the first time can be a pain in the ass. Here is how I do it.

I create a $HOME/src directory for all manually built AUR packages (yes I read the source).

mkdir $HOME/src
cd $HOME/src
# auracle-git is required by pacaur
wget https://aur.archlinux.org/cgit/aur.git/snapshot/auracle-git.tar.gz
tar -xzf auracle-git.tar.gz
cd auracle-git
makepkg -si
cd ../
# now we can install pacaur
wget https://aur.archlinux.org/cgit/aur.git/snapshot/pacaur.tar.gz
tar -xzf pacaur.tar.gz
cd pacaur
pacman -S jq expac
makepkg -si

Groovy. Now we can easily install packages from the AUR using the same syntax as pacman and trying the official repositories first.


Okay now here is where things get interesting.

I like to keep a cache of all the packages (including AUR packages) on a machine by machine basis. I have a private git repository that I store all my home directory magic in. I keep most of that secret sauce to myself.

Regardless, here is a small part of my bash system that I use to cache packages. Whenever I open up a new bash shell (yes I use bash) I run a quick and light weight cache dump.

Notice how we have a unique ID. This is calculated using lsblk. I then dump the package list to my home directory and voila now I now have a cache of every package on the system that I can easily git push to my repository.

COMPUTERID=$(lsblk -nro SERIAL | head -n 1)                                                                                                 
pkgs=$(pacaur -Q | cut -f 1 -d " ")                                                                                                         
echo $pkgs > ~/rc/package.list.${COMPUTERID}                                                                                                
echo "ID: ${COMPUTERID}"  

Now as I begin screwing around with packages and rebuilding kernel modules and effectively completely fucking over my system I at least have a place of sanity I can come back to. I can simply sync from the master list.

And now we have a unique package list and standard kernel across all my happy little arch linux machines. Easy to back up and easy to restore from.

Happy holidays. Remember to tell everyone you love how much you love them.