Added a script that backups obsidian notes

This commit is contained in:
Tomas Rivera
2026-03-28 10:04:05 +01:00
parent fe5dd2d660
commit 929ee1d060
5 changed files with 83 additions and 16 deletions
+1
View File
@@ -78,6 +78,7 @@
(pkgs.callPackage ../../modules/scripts/manix.nix {}) (pkgs.callPackage ../../modules/scripts/manix.nix {})
(pkgs.callPackage ../../modules/scripts/man.nix {}) (pkgs.callPackage ../../modules/scripts/man.nix {})
(pkgs.callPackage ../../modules/scripts/trimmer.nix {}) (pkgs.callPackage ../../modules/scripts/trimmer.nix {})
(pkgs.callPackage ../../modules/scripts/obsidianbackup.nix {}) # periodically syncs obsidian's note to kdrive
(pkgs.callPackage ../../modules/scripts/QSsysinfo.nix {}) (pkgs.callPackage ../../modules/scripts/QSsysinfo.nix {})
(pkgs.callPackage ../../modules/scripts/QSnotifycache.nix {}) (pkgs.callPackage ../../modules/scripts/QSnotifycache.nix {})
(pkgs.callPackage ../../modules/scripts/QSnotifyhistory.nix {}) (pkgs.callPackage ../../modules/scripts/QSnotifyhistory.nix {})
+7 -6
View File
@@ -203,6 +203,7 @@ in {
"custom-mountkdrive" "custom-mountkdrive"
#"waybar" #"waybar"
"custom-gitnotify" "custom-gitnotify"
"custom-obsidianbackup" # backups the obsidian notes to kdrive and to a timed hidden dir (~/.Notes.backup/)
"QS-notifycache" # builds the cache that will be used for the notification history "QS-notifycache" # builds the cache that will be used for the notification history
######################### #########################
@@ -353,8 +354,8 @@ in {
"2, layout:scrolling, layoutopt:direction:right" "2, layout:scrolling, layoutopt:direction:right"
"name:special, layout:scrolling" "name:special, layout:scrolling"
# used for smart gaps along some windowrules # used for smart gaps along some windowrules
"w[tv1], gapsout:0, gapsin:0" "w[tv1], gapsout:1, gapsin:1"
"f[1], gapsout:0, gapsin:0" "f[1], gapsout:1, gapsin:1"
]; ];
# █░█░█ █ █▄░█ █▀▄ █▀█ █░█░█   █▀█ █░█ █░░ █▀▀ █▀ # █░█░█ █ █▄░█ █▀▄ █▀█ █░█░█   █▀█ █░█ █░░ █▀▀ █▀
@@ -415,10 +416,10 @@ in {
"float on, size 400 175, match:class ^(custom-librewolfprofiles)$" "float on, size 400 175, match:class ^(custom-librewolfprofiles)$"
"float on, size 600 600, match:initial_class ^(custom-pomodoro)$" "float on, size 600 600, match:initial_class ^(custom-pomodoro)$"
"float on, size 1500 800, match:initial_class ^(custom-bottom)$" "float on, size 1500 800, match:initial_class ^(custom-bottom)$"
"border_size 0, match:float 0, match:workspace w[tv1]" "border_size 2, match:float 0, match:workspace w[tv1]"
"rounding 0, match:float 0, match:workspace w[tv1]" "rounding 1, match:float 0, match:workspace w[tv1]"
"border_size 0, match:float 0, match:workspace f[1]" "border_size 2, match:float 0, match:workspace f[1]"
"rounding 0, match:float 0, match:workspace f[1]" "rounding 1, match:float 0, match:workspace f[1]"
]; ];
# add a float for tomato when in kitty # add a float for tomato when in kitty
#"plugin:imgborders:noimgborders, tag:noborder" #"plugin:imgborders:noimgborders, tag:noborder"
+9 -2
View File
@@ -7,7 +7,14 @@
enable = true; enable = true;
vaults.miscellanious = { vaults.miscellanious = {
enable = true; enable = true;
#target = "/kdrive/Notes/miscellanious"; #not directly to kdrive. It causes problems target = "/Documents/Notes/miscellanious"; # target is relative to ~ #not directly to kdrive. It causes problems
}; };
vaults.work = {
enable = true;
target = "/Documents/Notes/work";
};
defaultSettings = {
};
}; };
} }
+64
View File
@@ -0,0 +1,64 @@
{
writeShellApplication,
rclone,
libnotify,
rsync,
...
}:
writeShellApplication {
name = "custom-obsidianbackup";
runtimeInputs = [
rclone
libnotify
rsync
];
text = ''
#!/usr/bin/env bash
SOURCE_DIR="$HOME/Documents/Notes"
DEST_DIR="$HOME/kdrive/Notes"
BACKUP_DIR="$HOME/.Notes.backup"
mkdir -p "$DEST_DIR"
mkdir -p "$BACKUP_DIR"
while true; do
# Timestamp for this run
TIMESTAMP=$(date +%Y-%m-%d_%H-%M)
TIMESTAMPED_BACKUP="$BACKUP_DIR/$TIMESTAMP"
mkdir -p "$TIMESTAMPED_BACKUP"
echo "[$(date)] Starting Obsidian backup..."
# Check rclone mount
status=$(rclone about kdrive: 2>&1 || true)
if [[ "$status" =~ .*CRITICAL.* ]]; then
echo "[$(date)] rclone failed:"
echo "$status"
notify-send -u critical "rclone failed" \
"rclone might be broken or you need to deactivate this script in HomeManager."
else
# Run rsync with verbose debugging
echo "[$(date)] Running rsync..."
rsync -Lavh --progress --update --backup --backup-dir="$TIMESTAMPED_BACKUP" \
--exclude='.obsidian/cache/**' \
"$SOURCE_DIR/" "$DEST_DIR/"
echo "[$(date)] Backup completed for this run."
fi
# Safely remove backups older than 30 days
if [[ -d "$BACKUP_DIR" && "$BACKUP_DIR" == "$HOME/.Notes.backup" ]]; then
echo "[$(date)] Cleaning old backups..."
find "$BACKUP_DIR/" -mindepth 1 -maxdepth 1 -type d -mtime +30 -exec rm -rf {} \;
else
echo "[$(date)] Backup directory not safe. Skipping cleanup."
fi
# Wait 1 hour
echo "[$(date)] Sleeping for 1 hour..."
sleep 3600
done
'';
}
+2 -8
View File
@@ -1,20 +1,12 @@
audacity.x86_64 audacity.x86_64
biber.noarch
dolphin.x86_64 may be customized or nautilus cust dolphin.x86_64 may be customized or nautilus cust
ollama.x86_64 ollama.x86_64
plymouth.x86_64 plymouth.x86_64
python3.x86_64
qt6-qtwebsockets.x86_64 maybe copy from rivendel hy
quickshell.x86_64 quickshell.x86_64
raylib-devel.x86_64 raylib-devel.x86_64
some notification daemon 0.12-32.fc43 some notification daemon 0.12-32.fc43
texlive.noarch
texlive-biblatex.noarch
texlive-bibtex.x86_64
thunderbird.x86_64
tor.x86_64 tor.x86_64
torbrowser-launcher.noarch torbrowser-launcher.noarch
replace sddm by ly
maybe configure a bit ripgrep? majuscules maybe configure a bit ripgrep? majuscules
@@ -61,6 +53,8 @@ with quickshell:
maybe some kind of overview? maybe some kind of overview?
show battery percentage
see what people did with quickshell and take inspiration see what people did with quickshell and take inspiration
work on quickshell color palette to match gruvbox work on quickshell color palette to match gruvbox