scripts

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 52d1d5c5c4e442b36ea6d7af132e8520fd9f3bca
parent cc0094ed8098fc093aca8bb3a8f3c2cc522f030b
Author: Andrew Laack <andrew@laack.co>
Date:   Wed, 11 Mar 2026 01:25:08 -0500

Updated backup strategy + vm base configuration

Diffstat:
Mbackup.sh | 2+-
Abackups/old/pull.sh | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dbackups/pull.sh | 65-----------------------------------------------------------------
Abackups/simple.sh | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mvm-manager.sh | 30+++++++++++++++++++++++++-----
5 files changed, 168 insertions(+), 71 deletions(-)

diff --git a/backup.sh b/backup.sh @@ -3,7 +3,7 @@ set -o pipefail mkdir -p ~/logs -if ~/bin/backups/pull.sh | tee ~/logs/backup.log 2>&1; then +if ~/bin/backups/simple.sh | tee ~/logs/backup.log 2>&1; then echo "PASS: Backup Success" | tee -a ~/logs/backup.log date | tee -a ~/logs/backup-times.txt else diff --git a/backups/old/pull.sh b/backups/old/pull.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +COMMON_EXCLUDES=( + --exclude='.cache/' + --exclude='.local/' + --exclude='node_modules/' + --exclude='__pycache__/' + --exclude='vms/' + --exclude='.venv/' + --exclude='venv/' + --exclude='BraveSoftware/' + --exclude='librewolf/' + --exclude='gitRepos/' # this is all versioned... + --exclude='venv/' + --exclude='personal-files' # already synced in another way. + # TODO: Why am I even backing anything up from homes? Shouldn't there be one + # sync directory (probably in /srv?) and then that has git repos + one dir for other stuff. +) + +backup-vps () { + # Website + blog + mkdir -p /home/backup/vps/srv + rsync -v --delete --recursive root@laack.co:/srv/ /home/backup/vps/srv + + # Forgejo + mkdir -p /home/backup/vps/var + rsync -v --delete --recursive root@laack.co:/var/ /home/backup/vps/var + + # Other configuration + mkdir -p /home/backup/vps/etc + rsync -v --delete --recursive root@laack.co:/etc/ /home/backup/vps/etc +} + +shared-directories() { + # These are files that should be shared, source of truth is brgr + rsync -v --delete --recursive andrew@brgr:/home/andrew/personal-files ~ +} + +backup-brgr() { + + # These are private git repos + mkdir -p /home/backup/brgr/srv + rsync -v --delete --recursive andrew@brgr:/srv/ /home/backup/brgr/srv + + # Home directory + mkdir -p /home/backup/brgr/home + rsync -v --delete --recursive "${COMMON_EXCLUDES[@]}" andrew@brgr:/home/andrew /home/backup/brgr/home +} + +backup-deepthought() { + mkdir -p /home/backup/deepthought/home + rsync -v --delete --recursive "${COMMON_EXCLUDES[@]}" andrew@deepthought:/home/andrew /home/backup/deepthought/home +} + +if [ -n "$(hostnamectl | grep deepthought)" ] ; then + backup-vps + backup-brgr + shared-directories +fi + +# BRGR is source of truth for shared-directories +if [ -n "$(hostnamectl | grep brgr)" ] ; then + backup-vps + backup-deepthought +fi diff --git a/backups/pull.sh b/backups/pull.sh @@ -1,65 +0,0 @@ -#!/bin/bash - -COMMON_EXCLUDES=( - --exclude='.cache/' - --exclude='.local/' - --exclude='node_modules/' - --exclude='__pycache__/' - --exclude='vms/' - --exclude='.venv/' - --exclude='venv/' - --exclude='BraveSoftware/' - --exclude='librewolf/' - --exclude='gitRepos/' # this is all versioned... - --exclude='venv/' - --exclude='personal-files' # already synced in another way. - # TODO: Why am I even backing anything up from homes? Shouldn't there be one - # sync directory (probably in /srv?) and then that has git repos + one dir for other stuff. -) - -backup-vps () { - # Website + blog - mkdir -p /home/backup/vps/srv - rsync -v --delete --recursive root@laack.co:/srv/ /home/backup/vps/srv - - # Forgejo - mkdir -p /home/backup/vps/var - rsync -v --delete --recursive root@laack.co:/srv/ /home/backup/vps/var - - # Other configuration - mkdir -p /home/backup/vps/etc - rsync -v --delete --recursive root@laack.co:/srv/ /home/backup/vps/etc -} - -shared-directories() { - # These are files that should be shared, source of truth is brgr - rsync -v --delete --recursive andrew@brgr:/home/andrew/personal-files ~ -} - -backup-brgr() { - - # These are private git repos - mkdir -p /home/backup/brgr/srv - rsync -v --delete --recursive andrew@brgr:/srv/ /home/backup/brgr/srv - - # Home directory - mkdir -p /home/backup/brgr/home - rsync -v --delete --recursive "${COMMON_EXCLUDES[@]}" andrew@brgr:/home/andrew /home/backup/brgr/home -} - -backup-deepthought() { - mkdir -p /home/backup/deepthought/home - rsync -v --delete --recursive "${COMMON_EXCLUDES[@]}" andrew@deepthought:/home/andrew /home/backup/deepthought/home -} - -if [ -n "$(hostnamectl | grep deepthought)" ] ; then - backup-vps - backup-brgr - shared-directories -fi - -# BRGR is source of truth for shared-directories -if [ -n "$(hostnamectl | grep brgr)" ] ; then - backup-vps - backup-deepthought -fi diff --git a/backups/simple.sh b/backups/simple.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# ======== BOOLEANS TO SYNC ======== + +# backup laack.co vps +BACKUP_VPS=true +# backup brgr +BACKUP_SRV=true +# sync personal-files from brgr ~ +SYNC_SHARED_DIR=true + + +HOSTNAME_BRGR=$(hostnamectl | grep brgr) + +if [ -n "$HOSTNAME_BRGR" ]; then + BACKUP_SRV=false + SYNC_SHARED_DIR=false +fi + +# ======== SOURCES OF TRUTH ======== + +# Where should data be saved? + +# 1. Git (public | private) 2. Sync Directory +# +# Git +# - **non-binary** data should in git repos. +# - private: +# - these live at brgr:/srv/git/private-repos/ +# - public: +# - these live at root@laack.co:/var/lib/forgejo +# Sync directory +# - brgr:~/personal-files +# - this is where music, videos, photos, and large encrypted data should live +# +# Backups should be of /srv/ on brgr and /var/lib/forgejo on the vps. +# +# Synced data should be in ~/personal-files. These don't really require backups because they +# are just nice to have on all systems. + + +# ======== BACKUP DEFINITIONS ======== + +backup-vps () { + mkdir -p /home/backup/vps/var + rsync -v --delete --recursive root@laack.co:/var/ /home/backup/vps/var + + # TODO: Consider refactoring this. This sort of breaks with convention, but there is + # nginx configuration data here that is a source of truth... + + mkdir -p /home/backup/vps/etc + rsync -v --delete --recursive root@laack.co:/etc/ /home/backup/vps/etc +} + + +backup-srv() { + # backup private git repos + any additional things in srv (shouldn't be for now) + mkdir -p /home/backup/brgr/srv + rsync -v --delete --recursive andrew@brgr:/srv/ /home/backup/brgr/srv +} + +sync-shared() { + rsync -v --delete --recursive andrew@brgr:/home/andrew/personal-files ~ +} + + +if [ $BACKUP_VPS == "true" ]; then + backup-vps +fi + +if [ $BACKUP_SRV == "true" ]; then + backup-srv +fi + +if [ $SYNC_SHARED_DIR == "true" ]; then + sync-shared +fi diff --git a/vm-manager.sh b/vm-manager.sh @@ -13,9 +13,29 @@ else fi if [[ -n "$SELECTION" ]]; then - qemu-system-x86_64 "$SELECTION" \ - -cpu host \ - -enable-kvm \ - -smp 4 \ - -m 8G + if [ -n "$(hostnamectl | grep brgr)" ] ; then + + # brgr has 48gb of ddr4 ram + # bought this before everyone went crazy with RAM prices :) + + qemu-system-x86_64 "$SELECTION" \ + -cpu host \ + -enable-kvm \ + -smp 4 \ + -m 24G + else + + # laptop only has 16gb (from like 5 years ago too) + # this seems like a sane default for running most things + # reasonably well. + # + # No, I do not support the apple idea of 8gb being the new + # 16gb, that's just marketing nonsense. + + qemu-system-x86_64 "$SELECTION" \ + -cpu host \ + -enable-kvm \ + -smp 4 \ + -m 8G + fi fi