LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-20-2005, 11:06 AM   #1
bobbens
Member
 
Registered: Sep 2004
Location: Barcelona
Distribution: Debian, FreeBSD, Gentoo
Posts: 586

Rep: Reputation: 30
good backup image software?


I'm looking for a backup app that does mbr, and partition images. This would be for pretty much loading my partitions monthly to an external 200 GB hdd i have. My linux partition is 12 GB, and i would like to be able to save my mbr as well (have had trouble with that in the past). What program could do this, as well as write the image to fat32 (4gb file limit) natively. I've been using partimage but it has it's limits, it can't do mbr and if the partition image isn't the same size as the partition you want to load it to, it works poorly. Since i would backup my linux partition, i'd need to run it from a cd probably. So it'd be:
  • Partition Image Backup
  • MBR support
  • Ext3 and Fat32 support
  • Works well with 4 gb limit for fat32
  • Runs from cd or floppy, or whatever
Anyone know a backup program that meets as many of these "quirks" as possible, or any combination of programs that can make this all work? Thanks.
 
Old 01-20-2005, 12:03 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
I'm kinda partial to partimage myself, and I use dd to save and restore the MBR / partition table.
I put these scripts in the same partition where I'm going to save the images, then access the scripts from a Linux live cd like Knoppix or Systemrescue ....
If you are going to clone an NTFS partition, you may want to run defrag and scandisk first.

Bootup with the rescue cd and run the Save script to save the partitions to images.

Mount the partition where the images are going to be saved to.
For example ....
mount /dev/hda1 /mnt/images -t vfat

Save script

Code:
#!/bin/bash
##### This saves the MBR / Partition Table
##### and all partitions using partimage
##### example:  ./save /dev/hda

##############################################
#  Ensure that root is running the script.
#
WHOAMI=`/usr/bin/whoami`
if [ $WHOAMI != "root" ]; then
	echo
	echo "You must be root to run this!"
	echo
      exit 1
fi
##############################################

usage()
{
        echo "Usage: $0 /dev/hd#"
        exit 1;
}

test "$1" || usage

if ! [ -e $1 ]; then
    echo "$1 does not exist. Exiting."
    exit 1
fi

if [ -e $1 ]; then
   #Save the MBR with partition table
   mbrfile=`echo -e $1 | awk -F"/" '{print $3}'`;
   dd if=$1 of=/mnt/images/mbr_$mbrfile bs=512 count=1
   clear
   
   for i in `/sbin/sfdisk -l $1 | \
   grep -e "^[/dev]" | awk '{print $1}'`;
   
do
   a=`/sbin/sfdisk -s $i 2> /dev/null`
   test=$(($a + 0))
   stuff=`echo -e $i | sed -e 's/.\{8\}//'`;
   check=`sfdisk -c $1 $stuff`
   
if [ $check != 5 -a $check != 82 -a $test != 0 ];then

   part=`echo -e $i | awk -F"/" '{print $3}'`;
  #Save the partitions
  #use this method for GUI progress
   partimage save -c -b -d -z1 -f3 $i /mnt/images/$part
  
  #use this method for command line progress
  #partimage save -B=foo -c -b -d -z1 -f3 $i /mnt/images/$part
  clear
fi  
done
echo

else
    exit 1
fi

clear
echo "The save operation is complete"
echo "The images have been saved in /mnt/images/"
echo
exit 0
####

Bootup with the rescue cd and run the restore script to restore partitions from images.

Mount the partition where the images are going to be restored from.
For example ....
mount /dev/hda1 /mnt/images -t vfat

Restore script

Code:
#!/bin/bash
##### This retores the MBR / Partition Table
##### and all partitions using partimage
##### example:  ./restore /dev/hda

##############################################
#  Ensure that root is running the script.
#
WHOAMI=`/usr/bin/whoami`
if [ $WHOAMI != "root" ]; then
	echo
	echo "You must be root to run this!"
	echo
      exit 1
fi
##############################################
usage()
{
        echo "Usage: $0 /dev/hd#"
        exit 1;
}

test "$1" || usage

if ! [ -e $1 ]; then
    echo "$1 does not exist. Exiting."
    exit 1
fi

if [ -e $1 ]; then
clear
echo
echo "********************************************************************"
echo "     Caution!!!     This program will erase your hard drive"
echo
echo -n "                Do you want to proceed (Y/N)?"
read answer
if test "$answer" != "Y" -a "$answer" != "y";
then exit 0;
fi
#
clear
   mbrfile=`echo -e $1 | awk -F"/" '{print $3}'`;
   #Erase the old boot sector
   dd if=/dev/zero of=$1 bs=512 count=1
   
   #Restore the MBR with partition table
   dd if=/mnt/images/mbr_$mbrfile of=$1 bs=512 count=1
   clear
   
   for i in `/sbin/sfdisk -l $1 | \
   grep -e "^[/dev]" | awk '{print $1}'`;
   
do
   a=`/sbin/sfdisk -s $i 2> /dev/null`
   test=$(($a + 0))
   stuff=`echo -e $i | sed -e 's/.\{8\}//'`;
   check=`sfdisk -c $1 $stuff`
   
if [ $check = 82 ];then
   #setup the swap partition 
   /sbin/mkswap $i
   
elif [ $check != 5 -a $check != 82 -a $test != 0 ];then

   part=`echo -e $i | awk -F"/" '{print $3}'`;
  #Restore the partitions
  #use this method for GUI progress
  partimage restore -b -f3 $i /mnt/images/$part.000
  
  #use this method for command line progress
  #partimage restore -B=foo -b -f3 $i /mnt/images/$part.000
  clear
fi
done
echo
else
    exit 1
fi

clear
echo "The restore operation is complete"
echo "The partitions have been restored from /mnt/images/"
echo
exit 0
####
 
Old 01-20-2005, 12:21 PM   #3
bobbens
Member
 
Registered: Sep 2004
Location: Barcelona
Distribution: Debian, FreeBSD, Gentoo
Posts: 586

Original Poster
Rep: Reputation: 30
Some questions:
  • About your scripts, do they automatically back up all partitions except swap? ie: /dev/hda1 /dev/hda3 /dev/hda5 plus MBR.
  • If i am running it from /dev/sda1 (external hdd) will it also attempt to back-up /dev/sda1?
  • Is it saving it as tar.gz, tar.bz2 or raw?
  • Does it do smart things like not make a binary equal (let's say /dev/hda3 is at 30% capacity, will it copy even empty sectors?)?
From what i'm thinking is that the best way to run them, from my knoppix cd, would be:
Code:
su
mkdir /mnt/ramdisk/sda
mount -t vfat -o ro /dev/sda1 /mnt/ramdisk/sda
cp /mnt/ramdisk/sda/Scripts/backup-save (what i saved your save script as) /mnt/ramdisk
cp /mnt/ramdisk/sda/Scripts/backup-restore (what i saved your restore script as) /mnt/ramdisk
umount /mnt/ramdisk/sda
cd /mnt/ramdisk/sda/Scripts
./backup-save or ./backup-restore
Just wanna make sure, the only time i can't screw is backing up :P. Thanks alot.
 
Old 01-20-2005, 12:40 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
# About your scripts, do they automatically back up all partitions except swap? ie: /dev/hda1 /dev/hda3 /dev/hda5 plus MBR.
# If i am running it from /dev/sda1 (external hdd) will it also attempt to back-up /dev/sda1?
# Is it saving it as tar.gz, tar.bz2 or raw?
# Does it do smart things like not make a binary equal (let's say /dev/hda3 is at 30% capacity, will it copy even empty sectors?)?
1. The save script backs up all partitions including swap. The restore script restores all partitions including swap. Partimage doesn't do anything with swap or extended partitions.

2. If the live cd can see external drives ( /dev/sda ) then the script should handle it.

3. Partimage uses different compression tools depending on what you select in this line:
partimage save -c -b -d -z1 -f3 $i /mnt/images/$part
partimage --help look for -z0 , z1, z2
The z level has a huge effect on the time used to save an image and has no effect on image restore.

4. I think it skips empty sectors which helps it to be faster than using dd to copy an entire disk.


I wouldn't save anything in ramdisk as that has a nasty habit of disappearing on reboot.

Quote:
Just wanna make sure, the only time i can't screw is backing up :P. Thanks alot.
Might be a good idea to practice on something less important first.
 
Old 01-20-2005, 01:18 PM   #5
bobbens
Member
 
Registered: Sep 2004
Location: Barcelona
Distribution: Debian, FreeBSD, Gentoo
Posts: 586

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by homey
I wouldn't save anything in ramdisk as that has a nasty habit of disappearing on reboot.
[/B]
Yeah. i know, i could just make a script that automatically loads the ramdisk up with the scripts, since it will get erased, but it's the most comfortable way to get it done, in my opinion. The ramdisk is the only "harddrive" you can use with knoppix to save things and stuff like that.
Thanks for the answers, i'll test out the save method, i'll take your word on the restore method. It works "out of the box" right? Just in case, what knoppix cd are you using? I have one that is like 2 months old. Thanks alot!
 
Old 01-20-2005, 01:24 PM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Those scripts don't care what linux you use, can even use it on a hard drive system like FC3. I do use Knoppix 3.7 and system rescue 2.15 most of the time.
 
Old 01-20-2005, 01:27 PM   #7
bobbens
Member
 
Registered: Sep 2004
Location: Barcelona
Distribution: Debian, FreeBSD, Gentoo
Posts: 586

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by homey
Those scripts don't care what linux you use, can even use it on a hard drive system like FC3. I do use Knoppix 3.7 and system rescue 2.15 most of the time.
Was more worried about partimage being there and being the right version and same with dd. Thanks alot!

EDIT: Oh btw, another thing. Is it normal for scripts to not be able to be run from a fat32 partition? I seem to have alot of trouble running scripts, and doing things in fat32. Maybe i have set up bad permissions or something...?

Last edited by bobbens; 01-20-2005 at 01:36 PM.
 
Old 01-20-2005, 01:47 PM   #8
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Fat permissions for root is no problem but user will need some help from the umask. Here's my notes on that using the /etc/fstab.
Find out what id to use with the command like: id fred

Code:
To access the FAT partition (/dev/hdb1) while in Linux. 
Create a directory /mnt/win then type mount /dev/hdb1 /mnt/win -t vfat
To make it available at next boot, edit the /etc/fstab file to include the following line
/dev/hdb1    /mnt/win     vfat      defaults    0   0
To make it writable for users with a group id of 500, edit the /etc/fstab file to include the following line /dev/hdb1 /mnt/win  vfat gid=500,umask=002 0 0
To give the user complete control of that directory, try something like this in the fstab....
/dev/hdb1 /mnt/win vfat uid=500,gid=500,umask=000 1 0
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Good *free* backup/image software BuckRogers01 Linux - Software 9 08-10-2005 12:42 PM
How to Image/Backup a Software RAID Partition? SiegeX Slackware 6 02-24-2005 04:14 PM
Is there any good tape backup software out there? Homer Glemkin Linux - Software 2 12-02-2004 10:46 AM
Good Linux image cataloging software? neitzke Linux - Software 1 02-04-2003 01:15 AM
Whta's Good image editing software? concoran Linux - General 1 01-31-2002 06:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration