Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
####
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.
# 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.
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!
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.
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...?
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.