How to backup a linux server running a software raid

5,612

Solution 1

Normally from the live system you could force assemble existing RAID arrays:

mdadm --assemble --scan --config=partitions

This will find and create the necessary md devices.

From the live CD, If you know your RAID arrays devices you can force assemble them too:

mdadm --assemble --force /dev/md... /dev/sd... /dev/sd...

Mdadm will "do the right thing".

Solution 2

It works only if you are using raid 1 (Mirror disks) If you think your backup won't be consistent under load, I recommand you stop all possible services running on your box instead of rebooting it on rescue mode. As it's name suggests, rescue mode is for rescue and you are not in trouble :)

Share:
5,612
merlin
Author by

merlin

Updated on September 18, 2022

Comments

  • merlin
    merlin almost 2 years

    I would like to backup a production server running ubuntu 10.04 LTS on a software raid. In order to to that I have rebooted into a rescue system which is running in RAM.

    df -h on ubuntu looks like this:

    Filesystem            Size  Used Avail Use% Mounted on
    /dev/md2             1016G  5.3G  960G   1% /
    none                   16G  220K   16G   1% /dev
    none                   16G     0   16G   0% /dev/shm
    none                   16G   68K   16G   1% /var/run
    none                   16G     0   16G   0% /var/lock
    none                   16G     0   16G   0% /lib/init/rw
    /dev/md3              1.7T  274G  1.4T  17% /home
    /dev/md1              496M   69M  402M  15% /boot
    

    The thing is, that after booting to rescue the md devices are not present. Instead I do see the 2 harddrives directly:

    RAM  32112 MB
    Disk /dev/sda: 3000.6 GB  (=> 2861 GIB)
    Disk /dev/sdb: 3000.6 GB  (=> 2861 GIB)
    

    I need to exclude some folders as the backup image would otherwise contain xxx GB of data. So partimage as a backup solution does not work. I am using a regular tar with exclude:

    mkdir /mnt/md1_backup/
    sudo mount /dev/md1 /mnt/md1_backup/
    tar cvzpf test.taz ./ --exclude=test.taz  --exclude...
    

    Can I simply mount /dev/sda and run the tar with all the exclude commands? I could imagine, that without the system raid the folders like /home are not present and I also fear that I could even break the system by mounting /dev/sda

    How can I proceed from here? My goal is a full system backup without some data dirs.

    • Janne Pikkarainen
      Janne Pikkarainen over 12 years
      Why would you need to take your system offline for a backup?
    • merlin
      merlin over 12 years
      Because I believe the backup made under load would be inconsistent.
    • merlin
      merlin over 12 years
      I am not using LVM and do not mind a few minutes downtime.
    • MastaJeet
      MastaJeet over 12 years
      What is this "resuce system?" The 10.04LTS server installation CD has a rescue mode that should start up any MD RAID devices you have. Cf. help.ubuntu.com/10.04/installation-guide/amd64/rescue.html
  • merlin
    merlin over 12 years
    This would only work from the live system. The situation is, that I am booting into a rescue system in RAM which is a complete other install. There I can see the two hard drives available. mdadm --assemble --scan --config=partitions mdadm: No arrays found in config file
  • merlin
    merlin over 12 years
    Ok. I tried to to create a tar directly on the production server under load. The creation of the tar file exists with 1 after about 1.6GB and the message"tar: /sys/module/ipt_REDIRECT/sections/.strtab: File shrank by 4077 bytes; padding with zeros"
  • m0ntassar
    m0ntassar over 12 years
    well, /sys is a filesystem (sysfs) you should consider to skip when backuping just like /proc. You are safe skipping it
  • merlin
    merlin over 12 years
    Skipping /proc/ and /sys worked. I have a tar now from / as a backup. I would also like to backup the bootsector. The system is a software raid 1. Can I do something like this? dd if=/dev/sda of=/tmp/sda-mbr.bin bs=512 count=1
  • m0ntassar
    m0ntassar over 12 years
    what's the point of backuping "bootsector", you don't need to back up it, you will be safe making a new grub install