DAR (Disk ARchive) is a command-line backup tool, that uses compression, makes differential or full backups, which can be split over several files or disks. Dar saves all *NIX inode types, hard links, as well as Extended Attributes. And many other features...
Below are the steps on what was done to get a full archive of an external production server and restore it to a local test machine. The process can also be used for recovering from hard-disk failures.
Installation:
Download and Install:
$ ./configure $ make $ su - # make install-strip
Archive:
Do a full backup of the production server via:
# cp `which dar_static` /path/to/archive # dar -c /path/to/archive/full_server_backup -s 680M -z \ -R / -P dev/pts -P proc -P path/to/archive -P "home/virtual/site*" \ -D -m 256 -Z "*.gz" -Z "*.bz2" -Z "*.zip"
-
-c -- creates a backup with the basename of "full_server_backup"
-s -- size of slice (680M so the slices fit in CDs)
-z -- compress slices using gzip alogrithm (default compression level of 6)
-R -- backup path
-P -- exclude path
-D -- store excluded path as empty directories
-m -- minimum file size for compression
-Z -- exclude files from compression
Restore:
Use knoppix to boot via CD to prepare, partition and create the filesystems for restoration.
-
Preparation
Partition the hard-disk as needed:
# fdisk /dev/hda1 ( 100MB for boot) # fdisk /dev/hda2 ( 256MB for swap ) # fdisk /dev/hda3 ( rest for the system )
Here is the final result:
Disk /dev/hda: 240 heads, 63 sectors, 776 cylinders Units = cylinders of 15120 * 512 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 14 105808+ 83 Linux /dev/hda2 15 48 257040 82 Linux swap /dev/hda3 49 776 5503680 83 Linux
Inform the kernel of the new partitions:
# partprobe /dev/hda1 /dev/hda2 /dev/hda3
# mke2fs -j /dev/hda1 ( ext3 filesystem ) # mkswap -c /dev/hda2 ( swap ) # mke2fs -j /dev/hda3 ( ext3 filesystem )Activate Swap
# swapon /dev/hda2Mount
# mount -t vfat /dev/sda1 /mnt/sda1 ( external usb storage drive ) # mount -t ext3 /dev/hda3 /mnt/hda3 # mkdir /mnt/hda3/boot # mount -t ext3 /dev/hda1 /mnt/hda3/bootRestore
# cp /mnt/sda1/dar_static /mnt/hda3/ # /mnt/hda3/dar_static -x /mnt/sda1/path/to/full_server_backup -R /mnt/hda3 # rm /mnt/hda3/dar_staticLilo Check
Once the archive is restored, launch lilo to boot properly.
# chroot /mnt/hda3 # lilo -v -v # exitReboot
# shutdown -r now
Remote Restore over SSH using DAR
On the localhost where the remote backup is to be restored:
Generate a ssh passwordless login key.
Note: Press enter when prompted for password.
Copy the "id_dsa.pub" to remote backup server as "authorized_keys2".Create the named pipes "todar" and "toslave". Run the dar_slave on remote and dar_static on local:
Note: Leaving out the file/folder to restore path, will restore everything.
Remote Backup using DAR over SSH
DAR can output its archive to stdout instead of a given file. To activate it, use "-" as basename.
Extended Attributes Namespace error
Use the -U and -u option to not consider user and system namespaces.
libattr.a error when doing make
Note: when installing dar on RHEL3 and Fedora Core 3, I had to symlink as below: