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