backup piha home

This commit is contained in:
oskar 2025-12-01 20:21:38 +01:00
parent 2056a08aac
commit 991718eed0
2 changed files with 15 additions and 8 deletions

View file

@ -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"

View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
dir=$(dirname $0)
scp $dir/backup-piha-home.sh pi@piha.local:~/backup-scr/