lots of stuff
This commit is contained in:
@@ -343,7 +343,6 @@
|
|||||||
(setq browse-url-browser-function 'browse-url-generic)
|
(setq browse-url-browser-function 'browse-url-generic)
|
||||||
|
|
||||||
(use-package! tramp
|
(use-package! tramp
|
||||||
:defer t
|
|
||||||
:init
|
:init
|
||||||
;; TRAMP optimizations
|
;; TRAMP optimizations
|
||||||
;; See: https://coredumped.dev/2025/06/18/making-tramp-go-brrrr
|
;; See: https://coredumped.dev/2025/06/18/making-tramp-go-brrrr
|
||||||
@@ -369,3 +368,20 @@
|
|||||||
(with-eval-after-load 'compile
|
(with-eval-after-load 'compile
|
||||||
(remove-hook 'compilation-mode-hook
|
(remove-hook 'compilation-mode-hook
|
||||||
#'tramp-compile-disable-ssh-controlmaster-options)))
|
#'tramp-compile-disable-ssh-controlmaster-options)))
|
||||||
|
|
||||||
|
(use-package emms
|
||||||
|
:after emms-player-mpd
|
||||||
|
:config
|
||||||
|
(require 'emms-setup)
|
||||||
|
(require 'emms-player-mpd)
|
||||||
|
(emms-all)
|
||||||
|
(emms-default-players)
|
||||||
|
|
||||||
|
(setq emms-player-list '(emms-player-mpd)
|
||||||
|
emms-player-mpd-server-name "127.0.0.1"
|
||||||
|
emms-player-mpd-server-port "6660"
|
||||||
|
emms-player-mpd-music-directory "~/music")
|
||||||
|
|
||||||
|
(add-to-list 'emms-info-functions 'emms-info-mpd)
|
||||||
|
|
||||||
|
(emms-player-mpd-connect))
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ log_file "~/.local/share/mpd/log"
|
|||||||
pid_file "~/.local/share/mpd/pid"
|
pid_file "~/.local/share/mpd/pid"
|
||||||
state_file "~/.local/share/mpd/state"
|
state_file "~/.local/share/mpd/state"
|
||||||
sticker_file "~/.local/share/mpd/sticker.sql"
|
sticker_file "~/.local/share/mpd/sticker.sql"
|
||||||
bind_to_address "~/.local/share/mpd/socket"
|
port "6660"
|
||||||
|
bind_to_address "127.0.0.1"
|
||||||
|
|
||||||
audio_output {
|
audio_output {
|
||||||
type "pulse"
|
type "pulse"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
mpd_music_dir = "~/music"
|
|
||||||
|
|
||||||
mpd_host = "/home/opal/.local/share/mpd/socket"
|
mpd_host = "127.0.0.1"
|
||||||
mpd_port = "6600" # Ignored when using a socket
|
mpd_port = "6660"
|
||||||
|
mpd_music_dir = "/home/opal/music"
|
||||||
|
|
||||||
ncmpcpp_directory = "~/.config/ncmpcpp"
|
ncmpcpp_directory = "~/.config/ncmpcpp"
|
||||||
lyrics_directory = "~/.config/ncmpcpp/lyrics"
|
lyrics_directory = "~/.config/ncmpcpp/lyrics"
|
||||||
|
|||||||
8
.config/systemd/user/backup.service
Normal file
8
.config/systemd/user/backup.service
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Backup to external drive
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/home/opal/.local/bin/backup.sh
|
||||||
|
StandardOutput=append:/home/opal/.local/state/backup/backup.log
|
||||||
|
StandardError=append:/home/opal/.local/state/backup/backup.log
|
||||||
10
.config/systemd/user/backup.timer
Normal file
10
.config/systemd/user/backup.timer
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Daily backup to external drive
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=daily
|
||||||
|
Persistent=true
|
||||||
|
AccuracySec=5min
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
86
.local/bin/backup.sh
Executable file
86
.local/bin/backup.sh
Executable file
@@ -0,0 +1,86 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# === Config ===
|
||||||
|
BACKUP_NAME="$(hostname)_backup"
|
||||||
|
BACKUP_SRC="$HOME/docs $HOME/pics $HOME/code $HOME/dls"
|
||||||
|
PASSWORD_ENTRY="misc/backup-archive-password"
|
||||||
|
|
||||||
|
# Known external backup drives (UUID-based mount points)
|
||||||
|
BACKUP_DRIVE_PATHS=(
|
||||||
|
"/run/media/opal/e1f36c5c-4775-4549-8edc-1fa4d273b82e"
|
||||||
|
"/run/media/opal/790e21c0-77d3-4119-ad86-e9a6857fc89d"
|
||||||
|
)
|
||||||
|
|
||||||
|
# === Find first mounted backup drive ===
|
||||||
|
for path in "${BACKUP_DRIVE_PATHS[@]}"; do
|
||||||
|
if [ -d "$path" ] && mountpoint -q "$path"; then
|
||||||
|
DRIVE_ROOT="$path"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$DRIVE_ROOT" ]; then
|
||||||
|
echo "❌ No backup drive found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# === Create backup directory on drive ===
|
||||||
|
BACKUP_TARGET_DIR="$DRIVE_ROOT/backups/desktop_backups"
|
||||||
|
mkdir -p "$BACKUP_TARGET_DIR"
|
||||||
|
|
||||||
|
# === Create archive directly on the drive ===
|
||||||
|
TODAY=$(date +%F)
|
||||||
|
ARCHIVE="$BACKUP_TARGET_DIR/${BACKUP_NAME}_${TODAY}.7z"
|
||||||
|
|
||||||
|
PASSWORD=$(gopass show "$PASSWORD_ENTRY")
|
||||||
|
if [ -z "$PASSWORD" ]; then
|
||||||
|
echo "❌ Failed to get password from gopass"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "📦 Creating archive directly at $ARCHIVE..."
|
||||||
|
7z a -mhe=on -p"$PASSWORD" "$ARCHIVE" $BACKUP_SRC
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "❌ 7z compression failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# === Retention policy ===
|
||||||
|
echo "🧹 Applying retention policy..."
|
||||||
|
|
||||||
|
BASE="${BACKUP_NAME}_"
|
||||||
|
find "$BACKUP_TARGET_DIR" -maxdepth 1 -name "${BASE}*.7z" | while read -r file; do
|
||||||
|
fname=$(basename "$file")
|
||||||
|
date_part=$(echo "$fname" | sed -E "s/^${BASE}([0-9]{4}-[0-9]{2}-[0-9]{2})\.7z$/\1/")
|
||||||
|
|
||||||
|
if ! date -d "$date_part" >/dev/null 2>&1; then
|
||||||
|
echo "⚠️ Skipping unrecognized file: $fname"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
day_of_week=$(date -d "$date_part" +%u) # 7 = Sunday
|
||||||
|
day_of_month=$(date -d "$date_part" +%d) # 01 = first of month
|
||||||
|
month_day=$(date -d "$date_part" +%m-%d) # 01-01 = Jan 1
|
||||||
|
age_days=$(( ( $(date +%s) - $(date -d "$date_part" +%s) ) / 86400 ))
|
||||||
|
|
||||||
|
keep=0
|
||||||
|
|
||||||
|
if [ "$month_day" = "01-01" ]; then
|
||||||
|
keep=1 # yearly
|
||||||
|
elif [ "$day_of_month" = "01" ] && [ "$age_days" -le 180 ]; then
|
||||||
|
keep=1 # monthly
|
||||||
|
elif [ "$day_of_week" = "7" ] && [ "$age_days" -le 28 ]; then
|
||||||
|
keep=1 # weekly
|
||||||
|
elif [ "$age_days" -le 3 ]; then
|
||||||
|
keep=1 # daily
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$keep" -eq 1 ]; then
|
||||||
|
echo "📌 Keeping: $fname"
|
||||||
|
else
|
||||||
|
echo "🗑 Deleting: $fname"
|
||||||
|
rm -f "$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "✅ Backup complete."
|
||||||
Reference in New Issue
Block a user