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