Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: tar command to backup Ubuntu system ?

  1. #1
    Join Date
    Jun 2013
    Beans
    120

    Question tar command to backup Ubuntu system ?

    I have a really nice Ubuntu install tweaked, complete with all the software apps I need, Compiz effects, etc. I would like to back it up in case it succumbs to a case of fubar from either something i do or a system update/upgrade. I have used Clonezilla to do some partition cloning, but sometimes that does not work. I am getting better at learning Grub2 so I am feeling better about being able to restore Grub2 if needed, so I think a tar backup might suffice. Just that I want to be clear on a tar command to do what needs doing.

    So say my Windows 7 system is on /dev/sda, my Ubuntu system ("/") is on /dev/sdb1, my /home is on /dev/sdb2, and I have an ntfs data drive with folders on /dev/sdc1 (that data drive is automagically mounted at boot by my Ubuntu system as /datadrive).

    What tar command could I use to tar my Ubuntu system ("/") to /dev/sdc1 (without destroying that drive of course!), including the use of bzip? I want the highest compression, am willing to sacrifice execution time for highest compression. I have read it is important for such a tar to use excludes to exclude the .bzip tar file itself as well as various volatile system folders/files that do not need to be tarred because they are created during boot and only exist temporarily.

    I came across this post on backing up an Ubuntu system using tar
    https://help.ubuntu.com/community/BackupYourSystem/TAR
    but I want to understand it better and I want to be able to do such a tar backup where the tar archive is created and stored on /datadrive

    From a terminal command line shell in my Ubuntu system, would this do what I need done?
    $ sudo tar -cbvf /datadrive/backup.tar.bz2 /
    My concern is that such a tar command would also try to include the automagically mounted /windows and /datadrive folders, which of course would be a disaster; so should i exclude them like this:
    $ sudo tar -cbvf /datadrive/backup.tar.bz2 --exclude=/datadrive --exclude=/windows /
    Last edited by Coder88; September 8th, 2013 at 02:02 PM.

  2. #2
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: tar command to backup Ubuntu system ?

    If you move /home partition into the root partition, I have a system ready for you. Otherwise you can just make your own extra tarball of the home partition and store it separately.

    Try the One Button Installer, 'OBI'

    It is very easy to make your own tarballs. But as before, it requires a simple configuration, only one partition for the system and one for swap.

    There is also a possibility to install (as a second step) the OBI to an arbitrary sized drive and use all of it: For example a big USB pendrive (16GB or 32GB), or an external HDD or SSD (connected via USB or eSATA). This means that it can contain a rather big library of tarballs, or big tarballs, and can be used either to install from a large selection of tarballs, or to make and store backups as tarballs.

  3. #3
    Join Date
    Mar 2008
    Beans
    1,219

    Re: tar command to backup Ubuntu system ?


  4. #4
    Join Date
    Jun 2013
    Beans
    120

    Re: tar command to backup Ubuntu system ?

    Um, yes, that link is in my original message/post.

  5. #5
    Join Date
    Jun 2013
    Beans
    120

    Re: tar command to backup Ubuntu system ?

    Also, when I do
    $ls /
    I see home listed, even though home exists on its own drive partition. So when doing the tar command for a system backup, if I do NOT want home included in the backup, I would have to include the exclude for home in the tar command options, correct? so maybe:
    $ sudo tar -cbvf /datadrive/backup.tar.bz2 --exlude=/home --exclude=/datadrive --exclude=/windows /

  6. #6
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: tar command to backup Ubuntu system ?

    I think this option will also prevent backing up other partitions, that are mounted.

    Code:
    --one-file-system
               stay in local file system when creating archive
    But I suggest that you create a mini system to test your command lines before you go ahead with the real task. Then it will be easy to inspect the result either with file-roller or by extracting it to some other place.

  7. #7
    Join Date
    Jun 2013
    Beans
    120

    Re: tar command to backup Ubuntu system ?

    Okay thank you. I am feeling close to pulling the trigger and giving a tar backup a go!

  8. #8
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: tar command to backup Ubuntu system ?

    Just a final thought. It is always easier to backup a system, that is not running. So if possible, boot from another system, mount the system you want to backup, and back it up. Otherwise things might change during the backup, so that it is not quite self-consistent (compatible with itself).

    Otherwise you should exclude directories with files that are likely to change (and that might not be necessary in the backup).

  9. #9
    Join Date
    Jun 2013
    Beans
    120

    Re: tar command to backup Ubuntu system ?

    Quote Originally Posted by sudodus View Post
    Just a final thought. It is always easier to backup a system, that is not running. So if possible, boot from another system, mount the system you want to backup, and back it up. Otherwise things might change during the backup, so that it is not quite self-consistent (compatible with itself).

    Otherwise you should exclude directories with files that are likely to change (and that might not be necessary in the backup).
    Excellent point. I am curious though, how much of a problem would it be to use a tarball created from a running linux system (very convenient of course, as one could stay productive), how reliable would such a tarball be for a restore? I don't know the answer to that question, just wondering.

    I am running a tar backup now, scrolling by in a terminal. But once it completes I will do one from a live boot linux distro so my main linux system is not running during the tar backup.

    I was unable to run the tar using the bzip compression option, got an error about block sizes; so i am running a tar using gzip. I would like to figure out though how to do a higher compression. My goal is to get tarballs under 8GB (excluding /home) so they could easily be burned to a dual layer DVD for optical storage.

  10. #10
    Join Date
    Jun 2013
    Beans
    120

    Re: tar command to backup Ubuntu system ?

    As my tarball is being created, to be stored on an ntfs data drive, I wonder if the resulting tarball filesize will be too large for ntfs? I guess I will find out. What is the maximum size of a tarball on linux? on windows/ntfs? Hmm. I guess if needed I could make a linux data drive for tarballs.

Page 1 of 3 123 LastLast

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
  •