Results 1 to 4 of 4

Thread: How to restore Linux with Tar

  1. #1
    Join Date
    Dec 2004
    Posts
    420

    How to restore Linux with Tar

    Linux backup
    The principle is to make a single archive containing all files on the hard disk to make a backup.
    Under Linux, it is possible to access all the files and modify them even if they are in use. It is theoretically not necessary, therefore, to run on a Live-CD for backup or restore.
    To create and to restore our archive, we will just use tar.

    Important
    • Before doing the backup: make sure not to include unnecessary files:

    1. empty the Recycle Bin for each user,
    2. if you want a backup system, do not include personal documents ...
    3. also empty the cache folder of fitness: When downloading a packet, it remains on the disk, they must be abolished to win (a lot) of space. For this, type in a terminal:

    sudo aptitude clean
    • It is very important if you follow this trick directly from the system restore (no Live-CD for example) not to use other software during the backup: do not modify files on the disk during reading tar.


    The ideal is to do the backup after installing the system, after installing its software and the like updates like this, the system is clean.

    Backup
    To get full access to system files, let us root user by typing in a terminal:
    sudo su

    Then go to where you want to create the archive: here we take the root of the drive: /
    cd /

    Well, we can create our archive using the following command:
    tar cvpzf backup.tgz --exclude=/backup.tgz --exclude=/lost+found --exclude=/media /

    Explicitons a bit:
    • cvpzf: what are the options: to create (c) showing an archive (v) the scroll on the screen. Each file will retain its permissions (p) using gzip (z) to create the file (f) backup.tgz.
    • The records and files after - exclude / are the records that we do not want to include in the archive:

    1. backup.tgz: we can not of course include the archive itself failing to create a loop ...
    2. / lost + found, these files are not used to much.
    3. / media: we must not include the other file systems.

    • As we want to save, it puts "/" to include the root file system.


    Run the command and then wait as it might take time.
    At the end, you end up with a file backup.tgz in the root file system containing all the files in "/" we have not excluded.

  2. #2
    Join Date
    May 2009
    Posts
    245

    Re: How to restore Linux with Tar

    Remarks
    You can also use gzip Bzip2 instead: this will cause a compression of larger files (an archive smaller) but the process will take longer.
    To this solution, just replace "z" with "j" in the options, and name the archive so that it ends with. "Tar.bz2", like this:
    tar cvpjf backup.tar.bz2 --exclude=/backup.tar.bz2 --exclude=/lost+found --exclude=/media /

    Be careful here: the manipulation below to replace each file with their "counterpart" in the archive, so be sure what you do.

    Backup.tgz Place the file in the root file system, then put you in as root (sudo su) and put you in the root (cd /)

    Here is the command to restore any type:
    tar xvpfz backup.tgz -C /

    Or in the case of using Bzip2 to replace gzip:
    tar xvpfj backup.tar.bz2 -C /

    explanations:
    1. options:

    • x: to extract.
    • -C: to use the current directory (/) to extract the files.


    To restore: type the command, then press enter and wait until the process finishes.

    There only one thing: if you have excluded files (eg / lost + found), you must recreate them with the command:
    mkdir /lost+found

    That is: after a system reboot, you'll have a system in the same condition as when creating the backup!

  3. #3
    eXcalibre Guest

    question Re: How to restore Linux with Tar

    I know this is an old post but would like to ask a question on this subject.

    When i try to do a backup of my system (which is a hosted VPS) i get the following error on 2 servers.

    tar: /: file changed as we read it

    i have shut down as many services as i dare in order to keep my ssh open before doing the backup. (ie http mysql clam spamass crond rsyslogd etc)

    the error does not specify a file that fails but the root folder / !!

    is there something you can think of that may get me around this issue?

    I have tried adding --ignore-failed-read and excluded the last file in the backup to the --exclude but it just fails on another.

  4. #4
    eXcalibre Guest

    Re: How to restore Linux with Tar

    UPDATE
    Solved by moving the tar file to the /root/ directory and adding that to exclusions.
    :-)

    thanks anyway

Similar Threads

  1. Unable to restore the Language applet in Linux
    By Rhesa in forum Operating Systems
    Replies: 6
    Last Post: 08-05-2012, 10:38 PM
  2. Corrupt restore using backup tool in Linux mint
    By Parnell in forum Operating Systems
    Replies: 2
    Last Post: 11-11-2011, 10:36 PM
  3. Replies: 3
    Last Post: 16-09-2011, 09:04 AM
  4. cannot restore backup in linux mint
    By Mahua in forum Operating Systems
    Replies: 4
    Last Post: 15-01-2011, 10:49 AM
  5. System restore available for the Linux Mint 10
    By quentein in forum Operating Systems
    Replies: 4
    Last Post: 30-12-2010, 03:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,421,690.96039 seconds with 16 queries