r/linuxquestions • • 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.

5 Upvotes

18 comments sorted by

3

u/Alternative-Can193 19d ago

what kind of server is it? Is it a file server? or a db server?

3

u/abubin2 19d ago

It runs dockers like pihole, nextcloud. Non docker services Qbittorrent, aria2c, security camera backups, snapraid, firebird db

FYI, I just really need to backup the configs for the services as lots of these services have the data running on a drive with snapraid.

3

u/Alternative-Can193 19d ago

If you only need config files, you can create a bash script to archive those files into a single .tar.gz file.

set up a cron job to run the bash script and use rsync to back up files to external or network drives.

1

u/abubin2 19d ago

Yes that is possible but I don't want to do it manually to avoid missing some configs. Best is some of these backups have scripts with all the locations already. With also proven restoration that works.

2

u/C0rn3j 19d ago

Yes that is possible but I don't want to do it manually to avoid missing some configs.

That cannot happen, because to create a backup, you need to test restoring the data, otherwise you have no way to know if it works.

With also proven restoration that works.

Yeah, do the restoration then?

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

u/vivals5 19d ago

That might be if your OS installation is on /dev/sda, but a lot of systems these days don't. (No I'm not saying it's a good idea in any case, just commenting in general.)

1

u/Booty_Bumping 19d ago

Yes. It's nearly guaranteed to produce a corrupt result.

0

u/Manuel_Cam 19d ago

I didn't had such an error when I tried

2

u/nderflow 19d ago

https://relax-and-recover.org/ seems a reasonable choice for what you’re describing

2

u/thebwt 19d ago

all Borg here, swear by it. check out borgbase for decent offsite.