You are on page 1of 7

1.

CPIO

Full backup:

[root@localhost /]# find /home/ -print | cpio -oF /root/backup/cpiofull


11 blocks

Incremental backup 1:

[root@localhost /]# touch /home/newfile1 /home/newfile2


[root@localhost /]# find /home/ -cnewer /root/backup/cpiofull -print
/home/newfile1
/home/newfile2
[root@localhost /]# find /home/ -cnewer /root/backup/cpiofull -print | cpio -oF
/root/backup/cpioinc1
4 blocks

Incremental backup 2:

[root@localhost /]# touch /home/newfile3


[root@localhost /]# touch /home/newfile4
[root@localhost /]# find /home/ -cnewer /root/backup/cpioinc1 -print
/home/newfile4
/home/newfile3
[root@localhost /]# find /home/ -cnewer /root/backup/cpioinc1 -print | cpio -oF
/root/backup/cpioinc2
4 blocks

And so on for next incremental backups.

Check our backup files:

[root@localhost /]# cpio -tF /root/backup/cpioinc1 2>/dev/null


home/
home/newfile1
home/newfile2
[root@localhost /]# cpio -tF /root/backup/cpioinc2 2>/dev/null
home/
home/newfile4
home/newfile3

Restore:

Restore Full backup:


[root@localhost /]# rm -rf /home/*
[root@localhost /]# ls /home/
[root@localhost /]# cd /
[root@localhost /]# cpio -iF /root/backup/cpiofull 2>/dev/null
[root@localhost /]# ls home/
user1  user2  user3  user4  users

Restore Incremental backup 1:

[root@localhost /]# cpio -iF /root/backup/cpioinc1 2>/dev/null


[root@localhost /]# ls /home/
newfile1  newfile2  user1  user2  user3  user4  users

Restore Incremental backup 2:

[root@localhost /]# cpio -iF /root/backup/cpioinc2 2>/dev/null


[root@localhost /]# ls home/
newfile1  newfile2  newfile3  newfile4  user1  user2  user3  user4  users

Done.

2. PAX

Create full backup

[root@localhost ~]# pax -wf /root/backup/$(date +%d%m%Y) /home/


[root@localhost ~]# ls -alh /root/backup/
total 200K
drwxr-xr-x  3 root root 4.0K Jan 29 00:59 .
drwxr-x— 20 root root 4.0K Jan 29 00:17 ..
-rw-r–r–  1 root root  40K Jan 29 00:59 29012012
-rw-r–r–  1 root root 5.5K Jan 29 00:42 cpiofull
-rw-r–r–  1 root root  512 Jan 29 00:43 cpioinc1
-rw-r–r–  1 root root  512 Jan 29 00:44 cpioinc2
drwxr-xr-x  7 root root 4.0K Jan 29 00:29 home
-rw-r–r–  1 root root  40K Jan 27 05:21 paxbackup
-rw-r–r–  1 root root  10K Jan 28 00:00 Sat
-rw-r–r–  1 root root  40K Jan 28 00:00 Sat1

Create Incremential backup 1. We’ve done the full backup for the date “29 Jan” so next we will
do incremental backup for “30 Jan”. Just set the date to what we want.

[root@localhost ~]# date


Sun Jan 29 00:59:56 ICT 2012

[root@localhost ~]# date -s “30 Jan 2012″


Mon Jan 30 00:00:00 ICT 2012
[root@localhost ~]# touch /home/newfile1 /home/newfile2
[root@localhost ~]# pax -T 0000 -wf /root/backup/$(date +%d%m%Y) /home
[root@localhost ~]# ls -alh /root/backup/
total 104K
drwxr-xr-x  2 root root 4.0K Jan 30 00:04 .
drwxr-x— 20 root root 4.0K Jan 29 00:17 ..
-rw-r–r–  1 root root  40K Jan 29 00:59 29012012
-rw-r–r–  1 root root  10K Jan 30 00:01 30012012
-rw-r–r–  1 root root 5.5K Jan 29 00:42 cpiofull
-rw-r–r–  1 root root  512 Jan 29 00:43 cpioinc1
-rw-r–r–  1 root root  512 Jan 29 00:44 cpioinc2

Create Incremential backup 2 for 31 Jan.

[root@localhost ~]# date


Mon Jan 30 00:07:18 ICT 2012
[root@localhost ~]# date -s “31 Jan 2012″
Tue Jan 31 00:00:00 ICT 2012
[root@localhost ~]# touch /home/
newfile1  newfile2  user1/    user2/    user3/    user4/    users/
[root@localhost ~]# touch /home/newfile3
[root@localhost ~]# echo “newline” >> /home/newfile1
[root@localhost ~]# pax -T 0000 -wf /root/backup/$(date +%d%m%Y) /home/
[root@localhost ~]# ls -alh /root/backup/
total 120K
drwxr-xr-x  2 root root 4.0K Jan 31 00:01 .
drwxr-x— 20 root root 4.0K Jan 29 00:17 ..
-rw-r–r–  1 root root  40K Jan 29 00:59 29012012
-rw-r–r–  1 root root  10K Jan 30 00:01 30012012
-rw-r–r–  1 root root  10K Jan 31 00:01 31012012
-rw-r–r–  1 root root 5.5K Jan 29 00:42 cpiofull
-rw-r–r–  1 root root  512 Jan 29 00:43 cpioinc1
-rw-r–r–  1 root root  512 Jan 29 00:44 cpioinc2

Restore. We follow the backup order respectedly.

[root@centos ~]# rm -rf /home/*


[root@centos ~]# pax -rf /root/backup/29012012
[root@centos ~]# ls /home/
user1 user2 user3 user4 users

[root@centos ~]# pax -rf /root/backup/30012012


[root@centos ~]# ls /home/
newfile1 newfile2 user1 user2 user3 user4 users
[root@centos ~]# cat /home/newfile1
[root@centos ~]# pax -rf /root/backup/31012012
[root@centos ~]# ls /home/
newfile1 newfile2 newfile3 user1 user2 user3 user4 users
[root@centos ~]# cat /home/newfile1
newline

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]#

You might also like