You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
1.9 KiB
Plaintext

10 months ago
#!/bin/nu
let repo = '/run/media/trivernis/Backup/borg'
$env.BORG_REPO = $repo
10 months ago
let BACKUP_PATHS = ([
~/Documents
~/Videos
~/Pictures/
~/Music
~/Phone
10 months ago
~/.config
~/.zshrc
~/.local
/mnt/Data/Cloud/Nextcloud/
/mnt/Data/Bilder/
/mnt/Data/Dokumente/
/mnt/Data/Filme/
/mnt/Data/Audio/
/mnt/Massdata/
/etc
] | path expand )
if (pgrep borg | length) > 0 {
print "Borg is running"
10 months ago
exit
}
10 months ago
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"
10 months ago
(borg create
--progress
--warning
--filter AME
--compression zstd
--exclude-caches
--exclude-if-present '.borgexclude'
--exclude-if-present 'Code Cache'
10 months ago
--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'
10 months ago
--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'
10 months ago
--list
--stats
'::{hostname}-{now}'
...$BACKUP_PATHS
10 months ago
)
print "Deleting old files"
10 months ago
(borg prune
--progress
--list
--glob-archives '{hostname}-*'
--show-rc
--keep-daily 2
--keep-weekly 2
--keep-monthly 1
)
print "Running check for five minutes"
10 months ago
(borg check
--progress
--repository-only
--max-duration 300
)