mom, we have ansible at home
This commit is contained in:
116
pkglist.txt
116
pkglist.txt
@@ -1,116 +0,0 @@
|
|||||||
7zip
|
|
||||||
amd-ucode
|
|
||||||
bambustudio-bin
|
|
||||||
base
|
|
||||||
base-devel
|
|
||||||
bat
|
|
||||||
bind
|
|
||||||
bluez
|
|
||||||
bluez-utils
|
|
||||||
bolt
|
|
||||||
brightnessctl
|
|
||||||
btop
|
|
||||||
cantarell-fonts
|
|
||||||
clang
|
|
||||||
cups
|
|
||||||
cups-pdf
|
|
||||||
direnv
|
|
||||||
discord
|
|
||||||
dunst
|
|
||||||
e2fsprogs
|
|
||||||
emacs-wayland
|
|
||||||
eza
|
|
||||||
fastfetch
|
|
||||||
fd
|
|
||||||
firefox
|
|
||||||
flatpak
|
|
||||||
foomatic-db
|
|
||||||
foomatic-db-engine
|
|
||||||
foomatic-db-nonfree-ppds
|
|
||||||
foomatic-db-ppds
|
|
||||||
freerdp
|
|
||||||
gdb
|
|
||||||
ghostty
|
|
||||||
gimp
|
|
||||||
git
|
|
||||||
go
|
|
||||||
gutenprint
|
|
||||||
imagemagick
|
|
||||||
inetutils
|
|
||||||
kanshi
|
|
||||||
keychain
|
|
||||||
lazygit
|
|
||||||
lib32-mesa
|
|
||||||
lib32-pipewire
|
|
||||||
lib32-vulkan-radeon
|
|
||||||
libreoffice-fresh
|
|
||||||
linux
|
|
||||||
linux-firmware
|
|
||||||
linux-lts
|
|
||||||
lldb
|
|
||||||
luarocks
|
|
||||||
man-db
|
|
||||||
man-pages
|
|
||||||
mosh
|
|
||||||
nano
|
|
||||||
networkmanager
|
|
||||||
nnn
|
|
||||||
noto-fonts
|
|
||||||
noto-fonts-cjk
|
|
||||||
noto-fonts-emoji
|
|
||||||
noto-fonts-extra
|
|
||||||
nss-mdns
|
|
||||||
omnissa-horizon-client
|
|
||||||
openssh
|
|
||||||
pacman-contrib
|
|
||||||
paru
|
|
||||||
paru-debug
|
|
||||||
pavucontrol
|
|
||||||
pcsc-tools
|
|
||||||
pipewire
|
|
||||||
pipewire-alsa
|
|
||||||
pipewire-jack
|
|
||||||
pipewire-pulse
|
|
||||||
ranger
|
|
||||||
reflector
|
|
||||||
ripgrep
|
|
||||||
rustup
|
|
||||||
sbcl
|
|
||||||
stow
|
|
||||||
sway
|
|
||||||
sway-contrib
|
|
||||||
swaybg
|
|
||||||
swayidle
|
|
||||||
swaylock
|
|
||||||
system-config-printer
|
|
||||||
texinfo
|
|
||||||
texlive-bibtexextra
|
|
||||||
texlive-fontsrecommended
|
|
||||||
texlive-latex
|
|
||||||
texlive-latexextra
|
|
||||||
texlive-plaingeneric
|
|
||||||
texlive-xetex
|
|
||||||
the_silver_searcher
|
|
||||||
tlp
|
|
||||||
tmux
|
|
||||||
ttf-dejavu
|
|
||||||
ttf-fira-code
|
|
||||||
ttf-hack-nerd
|
|
||||||
ttf-liberation
|
|
||||||
unzip
|
|
||||||
vlc
|
|
||||||
vlc-plugin-ffmpeg
|
|
||||||
vulkan-radeon
|
|
||||||
waybar
|
|
||||||
weechat
|
|
||||||
wget
|
|
||||||
wimlib
|
|
||||||
wireplumber
|
|
||||||
woff2-font-awesome
|
|
||||||
wofi
|
|
||||||
xdg-desktop-portal-wlr
|
|
||||||
xdg-user-dirs
|
|
||||||
xorg-xwayland
|
|
||||||
yubico-authenticator-bin
|
|
||||||
zoom
|
|
||||||
zsh
|
|
||||||
153
system-backup-20251125-125519.json
Normal file
153
system-backup-20251125-125519.json
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
{
|
||||||
|
"timestamp": "20251125-125519",
|
||||||
|
"packages": {
|
||||||
|
"pacman": [
|
||||||
|
"7zip",
|
||||||
|
"amd-ucode",
|
||||||
|
"base",
|
||||||
|
"base-devel",
|
||||||
|
"bat",
|
||||||
|
"bind",
|
||||||
|
"bluez",
|
||||||
|
"bluez-utils",
|
||||||
|
"bolt",
|
||||||
|
"brightnessctl",
|
||||||
|
"btop",
|
||||||
|
"cantarell-fonts",
|
||||||
|
"clang",
|
||||||
|
"cups",
|
||||||
|
"cups-pdf",
|
||||||
|
"direnv",
|
||||||
|
"discord",
|
||||||
|
"dunst",
|
||||||
|
"e2fsprogs",
|
||||||
|
"emacs-wayland",
|
||||||
|
"eza",
|
||||||
|
"fastfetch",
|
||||||
|
"fd",
|
||||||
|
"firefox",
|
||||||
|
"flatpak",
|
||||||
|
"foomatic-db",
|
||||||
|
"foomatic-db-engine",
|
||||||
|
"foomatic-db-nonfree-ppds",
|
||||||
|
"foomatic-db-ppds",
|
||||||
|
"freerdp",
|
||||||
|
"gdb",
|
||||||
|
"ghostty",
|
||||||
|
"gimp",
|
||||||
|
"git",
|
||||||
|
"go",
|
||||||
|
"gutenprint",
|
||||||
|
"imagemagick",
|
||||||
|
"inetutils",
|
||||||
|
"kanshi",
|
||||||
|
"keychain",
|
||||||
|
"lazygit",
|
||||||
|
"lib32-mesa",
|
||||||
|
"lib32-pipewire",
|
||||||
|
"lib32-vulkan-radeon",
|
||||||
|
"libreoffice-fresh",
|
||||||
|
"linux",
|
||||||
|
"linux-firmware",
|
||||||
|
"linux-lts",
|
||||||
|
"lldb",
|
||||||
|
"luarocks",
|
||||||
|
"man-db",
|
||||||
|
"man-pages",
|
||||||
|
"mosh",
|
||||||
|
"nano",
|
||||||
|
"networkmanager",
|
||||||
|
"nnn",
|
||||||
|
"noto-fonts",
|
||||||
|
"noto-fonts-cjk",
|
||||||
|
"noto-fonts-emoji",
|
||||||
|
"noto-fonts-extra",
|
||||||
|
"nss-mdns",
|
||||||
|
"openssh",
|
||||||
|
"pacman-contrib",
|
||||||
|
"pavucontrol",
|
||||||
|
"pcsc-tools",
|
||||||
|
"pipewire",
|
||||||
|
"pipewire-alsa",
|
||||||
|
"pipewire-jack",
|
||||||
|
"pipewire-pulse",
|
||||||
|
"ranger",
|
||||||
|
"reflector",
|
||||||
|
"ripgrep",
|
||||||
|
"rustup",
|
||||||
|
"sbcl",
|
||||||
|
"stow",
|
||||||
|
"sway",
|
||||||
|
"sway-contrib",
|
||||||
|
"swaybg",
|
||||||
|
"swayidle",
|
||||||
|
"swaylock",
|
||||||
|
"system-config-printer",
|
||||||
|
"texinfo",
|
||||||
|
"texlive-bibtexextra",
|
||||||
|
"texlive-fontsrecommended",
|
||||||
|
"texlive-latex",
|
||||||
|
"texlive-latexextra",
|
||||||
|
"texlive-plaingeneric",
|
||||||
|
"texlive-xetex",
|
||||||
|
"the_silver_searcher",
|
||||||
|
"tlp",
|
||||||
|
"tmux",
|
||||||
|
"ttf-dejavu",
|
||||||
|
"ttf-fira-code",
|
||||||
|
"ttf-hack-nerd",
|
||||||
|
"ttf-liberation",
|
||||||
|
"unzip",
|
||||||
|
"vlc",
|
||||||
|
"vlc-plugin-ffmpeg",
|
||||||
|
"vulkan-radeon",
|
||||||
|
"waybar",
|
||||||
|
"weechat",
|
||||||
|
"wget",
|
||||||
|
"wimlib",
|
||||||
|
"wireplumber",
|
||||||
|
"woff2-font-awesome",
|
||||||
|
"wofi",
|
||||||
|
"xdg-desktop-portal-wlr",
|
||||||
|
"xdg-user-dirs",
|
||||||
|
"xorg-xwayland",
|
||||||
|
"zsh"
|
||||||
|
],
|
||||||
|
"aur": [
|
||||||
|
"bambustudio-bin",
|
||||||
|
"omnissa-horizon-client",
|
||||||
|
"paru",
|
||||||
|
"paru-debug",
|
||||||
|
"yubico-authenticator-bin",
|
||||||
|
"zoom"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"systemd": {
|
||||||
|
"system": [
|
||||||
|
"bluetooth.service",
|
||||||
|
"getty@.service",
|
||||||
|
"NetworkManager-dispatcher.service",
|
||||||
|
"NetworkManager-wait-online.service",
|
||||||
|
"NetworkManager.service",
|
||||||
|
"reflector.service",
|
||||||
|
"systemd-boot-update.service",
|
||||||
|
"tlp.service",
|
||||||
|
"avahi-daemon.socket",
|
||||||
|
"cups.socket",
|
||||||
|
"pcscd.socket",
|
||||||
|
"systemd-userdbd.socket",
|
||||||
|
"remote-fs.target"
|
||||||
|
],
|
||||||
|
"user": [
|
||||||
|
"kanshi.service",
|
||||||
|
"wireplumber.service",
|
||||||
|
"xdg-user-dirs.service",
|
||||||
|
"p11-kit-server.socket",
|
||||||
|
"pipewire-pulse.socket",
|
||||||
|
"pipewire.socket"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"flatpak": [
|
||||||
|
"com.adamcake.Bolt"
|
||||||
|
]
|
||||||
|
}
|
||||||
119
system-backup.sh
119
system-backup.sh
@@ -2,56 +2,113 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
PKGLIST="pkglist.txt"
|
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
||||||
SYSTEMD_SYSTEM="systemd_enabled.txt"
|
BACKUP_FILE="system-backup-${TIMESTAMP}.json"
|
||||||
SYSTEMD_USER="systemd_user_enabled.txt"
|
|
||||||
|
|
||||||
show_help() {
|
show_help() {
|
||||||
echo "Usage: $0 [OPTION]"
|
echo "Usage: $0 [OPTION]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -b, --backup Create backup files of packages and systemd units"
|
echo " -b, --backup [filename] Create backup (default: system-backup-TIMESTAMP.json)"
|
||||||
echo " -r, --restore Restore packages and systemd units from backup files"
|
echo " -r, --restore <filename> Restore from backup file"
|
||||||
echo " -h, --help Show this help message"
|
echo " -h, --help Show this help message"
|
||||||
}
|
}
|
||||||
|
|
||||||
backup() {
|
backup() {
|
||||||
echo "Creating package list..."
|
local filename="${1:-$BACKUP_FILE}"
|
||||||
paru -Qqe > "$PKGLIST"
|
|
||||||
echo "Created $PKGLIST"
|
|
||||||
|
|
||||||
echo "Creating system unit list..."
|
echo "Creating backup..."
|
||||||
systemctl list-unit-files --state=enabled --no-pager | awk '{print $1}' > "$SYSTEMD_SYSTEM"
|
|
||||||
echo "Created $SYSTEMD_SYSTEM"
|
|
||||||
|
|
||||||
echo "Creating user unit list..."
|
# Get package lists (filtering out any integers/counts)
|
||||||
systemctl --user list-unit-files --state=enabled --no-pager | awk '{print $1}' > "$SYSTEMD_USER"
|
local pacman_pkgs=$(paru -Qqen | grep -v '^[0-9]*$')
|
||||||
echo "Created $SYSTEMD_USER"
|
local aur_pkgs=$(paru -Qqem | grep -v '^[0-9]*$')
|
||||||
|
|
||||||
echo "Backup complete."
|
# Get systemd units (filter headers, footers, and integers)
|
||||||
|
local system_units=$(systemctl list-unit-files --state=enabled --no-pager --no-legend | \
|
||||||
|
awk '{print $1}' | grep -E '\.(service|timer|socket|target|path|mount)$')
|
||||||
|
local user_units=$(systemctl --user list-unit-files --state=enabled --no-pager --no-legend | \
|
||||||
|
awk '{print $1}' | grep -E '\.(service|timer|socket|target|path|mount)$')
|
||||||
|
|
||||||
|
# Get flatpak list
|
||||||
|
local flatpak_pkgs=""
|
||||||
|
if command -v flatpak &> /dev/null; then
|
||||||
|
flatpak_pkgs=$(flatpak list --app --columns=application | tail -n +1 | grep -v '^[0-9]*$')
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build JSON
|
||||||
|
jq -n \
|
||||||
|
--arg timestamp "$TIMESTAMP" \
|
||||||
|
--arg pacman "$pacman_pkgs" \
|
||||||
|
--arg aur "$aur_pkgs" \
|
||||||
|
--arg system "$system_units" \
|
||||||
|
--arg user "$user_units" \
|
||||||
|
--arg flatpak "$flatpak_pkgs" \
|
||||||
|
'{
|
||||||
|
timestamp: $timestamp,
|
||||||
|
packages: {
|
||||||
|
pacman: ($pacman | split("\n") | map(select(length > 0))),
|
||||||
|
aur: ($aur | split("\n") | map(select(length > 0)))
|
||||||
|
},
|
||||||
|
systemd: {
|
||||||
|
system: ($system | split("\n") | map(select(length > 0))),
|
||||||
|
user: ($user | split("\n") | map(select(length > 0)))
|
||||||
|
},
|
||||||
|
flatpak: ($flatpak | split("\n") | map(select(length > 0)))
|
||||||
|
}' > "$filename"
|
||||||
|
|
||||||
|
echo "Backup created: $filename"
|
||||||
}
|
}
|
||||||
|
|
||||||
restore() {
|
restore() {
|
||||||
if [[ ! -f "$PKGLIST" ]]; then
|
local filename="$1"
|
||||||
echo "Error: $PKGLIST not found"
|
|
||||||
|
if [[ -z "$filename" ]]; then
|
||||||
|
echo "Error: No backup file specified"
|
||||||
|
show_help
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Installing packages..."
|
if [[ ! -f "$filename" ]]; then
|
||||||
paru -S --needed - < "$PKGLIST"
|
echo "Error: Backup file $filename not found"
|
||||||
|
exit 1
|
||||||
if [[ -f "$SYSTEMD_SYSTEM" ]]; then
|
|
||||||
echo "Enabling system units..."
|
|
||||||
while read unit; do
|
|
||||||
sudo systemctl enable "$unit" 2>/dev/null || echo "Skipping $unit"
|
|
||||||
done < "$SYSTEMD_SYSTEM"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$SYSTEMD_USER" ]]; then
|
# Ensure jq is installed
|
||||||
|
if ! command -v jq &> /dev/null; then
|
||||||
|
echo "Installing jq..."
|
||||||
|
sudo pacman -S --noconfirm jq
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Restoring from $filename..."
|
||||||
|
|
||||||
|
# Install pacman packages
|
||||||
|
echo "Installing official repository packages..."
|
||||||
|
jq -r '.packages.pacman[]' "$filename" | paru -S --needed --noconfirm -
|
||||||
|
|
||||||
|
# Install AUR packages
|
||||||
|
echo "Installing AUR packages..."
|
||||||
|
jq -r '.packages.aur[]' "$filename" | paru -S --needed --noconfirm -
|
||||||
|
|
||||||
|
# Enable system units
|
||||||
|
echo "Enabling system units..."
|
||||||
|
jq -r '.systemd.system[]' "$filename" | while read -r unit; do
|
||||||
|
[[ -n "$unit" ]] && sudo systemctl enable "$unit" 2>/dev/null || echo "Skipping $unit"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Enable user units
|
||||||
echo "Enabling user units..."
|
echo "Enabling user units..."
|
||||||
while read unit; do
|
jq -r '.systemd.user[]' "$filename" | while read -r unit; do
|
||||||
systemctl --user enable "$unit" 2>/dev/null || echo "Skipping $unit"
|
[[ -n "$unit" ]] && systemctl --user enable "$unit" 2>/dev/null || echo "Skipping $unit"
|
||||||
done < "$SYSTEMD_USER"
|
done
|
||||||
|
|
||||||
|
# Install flatpak packages
|
||||||
|
if command -v flatpak &> /dev/null; then
|
||||||
|
echo "Installing flatpak packages..."
|
||||||
|
jq -r '.flatpak[]' "$filename" | while read -r pkg; do
|
||||||
|
[[ -n "$pkg" ]] && flatpak install -y "$pkg" 2>/dev/null || echo "Skipping $pkg"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "Flatpak not installed, skipping flatpak packages"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Restore complete."
|
echo "Restore complete."
|
||||||
@@ -59,10 +116,10 @@ restore() {
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-b|--backup)
|
-b|--backup)
|
||||||
backup
|
backup "$2"
|
||||||
;;
|
;;
|
||||||
-r|--restore)
|
-r|--restore)
|
||||||
restore
|
restore "$2"
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
show_help
|
show_help
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
UNIT
|
|
||||||
bluetooth.service
|
|
||||||
getty@.service
|
|
||||||
NetworkManager-dispatcher.service
|
|
||||||
NetworkManager-wait-online.service
|
|
||||||
NetworkManager.service
|
|
||||||
reflector.service
|
|
||||||
systemd-boot-update.service
|
|
||||||
tlp.service
|
|
||||||
avahi-daemon.socket
|
|
||||||
cups.socket
|
|
||||||
pcscd.socket
|
|
||||||
systemd-userdbd.socket
|
|
||||||
remote-fs.target
|
|
||||||
|
|
||||||
13
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
UNIT
|
|
||||||
kanshi.service
|
|
||||||
wireplumber.service
|
|
||||||
xdg-user-dirs.service
|
|
||||||
p11-kit-server.socket
|
|
||||||
pipewire-pulse.socket
|
|
||||||
pipewire.socket
|
|
||||||
|
|
||||||
6
|
|
||||||
Reference in New Issue
Block a user