|
|
@ -1,10 +1,16 @@
|
|
|
|
#!/bin/nu
|
|
|
|
#!/bin/nu
|
|
|
|
$env.BORG_REPO = '/run/media/trivernis/Backup'
|
|
|
|
|
|
|
|
|
|
|
|
let repo = '/run/media/trivernis/Backup/borg'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$env.BORG_REPO = $repo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let BACKUP_PATHS = ([
|
|
|
|
let BACKUP_PATHS = ([
|
|
|
|
~/Documents
|
|
|
|
~/Documents
|
|
|
|
~/Videos
|
|
|
|
~/Videos
|
|
|
|
~/Pictures/
|
|
|
|
~/Pictures/
|
|
|
|
~/Music
|
|
|
|
~/Music
|
|
|
|
|
|
|
|
~/Phone
|
|
|
|
~/.config
|
|
|
|
~/.config
|
|
|
|
~/.zshrc
|
|
|
|
~/.zshrc
|
|
|
|
~/.local
|
|
|
|
~/.local
|
|
|
@ -18,18 +24,29 @@ let BACKUP_PATHS = ([
|
|
|
|
] | path expand )
|
|
|
|
] | path expand )
|
|
|
|
|
|
|
|
|
|
|
|
if (pgrep borg | length) > 0 {
|
|
|
|
if (pgrep borg | length) > 0 {
|
|
|
|
echo "Borg is running"
|
|
|
|
print "Borg is running"
|
|
|
|
exit
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
borg break-lock
|
|
|
|
borg break-lock
|
|
|
|
echo "Creating archive"
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
(borg create
|
|
|
|
--progress
|
|
|
|
--progress
|
|
|
|
--warning
|
|
|
|
--warning
|
|
|
|
--filter AME
|
|
|
|
--filter AME
|
|
|
|
--compression zstd
|
|
|
|
--compression zstd
|
|
|
|
--exclude-caches
|
|
|
|
--exclude-caches
|
|
|
|
|
|
|
|
--exclude-if-present '.borgexclude'
|
|
|
|
|
|
|
|
--exclude-if-present 'Code Cache'
|
|
|
|
--exclude '*/.cache'
|
|
|
|
--exclude '*/.cache'
|
|
|
|
--exclude '*/Rust/*/target'
|
|
|
|
--exclude '*/Rust/*/target'
|
|
|
|
--exclude '*/target/debug'
|
|
|
|
--exclude '*/target/debug'
|
|
|
@ -39,6 +56,11 @@ echo "Creating archive"
|
|
|
|
--exclude '*/dynmap/web/tiles'
|
|
|
|
--exclude '*/dynmap/web/tiles'
|
|
|
|
--exclude '*/work/*decompile'
|
|
|
|
--exclude '*/work/*decompile'
|
|
|
|
--exclude '*/PortableGit*'
|
|
|
|
--exclude '*/PortableGit*'
|
|
|
|
|
|
|
|
--exclude '*/Cache'
|
|
|
|
|
|
|
|
--exclude '*/GpuCache'
|
|
|
|
|
|
|
|
--exclude '*/Code Cache'
|
|
|
|
|
|
|
|
--exclude '*/logs'
|
|
|
|
|
|
|
|
--exclude '*/.config/syncthing'
|
|
|
|
--exclude '*.pyc'
|
|
|
|
--exclude '*.pyc'
|
|
|
|
--exclude '*/Java/*/build'
|
|
|
|
--exclude '*/Java/*/build'
|
|
|
|
--exclude '*/Java/*/out/artifacts'
|
|
|
|
--exclude '*/Java/*/out/artifacts'
|
|
|
@ -47,12 +69,17 @@ echo "Creating archive"
|
|
|
|
--exclude '*/Kotlin/*/out'
|
|
|
|
--exclude '*/Kotlin/*/out'
|
|
|
|
--exclude '*/Kotlin/*/build'
|
|
|
|
--exclude '*/Kotlin/*/build'
|
|
|
|
--exclude '*/.local/share/Steam'
|
|
|
|
--exclude '*/.local/share/Steam'
|
|
|
|
|
|
|
|
--exclude '/mnt/Massdata/omenrescue'
|
|
|
|
|
|
|
|
--exclude '/mnt/Massdata/hydrus.enc.tar.zst'
|
|
|
|
|
|
|
|
--exclude '/mnt/Massdata/fakesys*.iso'
|
|
|
|
--list
|
|
|
|
--list
|
|
|
|
--stats
|
|
|
|
--stats
|
|
|
|
'::{hostname}-{now}'
|
|
|
|
'::{hostname}-{now}'
|
|
|
|
$BACKUP_PATHS
|
|
|
|
$BACKUP_PATHS
|
|
|
|
)
|
|
|
|
)
|
|
|
|
echo "Deleting old files"
|
|
|
|
|
|
|
|
|
|
|
|
print "Deleting old files"
|
|
|
|
|
|
|
|
|
|
|
|
(borg prune
|
|
|
|
(borg prune
|
|
|
|
--progress
|
|
|
|
--progress
|
|
|
|
--list
|
|
|
|
--list
|
|
|
@ -62,7 +89,8 @@ echo "Deleting old files"
|
|
|
|
--keep-weekly 2
|
|
|
|
--keep-weekly 2
|
|
|
|
--keep-monthly 1
|
|
|
|
--keep-monthly 1
|
|
|
|
)
|
|
|
|
)
|
|
|
|
echo "Running check for five minutes"
|
|
|
|
print "Running check for five minutes"
|
|
|
|
|
|
|
|
|
|
|
|
(borg check
|
|
|
|
(borg check
|
|
|
|
--progress
|
|
|
|
--progress
|
|
|
|
--repository-only
|
|
|
|
--repository-only
|
|
|
|