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.

100 lines
1.9 KiB
Plaintext

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