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
100 lines
1.9 KiB
Plaintext
10 months ago
|
#!/bin/nu
|
||
10 months ago
|
|
||
|
let repo = '/run/media/trivernis/Backup/borg'
|
||
|
|
||
|
$env.BORG_REPO = $repo
|
||
|
|
||
|
|
||
10 months ago
|
let BACKUP_PATHS = ([
|
||
|
~/Documents
|
||
|
~/Videos
|
||
9 months ago
|
~/Pictures
|
||
10 months ago
|
~/Music
|
||
10 months ago
|
~/Phone
|
||
10 months ago
|
~/.config
|
||
|
~/.zshrc
|
||
|
~/.local
|
||
|
/mnt/Data/Cloud/Nextcloud/
|
||
|
/mnt/Data/Bilder/
|
||
|
/mnt/Data/Dokumente/
|
||
|
/mnt/Data/Filme/
|
||
|
/mnt/Data/Audio/
|
||
9 months ago
|
/mnt/Data/Musik/
|
||
10 months ago
|
/mnt/Massdata/
|
||
|
/etc
|
||
|
] | path expand )
|
||
|
|
||
|
if (pgrep borg | length) > 0 {
|
||
10 months ago
|
print "Borg is running"
|
||
10 months ago
|
exit
|
||
|
}
|
||
|
|
||
10 months ago
|
|
||
10 months ago
|
borg break-lock
|
||
10 months ago
|
|
||
|
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
|
||
10 months ago
|
--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*'
|
||
10 months ago
|
--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'
|
||
10 months ago
|
--exclude '/mnt/Massdata/omenrescue'
|
||
|
--exclude '/mnt/Massdata/hydrus.enc.tar.zst'
|
||
|
--exclude '/mnt/Massdata/fakesys*.iso'
|
||
10 months ago
|
--list
|
||
|
--stats
|
||
|
'::{hostname}-{now}'
|
||
10 months ago
|
...$BACKUP_PATHS
|
||
10 months ago
|
)
|
||
10 months ago
|
|
||
|
print "Deleting old files"
|
||
|
|
||
10 months ago
|
(borg prune
|
||
|
--progress
|
||
|
--list
|
||
|
--glob-archives '{hostname}-*'
|
||
|
--show-rc
|
||
9 months ago
|
--keep-daily 5
|
||
|
--keep-weekly 3
|
||
|
--keep-monthly 3
|
||
10 months ago
|
)
|
||
10 months ago
|
print "Running check for five minutes"
|
||
|
|
||
10 months ago
|
(borg check
|
||
|
--progress
|
||
|
--repository-only
|
||
|
--max-duration 300
|
||
10 months ago
|
)
|