Root partitions are copied to a nfs share everyday at 11 pm.
Temporary files such as standalone/{tmp,data}, /var/log/journal, /var/lib/postgresql are excluded amnong others.
Requirements for:
FStab Entry
# mount nfs share for root backups
192.168.100.97:/var/nfs/root-backups /mnt/root-backups nfs rw,defaults,nofail 0 0
Cron Job
# backup root partition to nfs share via rsync everyday at 11 pm
0 23 * * * root /home/madridn/root-rsync.sh >> /home/madridn/root-rsyc.log.log 2>&1
Backup Script
#!/bin/bash
# DEST_DIR will be created if needed
DEST_DIR=/mnt/root-backups/happywell-vm/
# sample cron job to run root rsync everyday at 11 pm
# 0 23 * * * root /home/madridn/root-rsync.sh >> /home/madridn/root-rsyc.log.log 2>&1
# sample fstab entry to mount nfs share for root backups
# 192.168.100.97:/var/nfs/root-backups /mnt/root-backups nfs rw,defaults,nofail 0 0
# rsync root partition to shared nfs directory
rsync -aAXHv --one-file-system --info=progress2 \
--exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*"} \
--exclude={"/media/*","/lost+found/*","/var/lib/postgresql/*"} \
--exclude="/var/log/journal" \
--exclude=standalone/{tmp,data} \
/ $DEST_DIR