Backup the entire OS

Discussion in 'General Linux' started by CesarCara, Jun 10, 2014.

  1. CesarCara

    CesarCara New Member

    Messages:
    24
    Likes Received:
    3
    Trophy Points:
    3
    Hello!

    I had this huge problem with my windows (I had a dual boot elementary-OS/Windows) and now I need re-install it. To do that I need to make all the partitions again and blablabla, but I worked hard on my GNU/Linux to make it more suitable to me and I don't want to do it all again.

    So I'm a****g for some tips about backup, I have a disk space to store my entire GNU/Linux system if I need to. I think it will be useful to have a backup of my system stored.

    I read something about tar, rsync (grsync) and DejaDup but I wanted to hear of you guys about some experiences you had.

  2. Yesyesloud

    Yesyesloud Active Member

    Messages:
    279
    Likes Received:
    140
    Trophy Points:
    43
    Best Answer
    If you install winblows without any repartitioning or formatting, it will overwrite your bootloader, being the only bootable OS, but your main Linux partition will keep untouched, so you can use boot-repair or other methods in order to recover your multiboot properly. This may work for single partition multiboot, too.


    If you choose the do-it-all-over path, backup suggestion:

    I always use dd in this case. No need for guis... A very clean solution:

    -Boot from a live cd
    -Set a mount point for the backup disk (you can do it by simply clicking it on your average file manager).
    -Open backup destination folder on terminal.
    -Make the iso image, replacing sdxn with the actual partition you wanna save:
    Code:
    dd if=/dev/sdxn of=mylinux.iso bs=4M
    After repartitioning the disk and reinstalling windows:
    -Boot a live cd again
    -Mount the disk in which the iso was saved, open it on terminal.
    -Replace sdxn with the partition on which the image will be written:
    Code:
    dd if=mylinux.iso of=/dev/sdxn bs=4M
    Then use boot-repair/preferred method.

    Ps: set a bigger block size for dd if you want to increase read/write speed.
    Last edited: Jun 10, 2014
  3. GrumpyOldMan

    GrumpyOldMan Active Member

    Messages:
    158
    Likes Received:
    50
    Trophy Points:
    28
    What tools you use depends on what you are doing.

    tar (Tape ARchive) was designed to backup entire file systems to streaming media. Now, it puts a filesystem into a sing archive file. So, use it to make a snapshot of your system.

    rsync will synchronize two separate file systems - either on subtrees (possibly an internal and an external drive) attached to one computer, or on completely separate computers, via ssh. It will work in an incremental manner, so while it will still maintain a single snapshot, you can update that snapshot on a regular basis, and only copy what's changed, unlike the monoliths tar creates.

    You could also use dd to make an exact bit-for-bit image of one disk on another, but that's sort of overkill for most uses. Plus, it's really easy to use dd to completely destroy the contents of your disk.

    Personally, I use rsync to backup my home directory to an external.

    In the office, we make tarballs of our servers, and then rsync them to a central backup server, that I then rsync to a portable drive that I keep off-site.
  4. GrumpyOldMan

    GrumpyOldMan Active Member

    Messages:
    158
    Likes Received:
    50
    Trophy Points:
    28
    Another thing - in addition to making monolithic files, tar can compress those archive files. For things like text, you can get a fantastic amount of compression. Works great for documentation and source files. rsync, on the other hand keeps files separately in their native format, so you can easily access them...
  5. Yesyesloud

    Yesyesloud Active Member

    Messages:
    279
    Likes Received:
    140
    Trophy Points:
    43
    Best Answer
    If you install winblows without any repartitioning or formatting, it will overwrite your bootloader, being the only bootable OS, but your main Linux partition will keep untouched, so you can use boot-repair or other methods in order to recover your multiboot properly. This may work for single partition multiboot, too.


    If you choose the do-it-all-over path, backup suggestion:

    I always use dd in this case. No need for guis... A very clean solution:

    -Boot from a live cd
    -Set a mount point for the backup disk (you can do it by simply clicking it on your average file manager).
    -Open backup destination folder on terminal.
    -Make the iso image, replacing sdxn with the actual partition you wanna save:
    Code:
    dd if=/dev/sdxn of=mylinux.iso bs=4M
    After repartitioning the disk and reinstalling windows:
    -Boot a live cd again
    -Mount the disk in which the iso was saved, open it on terminal.
    -Replace sdxn with the partition on which the image will be written:
    Code:
    dd if=mylinux.iso of=/dev/sdxn bs=4M
    Then use boot-repair/preferred method.

    Ps: set a bigger block size for dd if you want to increase read/write speed.
    Last edited: Jun 10, 2014
  6. CesarCara

    CesarCara New Member

    Messages:
    24
    Likes Received:
    3
    Trophy Points:
    3
    @Yesyesloud, In the "dd" method my new partition must have the same size as the previous one? It would be nice if I could change it, I want it bigger. Tank you.

    @GrumpyOldMan , tanks for the tips, I'm thinking about using rsync to keep a backup after this problem is solved.
  7. Yesyesloud

    Yesyesloud Active Member

    Messages:
    279
    Likes Received:
    140
    Trophy Points:
    43
    It must have at least the size of the previous. After everything is done, you can fine tune free space with gparted. You're very welcome :)
    CesarCara likes this.
  8. CesarCara

    CesarCara New Member

    Messages:
    24
    Likes Received:
    3
    Trophy Points:
    3
    Now just because I want to learn a little more about this. Why would this happen? Yesyesloud seems to be very confident about this method. Please I don't want to cause a harsh discussion, only want to know the reasons.
  9. Yesyesloud

    Yesyesloud Active Member

    Messages:
    279
    Likes Received:
    140
    Trophy Points:
    43
    There's no harm in using dd if you're minimally careful, really.

    GrumpyOldMan was talking about copying a whole disk over another, which's quite different from making an iso out of a single partition and then writing it over another single partition. We provided different suggestions.

    So if you are to analyze, it would be like comparing intact oranges with peeled tangerines :p (explanation follows)

    Just know what you are copying (if) and where to exactly (of) then you're fine. The "of" end is where there's little danger; however, only if you pick the wrong destination disk & if overwriting it. If one of these conditions is not met, you hardly have a disaster.

    So... Just copying an image file into a preexistent disk partition, not writing the iso as the partition itself, is not dangerous. Worry nawt... Just be careful as to picking the correct partition over which you will write that iso afterwards.


    Anyway, if you intend to clone a disk over another one directly (the whole partition table and all data within), you will use a pattern different from, say, sdxn (x represents the letter of the disk, while n represents the partition "number"). You'd only use sdx. Note that whatever is in the destination disk will be overwritten.

    Example of disk cloning:
    Code:
    dd if=sdx of=sdy bs=32M
    Last edited: Jun 11, 2014
  10. CesarCara

    CesarCara New Member

    Messages:
    24
    Likes Received:
    3
    Trophy Points:
    3
    Now I can see the difference. Thank you Yesyesloud.
    :)
  11. CesarCara

    CesarCara New Member

    Messages:
    24
    Likes Received:
    3
    Trophy Points:
    3
    Giving a feedback...

    Three weeks ago I made the image of my linux (elementaryOS) using the dd method. After formatting the system the way I wanted and installing linux again I needed to get some info I left in the previous system, then I decided to write back the backup image.

    Used:
    Code:
    dd if=mylinux.iso of=/dev/sdxn bs=32M
    And everything was written as it should.

    Thank you!
    Yesyesloud likes this.
  12. Yesyesloud

    Yesyesloud Active Member

    Messages:
    279
    Likes Received:
    140
    Trophy Points:
    43
    You are very welcome :)

Share This Page