#!/bin/nu let repo = '/run/media/trivernis/Backup/borg' $env.BORG_REPO = $repo let BACKUP_PATHS = ([ ~/Documents ~/Videos ~/Pictures ~/Music ~/Phone ~/.config ~/.zshrc ~/.local /mnt/Data/Cloud/Nextcloud/ /mnt/Data/Bilder/ /mnt/Data/Dokumente/ /mnt/Data/Filme/ /mnt/Data/Audio/ /mnt/Data/Musik/ /mnt/Massdata/ /etc ] | path expand ) if (pgrep borg | length) > 0 { print "Borg is running" exit } borg break-lock let occ = df $repo --output=pcent | split row "\n" | get 1 | str replace "%" "" | into float if $occ > 95 { print "Over 95% of disk space is used! Compacting..." borg compact $repo --progress --threshold 5 -v } print "Creating archive" (borg create --progress --warning --filter AME --compression zstd --exclude-caches --exclude-if-present '.borgexclude' --exclude-if-present 'Code Cache' --exclude '*/.cache' --exclude '*/Rust/*/target' --exclude '*/target/debug' --exclude '*/target/release' --exclude '*/node_modules' --exclude '*/massdata.tar.gz' --exclude '*/dynmap/web/tiles' --exclude '*/work/*decompile' --exclude '*/PortableGit*' --exclude '*/Cache' --exclude '*/GpuCache' --exclude '*/Code Cache' --exclude '*/logs' --exclude '*/.config/syncthing' --exclude '*.pyc' --exclude '*/Java/*/build' --exclude '*/Java/*/out/artifacts' --exclude '*/Java/*/target' --exclude '*/Kotlin/*/target' --exclude '*/Kotlin/*/out' --exclude '*/Kotlin/*/build' --exclude '*/.local/share/Steam' --exclude '/mnt/Massdata/omenrescue' --exclude '/mnt/Massdata/hydrus.enc.tar.zst' --exclude '/mnt/Massdata/fakesys*.iso' --list --stats '::{hostname}-{now}' ...$BACKUP_PATHS ) print "Deleting old files" (borg prune --progress --list --glob-archives '{hostname}-*' --show-rc --keep-daily 5 --keep-weekly 3 --keep-monthly 3 ) print "Running check for five minutes" (borg check --progress --repository-only --max-duration 300 )