mirror of
https://github.com/alyraffauf/nixcfg.git
synced 2024-11-22 15:03:55 -05:00
mauville: added sanity checks to backup script
This commit is contained in:
parent
dea16e6f64
commit
0b5bab79d3
|
@ -78,14 +78,23 @@
|
||||||
};
|
};
|
||||||
Service = {
|
Service = {
|
||||||
ExecStart = "${pkgs.writeShellScript "backblaze-sync" ''
|
ExecStart = "${pkgs.writeShellScript "backblaze-sync" ''
|
||||||
BACKBLAZE=${lib.getExe pkgs.backblaze-b2}
|
declare -A backups
|
||||||
|
backups=(
|
||||||
$BACKBLAZE sync --delete /mnt/Media/Music b2://aly-music
|
['/home/aly/pics/camera']="b2://aly-camera"
|
||||||
$BACKBLAZE sync --delete /mnt/Media/Audiobooks b2://aly-audiobooks
|
['/home/aly/sync']="b2://aly-sync"
|
||||||
$BACKBLAZE sync --delete /mnt/Archive/Archive b2://aly-archive
|
['/mnt/Archive/Archive']="b2://aly-archive"
|
||||||
|
['/mnt/Media/Audiobooks']="b2://aly-audiobooks"
|
||||||
$BACKBLAZE sync --delete /home/aly/sync b2://aly-sync
|
['/mnt/Media/Music']="b2://aly-music"
|
||||||
$BACKBLAZE sync --delete /home/aly/pics/camera b2://aly-camera
|
)
|
||||||
|
# Recursively backup folders to B2 with sanity checks.
|
||||||
|
for folder in "''${!backups[@]}"; do
|
||||||
|
if [ -d "$folder" ] && [ "$(ls -A "$folder")" ]; then
|
||||||
|
${lib.getExe pkgs.backblaze-b2} sync --delete $folder ''${backups[$folder]}
|
||||||
|
else
|
||||||
|
echo "$folder does not exist or is empty."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
''}";
|
''}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue