Solved

Newbie - CP Question

Posted on 2004-09-15
10
299 Views
Last Modified: 2010-04-21
Hi

How can I make a backup of my whole linux drive, I've got hda2 and hda5 which has data, how can I back these up to a local hard drive set as slave (hdb1) I don't need compression at all, can I use cp or dd? If I copy my data back will my linux work again if I backed up the mbr as well?

Just another thing, how can I show a picture in another tty session while cp or dd or copy process runs on tty1?

Thanks

0
Comment
Question by:reaper_11
  • 5
  • 5
10 Comments
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
The best way would be to use dump (see 'man dump' for details). You can write the dump image to a file(s) on hdba1, or by using a pipe to restore write each file system to a separate partition on hdb. The MBR won't be copied using that method, but it is easy to reset it from a floppy or rescue boot.

Linux supports multiple consoles (Ctrl-Alt-F2, Ctrl-Alt-F3, etc) so you can run the backup in in one session and do something else in another.
0
 

Author Comment

by:reaper_11
Comment Utility
can you maybe gove me an example of how dump works? how long will dumpp take on an 8 gig drive...

The diffrent session thing: I want to automate it and not push alt+F2 etc. while dump runs in tty1 I want to write "echo hello" in tty2 atomatically?
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
Since dump only operates on the actual data in use how long it would take depends on how much of that 8Gb is actually used. When I do this on my laptop across the network (100Mbps) to another system it takes a few of hours. That's a total of about 15Gb.

I don't know what Linux version you have and whether it & dump supports large files (greater than 2Gb) or not. But in its simplest form you might do something along the lines of:

mkdir /mnt/backup
mount /dev/hdb1 /mnt/backup
dump 0af /mnt/backup/root-fs.dump /
dump 0af /mnt/backup/home-fs /home

To avoid the "open files" problem where a file changes during a backup I like to do my backups with the system in single mode when using dump or tar. Commercial products like Legato Networker can do backups that are valid even if a file changes during the backup.
0
 

Author Comment

by:reaper_11
Comment Utility
Thanks for the help!!!

So if I have a HDA2(Primary) and a HDA5(Logical) and another drive local HDB1(set as slave) I can do the following:

mkdir/mnt/src1
mkdir /mnt/src2
mkdir /mnt/des
mount /dev/hda2 /mnt/src1
mount /dev/hda5 /mnt/src2
mount /dev/hdb1 /mnt/dest

dump 0af /mnt/dest/backup /mnt/src1

What does the 0af do?

Thanks again!
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
I presumed that hda2 & hda5 are already mounted, probably as / & maybe /home or /usr. So all you need to do is mount hdb1, do the dumps, and then unmount it. You can take the system down to run level 1 (single user mode) and back up to 3 or 5 without even rebooting. If it's done that way the Linux file system will remain mounted. Done this way you can script this process so that it is run from cron when it won't interfere with normal use.

0 - do a level zero dump, which is a full dump of all data
a - write until end of media is seen, i.e., don't assum the media is of fixed (known) length
f - the output filespec for the dump follows
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:reaper_11
Comment Utility
so all I do is mount hdb1 mount /dev/hdb1 /mnt/dest and then dump it
dump 0af /mnt/dest/image.img /

how can I extract the above image.img? if my drive fails, how can I copy the data back to hda1 (new drive), will it wirk if I dump the data back to the nw hda1 and restore the boot record then restart?

Thanks again
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
Restoring things gets a little more interesting. The worst case is if hda dies. In that case the first step is to boot into rescue mode from a distro CD or any of the mini-linuxen (Knoppix, tomsrtbt, etc) and partition the new disk, make file systems and swap (see 'man mke2fs' & 'man mkswap'), and then restore the data. For that you use, surprisingly, 'restore'. As an example assuming that we are in rescue mode and the file systems have been created you could do:

mkdir /mnt/disk
mount /dev/hda2 /mnt/disk
mkdir /mnt/backup
mount /dev/hdb1 /mnt/backup
cd /mnt/disk
restore rvf /mnt/backup/root-fs.dump
rm restoresymtable

When all of the data has been restored you'd do:

chroot /mnt/disk
lilo
--or--
grub-install

to re-create the MBR.
0
 

Author Comment

by:reaper_11
Comment Utility
Hi jlevie  

Thanks alot for your time and patients! This will be the last post then I will accept your answer. Please try helping me out as much as you can. The reason I asked the question in the first place is becaause I want to do the following:

Background: I've got a live linux cd, ISO Linux that just boots and extracts, no install. The machine I'm booting it on is an OS/2 box with 1 physical drive that's split into 2 partitions both 7.98 Gb (HDA2 - Physical) and (HDA5 - Logical) with the filesystem as HPFS. Like I said before, I want to do the following:

1.) Make a backup of the whole hard drive (the 2 partitions) I think I can use dump, onto another local disk (HDB1)
2.) I want to back up the partition tables and mbr onto another local disk (HDB1.) I then want to FDISK the whole drive, then with my ISO linux make a script that runs on startup and creates 2 partitions on the drive as above (HDA2) and (HDA5) and format the 2 partitions as HPFS and then restore the data, I can prob. do this with the restore command like you said.
4.) I want to restore the partition tables and MBR

Every thing gets backed up onto the extra local physical drive (HDB1), So basically a breakdown would be to back the drive as is, fdisk it so there's no filesystem and restore everything so that it operated like normal before I did the back up with dump...

I've read up and I think I can back up the partition table and MBR with:
<SNIP>
cd /root
mkdir partition-backup
cd partition-backup
dd if=/dev/hda of=backup-hda.mbr count=1 bs=512

sfdisk -d /dev/hda > backup-hda.sf
<SNIP>


And restore the partition tables and MBR with:
<SNIP>
dd if=backup-hda.mbr of=/dev/hda

sfdisk /dev/hda < backup-hda.sf
<SNIP>

Thanks again for your time, please help me as far as you can, I appreciate it. I will accept your answer.

Thanks
R.
0
 
LVL 40

Accepted Solution

by:
jlevie earned 325 total points
Comment Utility
> The machine I'm booting it on is an OS/2 box

You should have said that in the question, because it changes everything. From a linux boot you'll only be able to use dd to do this backup.

What you'd want to do there is 'dd if=/dev/hda of=/dev/hdb1/disk.img which will get everything (the MBR, hda2, & hda5). That means of course that /dev/hdb1 must be at least as large or larger than hda. The restore would simply be the inverse of that (dd if=/dev/hdb1/disk.img of=/dev/hda).

I'd recommend that you test the restore onto a a different disk before wiping out your OS/2 system.
0
 

Author Comment

by:reaper_11
Comment Utility
Thanks alot!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to pass an array to a shell script? 5 168
Linux daemon 11 346
how to run a command as a nologin user 7 265
Openwrt vnstat 9 108
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now