HOW TO BACK UP A LINUX PARTITION USING DUMP
Ok kids today we're gonna learn how to back up a linux partition. Er.. Mark! stop hitting Karim with the ruler! Okay now kids pay attention.
So let's say you want to backup the partition that is mounted as root (/), right kids?, which should normally contain all your files. So first we need to know the device name of the partition we're backing up.
Type:
mount
to see all mounted devices. Read the output and find the device mounted as /.
In my case for example I found the line:
/dev/hdb2 on / type ext3 (rw)
Which means here for example that the partition /dev/hdb2 is mounted as root. That's what we want to back up.
Now in today's class we'll be using a windows share to store our backup.
So let's mount a windows share on linux
First we need to create a directory to mount the share at:
mkdir /mnt/windows_share
Now let's mount the share, issue the command:
mount -t smbfs -o username=domain_user,password=domain_password //windows_pc_name_or_ip/share_name /mnt/windows_share
replacing the parameters as necessary with your windows username, password and the path to the share. It might also be possible to do without the username and password if this is an anonymous share.
(Note in my case the name of the windows_pc was not resolving correctly so I used the IP instead.)
Now lets check if it's mounted and all:
ls /mnt/windows_share
You should see the content of your windows share
Lets create a new directory to put the backup on on that share:
mkdir /mnt/windows_share/linux_dump
Now we can start doing the backup
dump -0u -y -M -B 1048576 -f /mnt/windows_share/linux_dump/linux_backup /dev/hdb2
Here is a quick breakdown of the command:
-0 : level 0 : it means back up all files and directory and whatever
u : not sure what that is for
-y : use 'lzo' compression. There are different compression options, I have tried them all but found the -y option to be the most efficient option for my configuration (pentium3 over a 100mbps network).
-M : multiple volumes mode: will automatically create new "volumes" with new names when one voulme reaches it's maximum capacity. Example: linux_backup001, linux_backup002, linux_backup003, etc..
-B : 1048576 : maximum size of the backup volume in kilobytes (that's 1 gigabyte here). Here since we're backing up to files it means the maximum size of the file before dump closes the file and creates a new one with the automatically generated name (see M option above)
-f : file mode : backup will write to a file (not a tape or whatever). this switch is followed by the path of the target file
and finally the location that you want to back up. Here I chose to backup the whole partition, /dev/hdb2 which is mounted as root /
Voila... hit enter and wait.
When the backup is finished, you should see something like:
DUMP: 6254830 blocks (6108.23MB) on 4 volume(s)
DUMP: finished in 1990 seconds, throughput 3143 kBytes/sec
DUMP: Date of this level 0 dump: Wed Jun 21 14:13:48 2006
DUMP: Date this dump completed: Wed Jun 21 14:47:09 2006
DUMP: Average transfer rate: 1594 kB/s
DUMP: Wrote 6254830kB uncompressed, 3300320kB compressed, 1.896:1
DUMP: DUMP IS DONE
As you can see, I just backed up 6 gigabytes in 26 minutes, which is good if you ask me.
But dont ask me how to restore this data... there is a "restore" command that comes with dump and that does just that, but I havent used it yet. That'll be all for today. :)
(samer feel free to use as an article)