How Backup an Entire Linux System
-
Hello to everyone
I need an help about what is the best procedure to backup an entire linux system over an external Drive.
I was thinking to use tar with the following option:
tar -cvzpf /media/user/externaldisk/full_backup_linux.tar.gz --exclude=/dev --exclude=/mnt --exclude=/proc --exclude=/sys --exclude=/tmp --exclude=/lost+found --exclude=/media /
and if i need to create a log is correct the followinf comand?
tar -cvzpf /media/user/externaldisk/full_backup_linux.tar.gz --exclude=/dev --exclude=/mnt --exclude=/proc --exclude=/sys --exclude=/tmp --exclude=/lost+found --exclude=/media / &> /media/error.log
But i really don't know if it is the best way to do it. we just need to save the systems because the data and the config files of this workstation are spread everywhere in the file system.
Thanks for the help
-
@Giovanni-Baldi I would always incrementally backup LXC systems with tar like this to an external Seagate drive, it's worked well so far:
tar --listed-incremental=/tmp/snapshot.file -cpjf /tmp/gentoo.tar.bz2 /home/ryan/.local/share/lxc/VPN2/rootfs --acls --xattrs --numeric-owner --exclude=proc --exclude=dev --exclude=sys --exclude=mnt --exclude=usr/portage/distfiles
-
The solution posted by @Ryan-Kastner works great and answers your original question. However, I would like to add on to it by suggesting you take a look at this Github project:
https://github.com/dolorosus/RaspiBackup
Dolorosus wrote an amazing script to perform an online backup of a Raspberry Pi using
rsync
.rsync
provides a number of advantages overtar
, the biggest of which is the ability to only backup changes. Dolorosus also backs up to a sparse disk image which can be easily mounted if you want to pull out one or two files instead of dealing with the entire archive. -
I put my Linux server under VMWare 6 standalone and use VEAAM to backup. Both are free. I backup my VMs intact to an external drive. They restore quickly.
-
if it is the "entire linux system" and space is not an issue, I always use "dd"... either to make a copy of the drive itself or a partition -----> another drive either in an .iso or just another mirror copy of the device completely swapable/bootable (Or into a virtual, a "little" tricky, but definitely doable). That way you have a working snapshot of the system that can be put back in place with the "dd" command again.... or possibly spun up on other system...OR spun up temporarily from the external drive using the boot override.
...nice for taking your home desktop with you on travel...
-
You can also perform what's called a "bare-metal backup" using a bit mirroring command such as dd. If you have some Linux boxes hosted in the cloud, then these are the steps that you would follow for most cloud providers (AWS, GCP, Linode, etc.):
- Power off the machine.
- Boot the machine into a rescue mode (the equivalent of booting into a Live USB Linux repair drive).
- Mount the block device containing your entire system, for example /dev/sda.
- Start the SSH server daemon.
- Run the dd command with the stdout piped to your local machine over the SSH protocol.