Backing up live linux – work in progress

In this worklog, I’m going to use dump to backup my system and chattr to mark some folders I don’t want to backup.

Using Chattr to mark folders we do not want to backup.
Quote: A file with the ‘d’ attribute set is not candidate for backup when  the dump(8) program is run.
Source: http://www.linuxcommand.org/man_pages/chattr1.html

-V  Verbose - if you don't use -V you do not get any output.
+d  set "no dump" tag on folder
-d  remove "no dump" tag on folder

To set the immutable flag:
# chattr -V +d /var/min-backups/
chattr 1.41.12 (17-May-2010)
Flags of /var/min-backups/ set as ------d----------e-

To check if ‘d’ flag is set
# lsattr -d /var/min-backups/
------d----------e- /var/min-backups/

To remove the immutable flag:
# chattr -V -d /var/min-backups/
chattr 1.41.12 (17-May-2010)
Flags of /var/min-backups/ set as -----------------e-

Using dump to do a live backup of thesystem
Dump source: http://www.freebsd.org/cgi/man.cgi?query=dump&sektion=8
source: http://www.cyberciti.biz/faq/freebsd-solaris-unix-linux-dump-exclude-directories-files/

-0    Backup level. '0' for full backup. (remember the -'h 0' option)
-1    Backup level. '1' for full backup.
-L    Tells dump it is backing up a live system
-h 0  Tells dump to honor the 'd' tag on full backups.
-v    Verbose the backup job
-u    Update the backup file
-f    Write dump data to a file

Get an overview of the system:

root@mailcleaner:/# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/vda1             7.7G  1.4G  6.0G  19% /
tmpfs                 501M     0  501M   0% /lib/init/rw
udev                  494M  494M     0 100% /dev
tmpfs                 501M     0  501M   0% /dev/shm
/dev/vda3             235G  162G   62G  73% /var
tmpfs                 501M  192K  500M   1% /var/mailcleaner/spool/tmp

To dump a live system
In order to dump a live system, we need to use the -L option. We also need to create a directory named .snap in the root of the file system to be dumped; its owner should be ‘root’, its group should be ‘operator’, and its mode should be ´0770.
# cd / && mkdir .snap
# chown root .snap
# chow :operator .snap
# chmod 777 .snap

Now, to dump full ‘/’ file system to a file named ‘mailcleaner.dump’ in folder ‘/var/min-backups/’, enter:

Working Live full backup

# /sbin/dump -h 0 -L -0 -f /var/min-backups/mailcleaner-dev.dump /dev/vda1
  DUMP: Date of this level 0 dump: Mon Feb 10 10:37:34 2014
  DUMP: Dumping /dev/vda1 (/) to /var/min-backups/mailcleaner-dev.dump
  DUMP: Label: -0
  DUMP: Writing 10 Kilobyte records
  DUMP: mapping (Pass I) [regular files]
  DUMP: mapping (Pass II) [directories]
  DUMP: estimated 1167431 blocks.
  DUMP: Volume 1 started with block 1 at: Mon Feb 10 10:37:34 2014
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: Closing /var/min-backups/mailcleaner-dev.dump
  DUMP: Volume 1 completed at: Mon Feb 10 10:38:15 2014
  DUMP: Volume 1 1162490 blocks (1135.24MB)
  DUMP: Volume 1 took 0:00:41
  DUMP: Volume 1 transfer rate: 28353 kB/s
  DUMP: 1162490 blocks (1135.24MB) on 1 volume(s)
  DUMP: finished in 40 seconds, throughput 29062 kBytes/sec
  DUMP: Date of this level 0 dump: Mon Feb 10 10:37:34 2014
  DUMP: Date this dump completed:  Mon Feb 10 10:38:15 2014
  DUMP: Average transfer rate: 28353 kB/s

Incremental backup (no actual backup is done in this example, as the system hasn’t changed since full backup)

# /sbin/dump -1uf /var/min-backups/mailcleaner-dev.dump /dev/vda1
  DUMP: Date of this level 1 dump: Mon Feb 10 10:39:25 2014
  DUMP: Date of last level 0 dump: Mon Feb 10 09:41:14 2014
  DUMP: Dumping /dev/vda1 (/) to /var/min-backups/mailcleaner-dev.dump
  DUMP: Label: none
  DUMP: Writing 10 Kilobyte records
  DUMP: mapping (Pass I) [regular files]
  DUMP: mapping (Pass II) [directories]
  DUMP: estimated 2278 blocks.
  DUMP: Volume 1 started with block 1 at: Mon Feb 10 10:39:26 2014
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: Closing /var/min-backups/mailcleaner-dev.dump
  DUMP: Volume 1 completed at: Mon Feb 10 10:39:27 2014
  DUMP: Volume 1 2200 blocks (2.15MB)
  DUMP: Volume 1 took 0:00:01
  DUMP: Volume 1 transfer rate: 2200 kB/s
  DUMP: 2200 blocks (2.15MB) on 1 volume(s)
  DUMP: finished in 1 seconds, throughput 2200 kBytes/sec
  DUMP: Date of this level 1 dump: Mon Feb 10 10:39:25 2014
  DUMP: Date this dump completed:  Mon Feb 10 10:39:27 2014
  DUMP: Average transfer rate: 2200 kB/s
  DUMP: DUMP IS DONE
Posted in Linux, System Utils

Leave a Reply