Removing old scripts, renaming and cleaning up
This commit is contained in:
48
Resticer
Executable file
48
Resticer
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
##Simple script to run Restic backups
|
||||
source $SCRIPTS/Okiru
|
||||
logging Restic
|
||||
|
||||
#Safety function; accepts repository to check
|
||||
safety(){
|
||||
#Check no other Restic process is using this repository; Free unnecessary locks, if present
|
||||
if [[ -n $(ps aux | grep restic | grep $1) ]]; then
|
||||
warn "Repository $1 is in use - ignoring"
|
||||
return 1
|
||||
# ^ If there's a restic process holding the repository, leave it alone.
|
||||
else
|
||||
info "Repository $1 is not in use - unlocking"
|
||||
restic -r b2:$1 unlock
|
||||
# ^ If a lock exists but no process, the repository is safe and should be unlocked.
|
||||
fi
|
||||
}
|
||||
#Backup function; accepts repository and path to backup
|
||||
backup(){
|
||||
#Check safety
|
||||
if safety $1; then
|
||||
#Run the backup
|
||||
if restic -r b2:$1 backup $2; then
|
||||
ok "Path $2 completed upload to $1." #Running integrity check"
|
||||
#Run integrity check
|
||||
# if restic -r b2:$1 check; then
|
||||
# echo "[OK]: Repository $1 is healthy"
|
||||
# Prune repository to avoid unnecessary data
|
||||
if restic -r b2:$1 prune; then
|
||||
ok "Repository $1 is trim"
|
||||
else
|
||||
error "Failed to prune repository $1!"
|
||||
fi
|
||||
# else
|
||||
# echo "[ERR]: Repository $1 failed integrity check!" > /dev/stderr
|
||||
# fi
|
||||
else
|
||||
error "Repository $1 failed to upload path $2!"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
#Pictures
|
||||
backup Gerbil-TK /Red-Vol/Media/Pictures/
|
||||
#Containers
|
||||
backup Pukeko-XYZ-Containers /Red-Vol/Media/Containers
|
||||
#Cloud
|
||||
backup Pukeko-XYZ-Cloud /Red-Vol/Media/Cloud/Syncthing
|
||||
Reference in New Issue
Block a user