rsync backup

    If your computer does not store photographs or
    documents that are dear to you , this note will not be of interest to you. If you are already making backups and the mechanism for working with them is completely satisfactory, this note is also better to skip. If you think that you are well versed in linux, you are unlikely to learn anything new from it. For the rest - I share.

    Why do you need to back up important data?


    As Woland said in The Master and Margarita, the terrible thing is not that a person is mortal, but that he is suddenly mortal. The same is true for hard drives. It seems like only 2 hard drives died for my life, one died suddenly (very valuable data was lost), the other almost suddenly (it was possible to recover part of the data), the situation among my friends on average is not very different. The statistics of death of screws is much less subjective, from Google - on average, a screw lives for several years, and in 60% of cases the screws die suddenly, even for SMART

    In addition to hardware, there are also software reasons for data loss - once the WIN95.CIH virus demolished the first few megabytes of the disk, including FAT, which led to complete inaccessibility of the data. It took a month of furious programming and climbing with DiskEdit to understand the FAT structures and restore them in the absence of the Internet. Once, Patrition Magic crashed while transferring a partition. Once during the work of
    Partition Magic, they turned off the electricity in the shield on the landing. In the last two cases, important data has not been lost - but this is just luck. If you are connected to the network, then there is a chance of an attacker breaking and destroying important data. From this kind of damage the RAID-array will not save.

    How to evaluate the expediency of backup?


    There is such a thing as risk rigidity - this is the probability of occurrence of risk, multiplied by the cost of risk in money. The cost of risk in this case is how much you would be willing to pay money to recover all the lost information. Let us estimate the probability of risk from below. I can only evaluate hardware failures, because I have no other statistics, and this reason
    was already enough for me . The probability of death of a hard drive in 3 years is at least 24% in any case, regardless of whether it is new or not. The probability that death will be sudden, as I wrote, is 60%. Total probability of sudden death in 3 years is 14%. If two railways without mirroring are used, the probability of death of at least one of them during this period is 26%.
    Of course, you need to take into account the value of the data on these disks - I have 2 hard drives with valuable data (the loss of any is fatal) and one with music and films - I will be upset about losing the collection of my chosen music, but I will survive.

    Once I was a student and sometimes lived on 600 rubles a month, but now I can afford some investment in data security. Today I bought an external (USB) hard drive with 320 gigabytes, and this pleasure cost me 3,000 rubles. Why a hard drive? Because I have a lot of data - only pictures that are dear to my heart occupy 40 gigabytes of that way. Yes, I don’t want to spend too much time on this and would like, without sorting everything that has accumulated over many years into “important - unimportant” backups in general except music and movies. Why external? The ability to store separately from the computer in case of theft (although this is more relevant for laptops), not connected to the computer (in case of an error fatal to data).

    Security.


    I am not paranoid, but the hard drive contains data whose safety I need not only - for example, it is not at all necessary to fall into the hands of strangers photographs of familiar girls in the nude style. Accordingly, the disk is encrypted - I encrypted the whole. In debian, everything is done out of the box in a few minutes and therefore I have no doubt that I can easily recover these data later, the main thing is to remember to write down the used cascade of algorithms and the password hint on a piece of paper and store it in a box with a screw. The use of third-party commercial-grunted funds I would highly recommend.

    Getting down.


    Without hesitation, I decided to back up all the unused (but just in case it’s better not to lose) partitions entirely, for the test I took a section with the once installed WIN98: we

    # cp /dev/hda1 /mnt/backup/images/
    test: Hurray! Works! Since I have working data in ext2 and ext3 file systems, I want to use the fact that the file attributes in ext2 / ext3 may contain information about its backup. However, dump is highly discouraged on mounted file systems - www.rhd.ru/docs/manuals/enterprise/RHEL-4-Manual/admin-guide/s1-disaster-rhlspec.html , dump.sourceforge.net/isdumpdeprecated. html
    # mkdir /mnt/hda1-backup-test
    # mount /mnt/backup/images/hda1 /mnt/hda1-backup-test -o loop
    # ls /mnt/hda1-backup-test/
    boot.ini io.sys ntdetect.com (и так далее)




    . There is a huge choice between the general backup technologies - tar, cpio, backup-manager, bacula and so on, but for now I have settled on rsync + cp - because the result can be read transparently anywhere without unpacking and reading all incremental archives.

    $ sudo rsync --archive --one-file-system /etc /home /root --delete /mnt/backup/rsync/`date +%F--%H-%M`

    Need to save the last few backups? Please use the fact that the --link parameter of cp creates a hard link to the file instead of copying it. Check: I want to see the differences with backup? “Emulate” copying the current state to the backup state. Want to see the differences between backups? Similarly. That's all. Sources: About encryption: aiz-linux.blogspot.com/2007/11/gnulinux.html About screws: habrahabr.ru/blog/hardware/24009.html

    $ sudo rsync --archive --one-file-system /etc /home /root --delete /mnt/backup/rsync/latest/
    $ sudo cp --archive --link /mnt/backup/rsync/latest/
    /mnt/backup/rsync/`date +%F--%H-%M`




    $ ls /mnt/backup/rsync/
    2008-04-03--04-29 2008-04-03--04-34 latest




    $ sudo rsync --archive --dry-run --verbose --one-file-system /etc /home /root --delete /mnt/backup/rsync/latest/



    $ sudo rsync --archive --dry-run --verbose --delete
    /mnt/backup/rsync/2008-04-03--04-41/
    /mnt/backup/rsync/2008-04-03--04-29/






    ,
    mydebianblog.blogspot.com/2007/11/blog-post.html
    About rsync and more: www.mikerubel.org/computers/rsync_snapshots

    You can also see:
    rsnapshot - also uses rsync and hard links, better suited for backup to removable media or network: habrahabr.ru/blogs/linux/45912

    Also popular now: