u/fl4tdriven

▲ 3 r/homelab+1 crossposts

Need some advice on creating an rsync script for local backups

I'm pretty new to using rsync in any capacity, but I've been searching for a way to automate local backups for some of my data to be stored on local 'human readable' exFAT formatted HDD's, which is how I landed on using rsync.

What I have so far is a RPi4B running Raspbian OS and completely dedicated to the purpose of running these backups. I have an TrueNAS hosted SMB share permanently mounted via fstab and a usb HDD dock plugged into the pi. My current working rsync syntax is:

rsync -av --delete mnt/smbshare/datafolder /media/rpi4/backuphdd --log-file /home/rpi4/desktop/rysnc_log.log

I'd like to modify the rsync script so that I can use one of two HDD's that could be in the dock at any given time. I'd like to rotate them out on a regular basis and keep one at a relatives house for cold storage. I want the script to be able to identify when either drive is attached and run successfully. Should I be using a different way to point to the HDD instead of /media/rpi4/backuphdd? If so, what would be best practice?

reddit.com
u/fl4tdriven — 16 hours ago