Next stage on this “plan” is a shell script to backup this machine (now a Pi4 with 8 GB of RAM - headless debian bookworm for arm64) to itself.
Note: contrary to the subject title “using a Pi5” - I’m now using a Pi4 (headless debian / raspbian 12).
Testing that now…
rsync (locally) to the 6 TB USB 3 ext4 filesystem…
then use tar to write that content to tar.gz file…
Then put that into cron - how often? I think daily’s overkill… Maybe daily for a few days…
Once that’s sorted and working - modify that script to do remote backup to that Pi4… But I won’t start on that until I’ve got gigabit from the other side of the house to the kitchen… Payday’s still 12 days away (monthly pay sucks) - will order some 30 m cat 6E cables and run a pair (i.e. one as a backup so I don’t have to do it again) through the ceiling and crawlspace from my office to the kitchen…
A backup of my Pi4 (itself) gzip’d tar, uses less than 1 GB…
WARNING - there’s some “potty mouth” words below :
So - crontab on the pi4 :
# m h dom mon dow command
# running this daily in the short term - eventually weekly...
0 4 * * * /usr/local/bin/bk2-rpi.bash > /dev/null 2>&1
Content of bk2-rpi.bash :
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: bk2-rpi.bash
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ #!/usr/bin/env bash
2 │ # backup this RPi
3 │ # use rsync to dump to /backup, then use tar to archive content of /backup to tgz file in /archive
4 │ # RUNTIME=$(date +'%Y%m%d-%H%M')
5 │ PROG=$(basename "$0")
6 │ BOX=$(uname -n)
7 │ RUNTIME=$(date +'%Y%m%d')
8 │ # EXL="/usr/local/bin/exl.txt"
9 │ EXL="/usr/local/bin/elx2.txt"
10 │ DEVIANT=/mnt/BUNGER00
11 │ RSYDIR=/mnt/BUNGER00/backups/$BOX
12 │ TURDIR=/mnt/BUNGER00/archives
13 │ # Returdation = 15 days :
14 │ RETURD=15
15 │ if [ ! -d $DEVIANT ] ; then
16 │ echo "$DEVIANT doesn't exist and not making it.... exiting..."
17 │ echo "maybe needs mounting perhaps????"
18 │ exit 1
19 │ fi
20 │ [[ ! -d $RSYDIR ]] && mkdir $RSYDIR
21 │ [[ ! -d $TURDIR ]] && mkdir $TURDIR
22 │ # /backup
23 │ # /home/x/ResilioSync
24 │ # /proc
25 │ # /sys
26 │ # /dev
27 │ set -vx
28 │ rsync -av --exclude-from=$EXL / $RSYDIR/.
29 │ tar czvpf $TURDIR/bkup-$BOX-$RUNTIME.tgz $RSYDIR/*
30 │ chown backups:backups $TURDIR/bkup-$BOX-$RUNTIME.tgz
31 │ rm -Rf $RSYSDIR/.
32 │ # cleanup shite older'n 15 days... or should we make it 30?
33 │ # find $TURDIR -type f -iname \*.tgz -ctime +$RETURD -exec rm {} \;
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
“returdation” is essentially “retention”…
I’ve got some commented foldernames - example of what’s excluded in $EXL.
Here’s $EXL (“/usr/local/bin/elx2.txt” - note: this is a symlink to a file on my homedir) :
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: elx2.txt
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ /mnt/BUNGER00/backups
2 │ /mnt/BUNGER00/archive
3 │ /home/x/ResilioSync/Music
4 │ /home/x/ResilioSync/scripto
5 │ /home/x/ResilioSync/bigshit
6 │ /home/x/ResilioSync/xr3t
7 │ /home/x/ResilioSync/PHOTOS
8 │ /home/x/ResilioSync/e-book
9 │ /home/x/.cache
10 │ /home/x/.config
11 │ /home/x/.oh-my-zsh
12 │ /home/x/tmp
13 │ /proc
14 │ /sys
15 │ /dev
16 │ /mnt
17 │ /media
18 │ /tmp
19 │ /var/spool
20 │ /var/tmp
21 │ /boot
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I think I will just modify that script to be “universal” - i.e. if it’s running on the backup server itself, “frambo”, do a local rsync, if it’s running elsewhere on a NIX like operating system (i.e. Linux) - then use rsync to a host (i.e. frambo, and if necessary - NFS mount from frambo to write a *.tgz file…
And I’ll have to modify that exclusion list for my two x86_64 systems which have multiple gigs of games installed which I don’t really need to backup…
Some time ago I had a shell script (forget its name) to remove the archive.tgz files except for the earliest of each month as EOM (end of month) for the previous month… Can’t find it anywhere…
I’d like to keep a month’s worth for a couple of months (weeklies)… but blow away everything except the first week of the month archive from 2 months earlier…