From 4b126b6b65e5fadb43926a4028012f5ea66f7a7c Mon Sep 17 00:00:00 2001 From: albert Date: Wed, 8 May 2024 08:02:08 +0900 Subject: [PATCH] Update backup scripts --- .../common/desktops/hyprland/components/swaylock.nix | 3 +-- nixos/hosts/backups-rpi4/backup-script.nix | 4 ++-- nixos/hosts/backups-rpi4/scripts/rsync-data-vol.sh | 3 ++- nixos/hosts/backups-rpi4/scripts/rsync-media.sh | 3 ++- nixos/hosts/backups-rpi4/scripts/rsync-sysctl.sh | 5 ++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/home-manager/common/desktops/hyprland/components/swaylock.nix b/home-manager/common/desktops/hyprland/components/swaylock.nix index 874e808a..bb6fd12f 100644 --- a/home-manager/common/desktops/hyprland/components/swaylock.nix +++ b/home-manager/common/desktops/hyprland/components/swaylock.nix @@ -6,9 +6,8 @@ # All options are of the form . # font-size = 96; show-failed-attempts = true; - effect-blur = "20x8"; + effect-blur = "30x8"; screenshots = true; - fade-in = 0.2; clock = true; timestr = "%R"; diff --git a/nixos/hosts/backups-rpi4/backup-script.nix b/nixos/hosts/backups-rpi4/backup-script.nix index e6b143e0..e13879bf 100644 --- a/nixos/hosts/backups-rpi4/backup-script.nix +++ b/nixos/hosts/backups-rpi4/backup-script.nix @@ -1,11 +1,11 @@ { pkgs, ... }: let rsync-data-vol = pkgs.writeScriptBin "rsync-data-vol" "${builtins.readFile ./scripts/rsync-data-vol.sh}"; - rsync-backups = pkgs.writeScriptBin "rsync-backups" "${builtins.readFile ./scripts/rsync-media.sh}"; + rsync-media = pkgs.writeScriptBin "rsync-media" "${builtins.readFile ./scripts/rsync-media.sh}"; rsync-sysctl = pkgs.writeScriptBin "rsync-sysctl" "${builtins.readFile ./scripts/rsync-sysctl.sh}"; in { environment.systemPackages = [ - rsync-backups + rsync-media rsync-data-vol rsync-sysctl ]; diff --git a/nixos/hosts/backups-rpi4/scripts/rsync-data-vol.sh b/nixos/hosts/backups-rpi4/scripts/rsync-data-vol.sh index c1c3c3cf..8891a837 100644 --- a/nixos/hosts/backups-rpi4/scripts/rsync-data-vol.sh +++ b/nixos/hosts/backups-rpi4/scripts/rsync-data-vol.sh @@ -27,7 +27,8 @@ if [[ $mounted1 != 0 ]] || [[ $mounted2 != 0 ]] || [[ $mounted3 != 0 ]] ; then fi # If an old backup is still running, don't continue -if [[ `ps aux | grep $BACKUP_NAME | grep -v grep` ]] ; then +count=$(ps aux | grep $BACKUP_NAME | grep -v grep | wc -l) +if [[ $count -ge 1 ]] ; then echo -e "$BACKUP_NAME rsync still running. Exiting...." payload="{\"message\": \"$BACKUP_NAME stopped. $BACKUP_NAME is still running.\nDate: `date`\", \"priority\": 2,\"title\": \"japan-rpi4: $BACKUP_NAME Backup Stopped\"}" curl -X "POST" "https://gotify.sysctl.io/message" -H "accept: application/json" -H "Content-Type: application/json" -H "X-Gotify-Key: $GOTIFY_TOKEN" -d "$payload" diff --git a/nixos/hosts/backups-rpi4/scripts/rsync-media.sh b/nixos/hosts/backups-rpi4/scripts/rsync-media.sh index 09b64f8c..eabfc89e 100644 --- a/nixos/hosts/backups-rpi4/scripts/rsync-media.sh +++ b/nixos/hosts/backups-rpi4/scripts/rsync-media.sh @@ -27,7 +27,8 @@ if [[ $mounted1 != 0 ]] || [[ $mounted2 != 0 ]] || [[ $mounted3 != 0 ]] ; then fi # If an old backup is still running, don't continue -if [[ `ps aux | grep $BACKUP_NAME | grep -v grep` ]] ; then +count=$(ps aux | grep $BACKUP_NAME | grep -v grep | wc -l) +if [[ $count -ge 1 ]] ; then echo -e "$BACKUP_NAME rsync still running. Exiting...." payload="{\"message\": \"$BACKUP_NAME stopped. $BACKUP_NAME is still running.\nDate: `date`\", \"priority\": 2,\"title\": \"japan-rpi4: $BACKUP_NAME Backup Stopped\"}" curl -X "POST" "https://gotify.sysctl.io/message" -H "accept: application/json" -H "Content-Type: application/json" -H "X-Gotify-Key: $GOTIFY_TOKEN" -d "$payload" diff --git a/nixos/hosts/backups-rpi4/scripts/rsync-sysctl.sh b/nixos/hosts/backups-rpi4/scripts/rsync-sysctl.sh index 48552d88..8e74c47a 100644 --- a/nixos/hosts/backups-rpi4/scripts/rsync-sysctl.sh +++ b/nixos/hosts/backups-rpi4/scripts/rsync-sysctl.sh @@ -6,10 +6,9 @@ payload="{\"message\": \"$BACKUP_NAME Backup has started\nDate: `date`\", \"prio curl -X "POST" "https://gotify.sysctl.io/message" -H "accept: application/json" -H "Content-Type: application/json" -H "X-Gotify-Key: $GOTIFY_TOKEN" -d "$payload" # If an old backup is still running, don't continue -if [[ `ps aux | grep $BACKUP_NAME | grep -v grep` ]] ; then +count=$(ps aux | grep $BACKUP_NAME | grep -v grep | wc -l) +if [[ $count -ge 1 ]] ; then echo -e "$BACKUP_NAME rsync still running. Exiting...." - echo "Output: " - ps aux | grep $BACKUP_NAME | grep -v grep payload="{\"message\": \"$BACKUP_NAME stopped. $BACKUP_NAME is still running.\nDate: `date`\", \"priority\": 2,\"title\": \"japan-rpi4: $BACKUP_NAME Backup Stopped\"}" curl -X "POST" "https://gotify.sysctl.io/message" -H "accept: application/json" -H "Content-Type: application/json" -H "X-Gotify-Key: $GOTIFY_TOKEN" -d "$payload" exit