Been there myself recently.
I lost a couple of years work a while back.
I am using a NUC rather than a RasPie, but the idea is the same.
This is a little "backup" script I made:
(You will have to edit some paths and stuff... But I hope this helps.)
#!/bin/bash
# ---------------------------------------
# Simple backup script v1.0
# ---------------------------------------
# Variables
myDate=`date "+%Y-%m-%d.%H.%M.%S"`
#backupFolderName="Backup_$myDate"
backupFolderName="$myDate"
backupSource="/home/me/.node-red"
backupDest="/home/me/Backups/NR/LOCAL"
backupFilter="*.j*"
backupExclude="lost\+found"
# Tell the user what we're working with
echo "The myDate variable contains: $myDate"
echo "A backup of $backupSource/$backupFilter will be made and stored in $backupDest/$backupFolderName"
# Begin backup
rsync -avz --progress $backupSource/$backupFilter --exclude=$backupExclude $backupDest/$backupFolderName
#RC = $?
# We're done.
echo "Done!"
exit $RC
This is a bash
script.
I run it now and then when I am doing big changes or it feels like a good time to do a backup.