Skip to content

Instantly share code, notes, and snippets.

@idontwantcookies
Last active February 5, 2022 12:54
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save idontwantcookies/3425d52addf58c0a1b842506408f4c34 to your computer and use it in GitHub Desktop.
Save idontwantcookies/3425d52addf58c0a1b842506408f4c34 to your computer and use it in GitHub Desktop.
Simple bash scripts to backup and restore several archlinux config files
# Storing installed package names
echo $(pacman -Qentq) > pacman.bak
echo $(pacman -Qemtq) > yay.bak
echo $(pacman -Qdq) > pacman-optdep.bak
# Global config
cp /etc/pacman.conf pacman.conf.bak
cp -r /etc/pacman.d/ pacman.d.bak
cp /etc/hosts hosts.bak
cp /etc/hostname hostname.bak
cp /etc/vconsole.conf vconsole.conf.bak
cp /etc/resolvconf.conf resolvconf.conf.bak
cp /etc/localtime localtime.bak
cp /etc/locale.gen locale.gen.bak
cp /etc/locale.conf locale.conf.bak
cp -r /etc/X11/ X11.bak
# User config
cp ~/.bashrc bashrc.bak
cp ~/.zshrc zshrc.bak
# Highly recommended to clear cache from Chromium, Discord and similar apps before this recursive copy
cp -r ~/.config config.bak
# Restore global configuration files
sudo cp pacman.conf.bak /etc/pacman.conf
sudo cp -r pacman.d.bak /etc/pacman.d/
sudo cp hosts.bak /etc/hosts
sudo cp hostname.bak /etc/hostname
sudo cp vconsole.conf.bak /etc/vconsole.conf
sudo cp resolvconf.conf.bak /etc/resolvconf.conf
sudo cp localtime.bak /etc/localtime
sudo cp locale.gen.bak /etc/locale.gen
sudo locale-gen
sudo cp locale.conf.bak /etc/locale.conf
sudo cp -r X11.bak /etc/X11
# Restore user configuration files
cp bashrc.bak ~/.bashrc
cp zshrc.bak ~/.zshrc
# Restore packages
sudo pacman -Syu
sudo pacman -S --needed - < pacman.bak
# Install yay
sudo pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
cd ..
# Restore foreign packages
yay -S --needed < yay.bak
yay -S --needed --asdeps < pacmam-optdep.bak
# Restore user config folder
cp -r .config.bak ~/.config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment