Linux backup using tar

backuplinuxtar

Im new to linux backup.
Im thinking of full system backup of my linux server using tar.
I came up with the following code:

tar -zcvpf /archive/fullbackup.tar.gz 
--exclude=/archive 
--exclude=/mnt 
--exclude=/proc 
--exclude=/lost+found 
--exclude=/dev 
--exclude=/sys 
--exclude=/tmp 
/

and if in need of any hardware problem, restore it with

cd /
tar -zxpvf fullbackup.tar.gz

But does my above code back up MBR and filesystem? Will the above code be enough to bring the same server back?

Best Answer

But does my above code back up MBR and filesystem?

No. It backs up the contents of the filesystem.

Not the MBR which is not a file but is contained in a sector outside the file systems.
And not the filesystem with it potentially tweaked settings and or errors, just the contents of the file system (granted, that is a minor difference).

and if in need of any hardware problem, restore it with

cd /
tar -zxpvf fullbackup.tar.gz

Will the above code be enough to bring the same server back?

Probably, as long as you use the same setup. The tarball will just contain the files, not the partition scheme used for the disks. So you will have to partition the disk in the same way. (Or copy the old partition scheme, e.g. with dd if=/dev/sda of=myMBRbackup bs=512 count=1).

Note that there are better ways to create backups, some of which already have been answered in other posts. Personally I would just backup the configuration and the data. Everything else is merely a matter of reinstalling. Possibly even with the latest version.

Also not that tar will backup all files. The first time that is a good thing.

But if you run that weekly or daily you will get a lot of large backups. In that case look at rsync (which does incremental changes) or one of the many other options.

Related Topic