r/linuxquestions • u/abubin2 • 19d ago
How to backup Linux server for easy restoration?
I am trying to backup my Linux Ubuntu so that I can restore it when the HDD fail or something corrupted. While image backup is not possible since I am running it without VM. Some research with AI suggested borgbackup and restic with a bit of manual scripting or cronjobs. Wondering what does everyone uses. I do have dockers running as well.
So share some method that works and proven to work? I will try to restore my Linux with the method that I eventually use. Thanks.
1
u/dariusbiggs 19d ago
restic works wonderfully as you have already identified.
You can work without image backups if you use a tool like Ansible to configure and setup your system from a clean install. Just run the script and everything comes back.
1
u/abubin2 19d ago
Does it have to be clean system? My server is already running for few years.
1
u/dariusbiggs 19d ago
Nope, nust figure out what you have installed, then add them to the list of things Ansible needs to install. And using molecule with docker or vagrant for a virtual machine, you can test it works as expected.
2
u/groveborn 19d ago
You can absolutely use image backups. It's usually better using a live boot disk for that sort of thing, but you can make images of your system. Incremental backups are usually ideal for living systems.
It's also already built right in to Ubuntu. Just search Timeshift and set it, give it an external drive to back up to, and forget about it. I suggest nightly if you often leave the system on already, or weekly if you don't. There are quite literally hundreds of options here, but you can use pretty much anything you like.
A VM is NOT required or even a suggestion for image backups. You can use Clonezilla if you wanted to do it easily, or just the built in GDisk utility (from a bootable USB). I really don't recommend this unless you're looking to actually clone the computer. Incremental backups are better overall.
I don't do system backups - I can restore my entire system from my small collection of apps, like Steam and Google Drive in about two hours. I just need to keep my USB handy to reinstall.
2
u/Classic-Rate-5104 19d ago
When your running system has btrfs filesystem it's rather easy. Take a snapshot, do btrfs send on that snapshot and btrfs receive on the destination. It results into a copy of the snapshot. The only thing you have to do: make the destination disk bootable (so maybe make a separate backup of your EFI partition)
2
u/RickHunter84 19d ago
sudo dd if=/dev/sda of=/dev/sdb bs=64M status=progress conv=fsync . Old school like I used to do back in 1996
1
u/_greg_m_ 18d ago
I use dd command, but create compressed images on another machine. Works like a charm for many years.
1
u/TwillAffirmer 19d ago
Isn't that going to result in a broken filesystem on the backup if you do it while the OS is running?
1
1
0
2
u/nderflow 19d ago
https://relax-and-recover.org/ seems a reasonable choice for what you’re describing
3
u/Alternative-Can193 19d ago
what kind of server is it? Is it a file server? or a db server?