Сделайте возрастающие резервные копии из Linux

Попытайтесь найти шанс своего сбоя сервера. Также фигура, сколько времени это возьмет Вас для получения замены и восстановленных резервных копий. Именно так долго Вы будете снижаться для. Цена сервера и время, настраивая дублирование - то, сколько Вы платите для сокращения возможности. Действительно ли цена стоит того к Вашей компании и серверу, или деньги были бы лучше потрачены в другом месте?

Помните, если оба сервера находятся в том же месте, том же питании, сетевом оборудовании, и т.д.... они все еще могли бы оба понизиться. И проблемы с самой базой данных могут копируемый, и она может все еще понизиться. Таким образом, это - сколько Вы готовы оплатить дублирование уровня устройств?

1
задан 22 August 2011 в 20:27
3 ответа

I use a self written bash script for it using rsync and cpio: http://pastebin.com/uRdH2uQf

So, the first thing I have done is create a directory structure. I work like this: создавать резервную копию каждый день, на 7-й день (воскресенье) я беру последнюю резервную копию (предыдущая неделя, воскресенье) и помещаю ее еженедельно. Каждые 4 недели я делаю ежемесячную резервную копию.

Все эти резервные копии являются инкрементными и основаны на 1 полной резервной копии.

моя структура каталогов основана в / mnt / backups и выглядит так:

--- SERVER1
   |--- daily
        |  --- 0
        |  --- 1
        |  --- 2
        |  --- 3
        |  --- 4
        |  --- 5
        |  --- 6
    |--- weekly
        |--- 0
        |--- 1
        |--- 2
        |--- 3
    |--- monthly
        |  --- 0
        |  --- 1
        |  --- 10
        |  --- 2
        |  --- 3
        |  --- 4
        |  --- 5
        |  --- 6
        |  --- 7
        |  --- 8
        |  --- 9

Я также использую сценарий для быстрого создания этой структуры: http://pastebin.com/LyFLBZGx

Итак, все мои скрипты находятся в / root / backup_tools. Сценарий backup.sh помещается в crontab и запускается каждый день. У меня есть обмен ключами с моего резервного сервера на все мои серверы, которые мне нужны для резервного копирования. In my tools dir I place my exclude files (folders / files I do not want to backup) in this format:

rsync.exclude.server1

These files contain the not to backup dirs :

/proc
/sys
/tmp

I also use my /.ssh/config file to add the hosts (f.e.: server1.example.com is defined as server1 with ssh port xxxx and username foo). This makes it a lot easier to add the servers to backup in the first line of the script.

Host server1
        User root
        Port 31337
        Hostname server1.example.com

The script will check the rule SERVERS="" and for every server defined there (space seperated) it will start an incremental backup (and excluding all the dirs in the exclude files).

It will use cpio for the rotating of the dirs (cpio allows a copy with link to the actual block on the disk, so the file will show up twice on your hard drive, and only use space once. Its not a symlink either, because when you delete the original file, the duplicate will still be readable)

I hope this was somewhat clear. The bash script is not perfect, but it does its job. I use it to backup 4 servers every night. I have backups of a couple of months now and they are not big. It is really space saving.

3
ответ дан 3 December 2019 в 16:38

In your example, you mention symlinks, however rsync deals in hard links. You mention in the comments that you're unsure what links are, so the Reader's Digest version is:

  • A symlink is like a "shortcut" in Windows -- it quite simply tells you "the file you want is over there"
  • A hard link has no direct correlation to Windows -- at least not in common usage. A hard link is quite literally another "entry point" to the same file; it appears to the file system to be an exact duplicate of the linked file, however on the physical disk there is only one copy of the file, no matter how many hard links there are.

rsync's '--link-dest' option creates hard links for files that don't change. This makes it somewhat confusing when trying to determine if your script is working as intended, because if you were to check the size of all the files in your backup directory (e.g. using du -sh [directory] or by checking the properties in the GUI), it would look to be the same size as your original directory, regardless of how many of those files are actually hard links and thus not taking up any additional space.

Check the space on disk, using either df or via GUI tools that look at actual disk space. Then, run your backup script, and check again -- if no files changed, disk usage should not change at all (well, okay, a tiny bit -- it takes a small amount of space for the hard link itself); if files did change, disk usage will increase by only what files changed.

In either case, rsync's output will list the files it is checking, whether it's actually copying them or not. Look at the end, at the "speed-up" value -- if that's a number less than 1, that indicates you got at least some hard links, as that represents the percentage difference from what rsync estimates it would have taken to copy all the files.

2
ответ дан 3 December 2019 в 16:38

Вы действительно хотите сделать это с помощью жестких ссылок. Лучшим инструментом для такого рода резервных копий на машинах Linux является rsnapshot . Он делает именно то, что вы описываете, и его довольно просто настроить.

2
ответ дан 3 December 2019 в 16:38

Теги

Похожие вопросы