Common backup Linux backup tools – 2

3. Dump

Dump is a nice tool to backup an entire filesystem (not for a specific subdirectory). It supports full and incremental backup in nature.

Create full backup

[root@centos ~]# mount
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sdb1 on /mnt/doc type ext3 (rw)

[root@centos ~]# dump -0uf /root/backup/full /mnt/doc

DUMP: Date of this level 0 dump: Tue Jan 31 01:42:20 2012
DUMP: Dumping /dev/sdb1 (/mnt/doc) to /root/backup/full
DUMP: Label: none
DUMP: Writing 10 Kilobyte records
DUMP: mapping (Pass I) [regular files]
DUMP: mapping (Pass II) [directories]
DUMP: estimated 475 blocks.
DUMP: Volume 1 started with block 1 at: Tue Jan 31 01:42:25 2012
DUMP: dumping (Pass III) [directories]
DUMP: dumping (Pass IV) [regular files]
DUMP: Closing /root/backup/full
DUMP: Volume 1 completed at: Tue Jan 31 01:42:25 2012
DUMP: Volume 1 490 blocks (0.48MB)
DUMP: 490 blocks (0.48MB) on 1 volume(s)
DUMP: finished in less than a second
DUMP: Date of this level 0 dump: Tue Jan 31 01:42:20 2012
DUMP: Date this dump completed: Tue Jan 31 01:42:25 2012
DUMP: Average transfer rate: 0 kB/s
DUMP: DUMP IS DONE
[root@centos ~]# ls -alh /root/backup/
total 580K
drwxr-xr-x 2 root root 4.0K Jan 31 01:42 .
drwxr-x— 24 root root 4.0K Jan 31 01:40 ..
-rw-r–r– 1 root root 10K Jan 29 00:01 29012012
-rw-r–r– 1 root root 10K Jan 30 00:00 30012012
-rw-r–r– 1 root root 10K Jan 31 00:00 31012012
-rw-r–r– 1 root root 490K Jan 31 01:42 full
-rw-r–r– 1 root root 10K Mar 8 2012 home08032012

Create incremental backup 1

[root@centos ~]# touch /mnt/doc/file1 /mnt/doc/file2
[root@centos ~]# dump -1uf /root/backup/incremental1 /mnt/doc

DUMP: Date of this level 1 dump: Tue Jan 31 01:44:55 2012
DUMP: Date of last level 0 dump: Tue Jan 31 01:42:20 2012
DUMP: Dumping /dev/sdb1 (/mnt/doc) to /root/backup/incremental1
DUMP: Label: none
DUMP: Writing 10 Kilobyte records
DUMP: mapping (Pass I) [regular files]
DUMP: mapping (Pass II) [directories]
DUMP: estimated 468 blocks.
DUMP: Volume 1 started with block 1 at: Tue Jan 31 01:44:55 2012
DUMP: dumping (Pass III) [directories]
DUMP: dumping (Pass IV) [regular files]
DUMP: Closing /root/backup/incremental1
DUMP: Volume 1 completed at: Tue Jan 31 01:44:55 2012
DUMP: Volume 1 480 blocks (0.47MB)
DUMP: 480 blocks (0.47MB) on 1 volume(s)
DUMP: finished in less than a second
DUMP: Date of this level 1 dump: Tue Jan 31 01:44:55 2012
DUMP: Date this dump completed: Tue Jan 31 01:44:55 2012
DUMP: Average transfer rate: 0 kB/s
DUMP: DUMP IS DONE

[root@centos ~]# ls -alh /root/backup/
total 1.1M
drwxr-xr-x 2 root root 4.0K Jan 31 01:45 .
drwxr-x— 24 root root 4.0K Jan 31 01:40 ..
-rw-r–r– 1 root root 10K Jan 29 00:01 29012012
-rw-r–r– 1 root root 10K Jan 30 00:00 30012012
-rw-r–r– 1 root root 10K Jan 31 00:00 31012012
-rw-r–r– 1 root root 490K Jan 31 01:42 full
-rw-r–r– 1 root root 480K Jan 31 01:44 incremental1

Create incremental backup 2:

[root@centos ~]# touch /mnt/doc/newfile3
[root@centos ~]# echo “new line” >> /mnt/doc/file1
[root@centos ~]# dump -2uf /root/backup/incremental2 /mnt/doc

DUMP: Date of this level 2 dump: Tue Jan 31 01:47:58 2012
DUMP: Date of last level 1 dump: Tue Jan 31 01:44:55 2012
DUMP: Dumping /dev/sdb1 (/mnt/doc) to /root/backup/incremental2
DUMP: Label: none
DUMP: Writing 10 Kilobyte records
DUMP: mapping (Pass I) [regular files]
DUMP: mapping (Pass II) [directories]
DUMP: estimated 472 blocks.
DUMP: Volume 1 started with block 1 at: Tue Jan 31 01:47:59 2012
DUMP: dumping (Pass III) [directories]
DUMP: dumping (Pass IV) [regular files]
DUMP: Closing /root/backup/incremental2
DUMP: Volume 1 completed at: Tue Jan 31 01:47:59 2012
DUMP: Volume 1 480 blocks (0.47MB)
DUMP: 480 blocks (0.47MB) on 1 volume(s)
DUMP: finished in less than a second
DUMP: Date of this level 2 dump: Tue Jan 31 01:47:58 2012
DUMP: Date this dump completed: Tue Jan 31 01:47:59 2012
DUMP: Average transfer rate: 0 kB/s
DUMP: DUMP IS DONE

[root@centos ~]# ls -alh /root/backup/
total 1.6M
drwxr-xr-x 2 root root 4.0K Jan 31 01:47 .
drwxr-x— 24 root root 4.0K Jan 31 01:40 ..
-rw-r–r– 1 root root 10K Jan 29 00:01 29012012
-rw-r–r– 1 root root 10K Jan 30 00:00 30012012
-rw-r–r– 1 root root 10K Jan 31 00:00 31012012
-rw-r–r– 1 root root 490K Jan 31 01:42 full
-rw-r–r– 1 root root 480K Jan 31 01:44 incremental1
-rw-r–r– 1 root root 480K Jan 31 01:47 incremental2

Restore:

[root@centos mnt]# rm -rf /mnt/doc/*
[root@centos mnt]# cd /mnt/doc
[root@centos doc]# ls
[root@centos doc]# restore -rf /root/backup/full
[root@centos doc]# ls
dir1 dir2 dir3 restoresymtable
[root@centos doc]# restore -rf /root/backup/incremental1
[root@centos doc]# ls
dir1 dir2 dir3 file1 file2 restoresymtable
[root@centos doc]# cat file1
[root@centos doc]# restore -rf /root/backup/incremental2
[root@centos doc]# ls
dir1 dir2 dir3 file1 file2 newfile3 restoresymtable
[root@centos doc]# cat file1
new line
[root@centos doc]#

Done.

This lab is done on:

[root@centos ~]# lsb_release -a | grep Description ; echo “Linux kernel: `uname -r`”
Description: CentOS release 5.7 (Final)
Linux kernel: 2.6.18-274.18.1.el5

dongthao

Advertisements

About dongthao

"Man does not simply exist but always decides what his existence will be, what he will become the next moment"
This entry was posted in Linux, Linux Tutorial and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s