In the stage creating a bash script to run before i shutdown my desktop.
Does my script need any more anything else?
I want to have proper check with –read-data alongside forget + prune maintance script created.
#!/bin/bash
source /home/$USER/.bin/backup/.env
LOG_FILE="/var/log/scripts/pc-backup.log"
log_message() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
}
restic unlock \
--repo "$RESTIC_PC_REPO" \
--password-file <(echo "$RESTIC_PC_PW")
restic check \
--repo "$RESTIC_PC_REPO" \
--password-file <(echo "$RESTIC_PC_PW")
restic backup \
--repo "$RESTIC_PC_REPO" \
--password-file <(echo "$RESTIC_PC_PW") \
--verbose \
--tag auto \
--compression auto \
--files-from "/home/$USER/.bin/backup/backup.files" \
--exclude-file "/home/$USER/.bin/backup/exclude.files" 2>&1 | tee -a "$LOG_FILE"
BACKUP_EXIT_CODE=${PIPESTATUS[0]}
if [ $BACKUP_EXIT_CODE -eq 0 ]; then
log_message "Backup completed successfully"
else
log_message "ERROR: Backup failed with exit code $BACKUP_EXIT_CODE"
exit $BACKUP_EXIT_CODE
fi