mauville/aly/backblaze-sync: add binPath

This commit is contained in:
Aly Raffauf 2024-09-08 23:20:42 -04:00
parent 4a19dcd37c
commit 6f7f1d6073

View file

@ -40,25 +40,36 @@
services.backblaze-sync = { services.backblaze-sync = {
Unit.Description = "Backup to Backblaze."; Unit.Description = "Backup to Backblaze.";
Service.ExecStart = "${pkgs.writeShellScript "backblaze-sync" '' Service = {
declare -A backups Environment = [
backups=( "PATH=${
['/home/aly/pics/camera']="b2://aly-camera" lib.makeBinPath (with pkgs; [
['/home/aly/sync']="b2://aly-sync" coreutils
['/mnt/Media/Audiobooks']="b2://aly-audiobooks" backblaze-b2
['/mnt/Media/Music']="b2://aly-music" ])
) }"
];
# Recursively backup folders to B2 with sanity checks. ExecStart = "${pkgs.writeShellScript "backblaze-sync" ''
for folder in "''${!backups[@]}"; do declare -A backups
if [ -d "$folder" ] && [ "$(ls -A "$folder")" ]; then backups=(
${lib.getExe pkgs.backblaze-b2} sync --delete $folder ''${backups[$folder]} ['/home/aly/pics/camera']="b2://aly-camera"
else ['/home/aly/sync']="b2://aly-sync"
echo "$folder does not exist or is empty." ['/mnt/Media/Audiobooks']="b2://aly-audiobooks"
exit 1 ['/mnt/Media/Music']="b2://aly-music"
fi )
done
''}"; # Recursively backup folders to B2 with sanity checks.
for folder in "''${!backups[@]}"; do
if [ -d "$folder" ] && [ "$(ls -A "$folder")" ]; then
backblaze-b2 sync --delete $folder ''${backups[$folder]}
else
echo "$folder does not exist or is empty."
exit 1
fi
done
''}";
};
}; };
timers.backblaze-sync = { timers.backblaze-sync = {