Perform backups for the Linux operating system

by on October 25, 2006 · 14 comments· LAST UPDATED July 4, 2007

in , ,

This question asked again and again by a new Linux sys admins:

How do I perform backups for my Linux operating system?

So I am putting up all necessary information you ever need to know about backup. The main aim is to provide you necessary software, links and commands to get started as soon as possible.

Backup is essential

First a backup is essential. You need a good backup strategy to:

  • Minimize time from disaster such as server failure or human error (file deleted) or acts of God
  • To avoid downtime
  • Save money and time
  • And ultimately to save your job ;)

A backup must provide

  • Restoration of a single/individual files
  • Restoration of file systems

What to backup?

  • User files and dynamic data [databases] (stored in /home or specially configured partitions or /var etc).
  • Application software (stored in /usr)
  • OS files
  • Application configuration files (stored in /etc, /usr/local/etc or /home/user/.dotfiles)

Different types of backups

  • Full backups: Each file and directory is written to backup media
  • Incremental backups (Full + Incremental backup): This backups are used in conjunction with full backup. These backups will be incremental if each original piece of backed up information is stored only once , and then successive backups only contain the information that changed since the previous one. It use file's modification time to determine which file need to backup.

So when you restore incremental backup:

  1. First restore the last full backup
  2. Next every subsequent incremental backup you need to restore

Preferred Backup Media

  1. Tape (old and trusted method)
  2. Network (ftp, nas, rsync etc)
  3. Disk (hard disk, optical disk etc)

Test backups

Please note that whichever backup media you choose, you need to test your backup. Perform tests to make sure that data can be read from media.

Backup Recommendation

My years of experience show that if you follow following formulas you are most likely to get back your data in worst scenario:
(a) Rotate backup media
(b) Use multiple backup media for same data such as ftp and tape
(c) Keep old copies of backups offsite

In short create good disaster recovery plan.

General procedure to restore a Linux/UNIX box

There is not golden rule or procedure but I follow these two methods:

Method # 1: Reinstall everything, restore everything, and secure everything

Use this method (bare metal recovery) if your server is cracked or hacked or hard drive is totally out of order:

  1. Format everything
  2. Reinstall os
  3. Configure data partitions (if any)
  4. Install drivers
  5. Restore data from backup media
  6. Configure security

Method # 2: Use of recovery CD/DVD rom

Use this method if your box is not hacked and system cannot boot or MBR damaged or accidental file deletion etc:

  1. Boot into rescue mode.
  2. Debug (or troubleshoot) the problem
  3. Verify that disk partitions stable enough (use fsck) to put backup data
  4. Install drivers
  5. Restore data from backup media
  6. Configure security

Linux (and other UNIX oses) backup tools

Luckily Linux/UNIX provides good set of tools for backup. We have almost covered each and every tool mentioned below. Just follow the link to get more information about each command and its usage:

It is also recommended that you use RAID or LVM (see consistent backup with LVM) or combination of both to increase reliability of data.

A note about MySQL or Oracle database backup

Backing up database server such as MySQL or Oracle needs more planning. Generally you can apply a table write lock and use mysql database dump utility to backup database. You can also use LVM volume to save database data.

A note about large scale backup

As I said earlier tar is good if you need to backup small amount of data that does not demands high CPU or I/O. Following are recommended tools for backup that demands high CPU or I/O rate:

(a) amanda - AMANDA, the Advanced Maryland Automatic Network Disk Archiver, is a backup system (open source software) that allows the administrator to set up a single master backup server to back up multiple hosts over network to tape drives/changers or disks or optical media.

(b) Third party commercial proprietary solutions:
Top three excellent commercial solutions:

If you are looking to perform the tasks of protecting large-scale computer systems use above solutions and following two books will give you good idea:

Recommended further readings

I hope this small how to provide enough information to anyone to kick start your backup operation. Tell me if I am missing something or if you have a better backup solution or strategy, please comment back.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

1 Wondwossen July 10, 2007 at 7:02 am

My name is Wondwossen , I am from Ethiopia , Africa .I am a system admin at a state bank.I really liked what you have preseted here. It has really helped me a lot. Thank for your effort keep it up

2 George Fleites April 29, 2011 at 4:15 am

This is a very good information about how important backups are, now that I know all that what should I do?
Type “Backup my server to the USB drive” at the console?
Thank you, George

3 artiomix August 2, 2007 at 9:20 pm

Nice one! Thanks! I recommend to use Unix ‘dump’ and ‘restore’ utilities for entire filesystem backup.

4 Deepu October 12, 2007 at 10:07 am

Many thanks for remembering us with some of the useful steps to be undertaken before taking backup.
Also i would like to mention about another backup tool – “MondoRescue”. For me it worked fine – easy backup, recovery, etc. Its even available for the 64 bit machines..

5 Ravindra Lawand March 19, 2009 at 4:07 am

I have a query, how can we take back up in Red Hat Linux by attaching tape drives to it, means
by which command we mount drive and then by which command backup will be stored in that tape,
kindly suggest..

6 Jeff Kayser November 12, 2009 at 6:23 pm

I was researching Linux backups, and discovered that although dump/restore (and it’s variants) are good backup programs for UNIX, they are NOT good backup programs for Linux. So says Linus Torvalds:

http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/admin-guide/s1-disaster-rhlspec.html

7 kiran kumar D.S March 30, 2010 at 4:41 am

hi this is kiran,i have a query of how to restore a file which is permanently deleted in ubuntu 9.04.plz answer my question in the nearest time.bye

8 Ramakrishna May 17, 2011 at 7:36 am

Hi,

This is Ramakrishna, Really your backup article is so pretty. we are improving our technical backup skills by following your articles. really these are awesome ones..
can you provide any additional backup opensource softwares and methods in linux(Redhat) / Unix (solaris 10).

thanks
with best regards
Ramakrishna

9 Purnima July 27, 2011 at 9:10 pm

Hi,

I need some help in doing Backup/Restore of the OS Settings and System Configuration. How should i do back up for that in Linux,please guide me are there
any links available for Backup of OS Setting and system configuration for Linux,please let me know ASAP.

10 Soni Peterson December 22, 2011 at 8:54 am

I need some help in taking backup of system video drivers as well as to create exxact replica machine

11 Alessio February 26, 2012 at 3:56 am

I have been googleing the net for a week. I need a GUI based program with a box that displays a “backup all” option :)

Come on, guys. I have second drive and wich to backup my linux on my primary drive to it.

How do I back it all up¿

12 deelipkumar yadav May 2, 2012 at 5:56 am

how to take a backup of os in linux help me

13 kunal vaidya June 18, 2012 at 8:38 am

Hi Vivek,

I have a question for you since i am struggling to find a detailed answer of this.
As in windws various backup types can be explained on the basis of archive bit, similarly on what basis we generate incremental backups in Linux. Second how can we restore incremental backup (Lets say you have created incremental backup using tar -g options), need this with example.
And can we have differential backup in Linux?

14 ansar June 30, 2012 at 1:24 pm

Hi,

I am facing the problem with redhat linux 5. I am using two redhat. One for main server and other one is backup server, End of the day i used to take backup from main server to backup server by using command ” rsync -av . by using this command datas are getting backup as incrimental . But when i delete any file from main server then i run this rsync command it is not updating with backup server.
So my requirement is any data has been deleted from server it should synchronize and delete that particular file from backup server too

Please any one can help me out……..

Comments on this FAQ are closed. If you'd like to continue the discussion on this topic, you can do so at our forum.

Tagged as: , , , , , , , , , , , , , , , ,

Previous post:

Next post: