Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.


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?

share|improve this question

3 Answers 3

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.

share|improve this answer
    
Could you paste the URL of other post for better ways to create backups? I have been looking for it but couldn't get the just way of doing it. –  misamisa Feb 14 '13 at 22:37
    
It depends on how you want to make backups. If you have several servers, try using Amanda (amanda.org), if you just have two servers use rsync (comes with the OS). If you have a build in tape drive use your tar command. If you want a once off backup with a nice graphical front consider Acronis True Image. Etc etc. –  Hennes Feb 14 '13 at 22:41
    
It's single Linux server (CentOS - shell access only) which I want to take a full system backup once. Once the backup is taken locally, I will transfer that backup to other PC to keep it safe. –  misamisa Feb 14 '13 at 23:02
    
In that case why create the backup on a server and then transfer it. You can do this instead: One the host to store your backup run nc -l 1234 > MyBackupOfComputerA.tgz. And on the computer to archive run the tar command with as output filename - and append | nc ComputerB 1234. That - will write to std out instead of to a file. The | pipes the std out text to netcat which forwards it to another computer. The nc on the other computer listens for the information and writes it to a file. No intermediate copy is needed. –  Hennes Feb 14 '13 at 23:05
    
As you told me above that the tar command won't backup the MBR and filesystem. I am looking for a way to have them in a backup in case of harddisk failure. –  misamisa Feb 14 '13 at 23:08

Using tar to backup/restore a system is pretty rudimentary, and by that I mean that there are probably more elegant ways out there to backup your system... If you really want to stick to tar, here's a very good guide I found (it includes instructions on backing up the MBR; grub specifically).=: https://help.ubuntu.com/community/BackupYourSystem/TAR While it's on the Ubuntu wiki website, there's no reason why it wouldn't work on any UNIX/Linux machine.

You may also wish to check out this: https://help.ubuntu.com/community/BackupYourSystem

If you'd like something with a nice web GUI that's relatively straightforward to set up and use: http://backuppc.sourceforge.net/

Hope this helps!

share|improve this answer
1  
Let me second the pointer to backuppc. If you have several machines to backup, backuppc is a dream come true. Best thing of it is it's deduplication and compression. –  Floyd Feb 14 '13 at 6:40

Using remastersys :

http://www.geekconnection.org/remastersys/ubuntu.html

You can create live iso of your existing system. so install all the required packages on your ubuntu and then take a iso using remastersys. Then using startup disk, you can create bootable usb from this iso.

edit your /etc/apt/sources.list file. Add the following line in the end of the file.

deb http://www.remastersys.com/ubuntu precise main

Then run the following command:

sudo apt-get update

sudo apt-get install remastersys

sudo apt-get install remastersys-gui

sudo apt-get install remastersys-gtk

To run the remastersys in gui mode, type the following command:

sudo remastersys-gui

share|improve this answer
    
Any decent system would have all that in a startup script on the boot media. Nobody should have to search for instructions like that when trying to recover a system. –  John Gardeniers Feb 14 '13 at 10:22
    
@JohnGardeniers : remastersys-gui is a decent tool for these purposes. I have provided detailed way to install and use it –  Vivek Feb 14 '13 at 10:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.