From 991718eed01b9e6e0fd16388c972b92f130ce6e2 Mon Sep 17 00:00:00 2001 From: oskar Date: Mon, 1 Dec 2025 20:21:38 +0100 Subject: [PATCH] backup piha home --- 006_backups/backup-piha-home.sh | 18 ++++++++++-------- 006_backups/send-backup-piha-home.sh | 5 +++++ 2 files changed, 15 insertions(+), 8 deletions(-) create mode 100755 006_backups/send-backup-piha-home.sh diff --git a/006_backups/backup-piha-home.sh b/006_backups/backup-piha-home.sh index c64d6e5..2de911c 100644 --- a/006_backups/backup-piha-home.sh +++ b/006_backups/backup-piha-home.sh @@ -59,15 +59,17 @@ if cd "$toBackupDir"; then fi if find . \( -type d \( "${prune_expr[@]}" \) -prune \) -o \( -type f ! \( "${name_expr[@]}" \) -print0 \) | tar -czf "$backupsDir/$backupFolderName${dateStamp}.tgz" --null -T -; then + chown pi:pi $backupsDir/$backupFolderName${dateStamp}.tgz + echo "Backup completed successfully: $backupsDir/$backupFolderName${dateStamp}.tgz" - - # Remove backups older than 7 days except last day of month backups - find "$backupsDir" -name "${backupFolderPrefix}*.tgz" -type f -mtime +7 | while read -r file; do - fileDtgName=$(echo $file | cut -d '_' -f 2) - if ! is_last_day_of_month "$fileDtgName"; then - rm "$fileDtgName" - fi - done + + # Remove backups older than 7 days except last day of month backups + find "$backupsDir" -name "${backupFolderPrefix}*.tgz" -type f -mtime +7 | while read -r file; do + fileDtgName=$(echo $file | cut -d '_' -f 2) + if ! is_last_day_of_month "$fileDtgName"; then + rm "$fileDtgName" + fi + done else echo "Error creating backup" diff --git a/006_backups/send-backup-piha-home.sh b/006_backups/send-backup-piha-home.sh new file mode 100755 index 0000000..b3b645c --- /dev/null +++ b/006_backups/send-backup-piha-home.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +dir=$(dirname $0) + +scp $dir/backup-piha-home.sh pi@piha.local:~/backup-scr/ \ No newline at end of file