I'm trying to implement a good back up strategy for my ubuntu server operating system. I have multiple harddrives on my server. So my plan is to use rsync to copy everything but my user data to another drive daily, and keep a weeks worth of copies. So if anything goes wrong I can just run rsync to copy the files back over to my "/" drive where my operating system is installed. I have two partitions on the drive where my operating system is installed nvme1p1 where the boot efi is saved and nvme1p2 where all the usual operating system folders are (bin, dev, etc, lib...)
So I'm running the bash script below daily:
#!/bin/bash
DATE=$(date '+%F')
sudo rsync --exclude={/mnt,/home} -avz / /mnt/data/storage1_1tb/backup_server_os/$DATE
I had a "busybox" and readonly filesystem issue with my server recently. so I ran
sudo rsync -av /mnt/data/storage1_1tb/backup_server_os/2023-11-09 /
I got a message that some files couldn't be copied, and after rebooting it still didn't fix the issues. ultimately I had to run fsck -y /
from root and also ran fsck -y /dev/nvme1p2
and fsck -y /dev/nvme1p1
using live media. when run with live media it mentioned some dirty files on /dev/nvme1p1
. I haven't been backing up the boot efi on /dev/nvme1p1
, do I need to do that as well so I can copy it back over in case of issue.
My ultimate goal is that if something went wrong with my operating system (ex. hard shutdown causes read only file system error on boot) I could just copy the files back over from the previous days back up, reboot and hopefully everything runs fine like the day before. Does the strategy I've outlined make sense and if so what am I doing wrong with rsync, (since I still had to run fsck -y after running rsync to copy files back over)?
rsync
can copy with data structure on a lower level i.e. filesystem whichrsync
can’t copy … That’s another job for disk imaging or at least partition/filesystem copying/backup software … See for example https://askubuntu.com/a/1422748 – Raffa Nov 22 '23 at 10:09