87Ferrets Blog

How to make a backup of your server, or how I did it.

Written by TuxThePenguin on 13/07/2020 at 08:30 pm

You should make backups regularly. I learnt this when I accidentally messed up badly once and had no backup to revert to. But with a server with no GUI and only a commandline interface, how are you supposed to do that?
Thats where the wonderful DD command comes in!
WARNING: Avoid doing a system backup on a live filesystem such as your root filesystem. I did it and luckily had no issue, but the same cannot be said for everyone!
To execute the DD command, preferably plug in the drive to a computer running Linux or a subsystem for Linux and mount it. Open up a terminal and type dd if=/dev/sda of=/BACKUPS/Server1.img. Now change /dev/sda to your drive (use fdisk -l) to see and /BACKUPS/Server1.img to your destination directory and change the image name if you like too. If you have a large drive, this may take a while.
You may need to use sudo to execute DD
Once its done, you can test if it is bootable to avoid disaster when you need to restore from the backup but only find out that it doesn't boot properly. Using a terminal, just execute VBoxManage convertdd /BACKUPS/Server1.img /PRODUCTION/Server1.vdi (You will need Virtualbox installed for this, its free!)
What does that do? Well, it converts your IMG file into a VDI because Virtualbox does not support booting of a raw image file. After you verified the image boots, just delete the VDI and keep the backup if disaster happens.

This worked for me, it may not work for you but that was just my experience