Re: How to restore rsync backup?

"Nicholas Frost" <[email protected]> Mon, 21 Sep 2009 22:13:21 -0600 (MDT)
Newsgroups gmane.org.user-groups.nmlug
Message-ID <[email protected]>
> My hard drive died yesterday, and I bought a replacement (actually, a
> new machine with a new HD).
>
> I've been making backups using (essentially) "rsync -r /", but I'm not
> sure how to restore them. Specifically:
>
>  % I need to install some OS on the new machine just to transfer
>  files. My previous OS was RedHat 7.3 (I've customized it a lot so I
>  don't want to upgrade). Do I need to install this, or can I install
>  some other Linux (eg, damnsmalllinux.com or another minimal Linux)
>  just to transfer the files?

If you have customizations or specifics requirements for Redhat 7.3, you
will need to use that. However, you might want a more current version or
distribution.

>  % I'm pretty sure "rsync -r /" doesn't back up the master boot record
>  (MBR), since that isn't part of the root filesystem. How do I create
>  that on the new hard drive?

the "-r" just means recursive copy of files.  So, wherever you have
Rsynced the data to, your entire file system should be on that secondary
drive, but since you didn't say where  you put your Rsync backups, it's
hard to know.

I would think you'd want to set up a new Linux installation and manually
copy over the portions of your data you want to restore.  Simply restoring
the entire rsync backup of your file system is unlikely to work if applied
to a new installation of Redhat 7.3 or another distribution but you could
try it if you have a backup of or can extract  your partition table, boot
sector, etc. and you essentially re-create an identical RH 7.3
installation at the same patch level.

So, the long way is to set up a new Linux installation, apply all patches
and updates, and then mount the drive with your backups, navigate into the
areas you want to restore and do that, e.g.

cd /backupdrive/home/sarang
rsync --force -avur . /home/sarang

you can test your rsync string if you want with the --dry-run switch.  Or,
you can cp -r the files in various locations to the new installation, or
use tarfiles, etc.

Depending on how definitively dead your hard drive is (does it spin up?)
there are people in Santa Fe who could likely restore your machine to a RH
7.3 environment more or less as it was before, but I don't know any who
would do that for karma points alone.

>  % Once I get an OS running from the new drive, will rsync'ing cause
>  problems, since I'm replacing files that are in use? Ideally, the new
>  hard drive will show up like /mnt/newdrive or something, so that I
>  can rsync w/o wiping out the files that are in use. That should be
>  what happens when I boot from CD, yes?

Yes, you want to quiesce the file system, by booting from CD for example,
but if you overwrite everything below the root dir "/" it's possible if
not highly likely that you will break your Linux installation...unless you
have RH 7.3 installed at the same patch level, same partition layout, etc.

>  % I think I can do some of this by booting from CD, but how do I tell
>  the CD installer: "I don't want to install: just give me enough to
>  mount my hard drive + networking + rsync"?

If you know your previous partition layout you can create an identical
partition table, install grub and then quiesce the new system and write
your files back, but this assumes you did not change drive sizes with the
replacement drive?

If the old drive's first few sectors can be read, you might try to use dd
to write the old drive's partition table and boot sector to the new drive
and then restore your file system from the backup to the new drive.

You could install RH 7.3 on the new drive (with same partition layouts),
then use mkfs to make an empty filesystem on each partition (zero those
partitions, removing all data) and then write your data back from your
Rsync backup.  That *might* work as long as grub is installed, can see the
old kernel, all files are put back in proper place, etc.

Good luck.

-nick




_______________________________________________
NMLUG mailing list
[email protected]
http://lists.b9.com/cgi-bin/mailman/listinfo/nmlug