DAR (Disk ARchive) is a command-line archiving tool,  is very similar to tar in the number of options it has, such as create, list, extract etc..  in the meantime, it offers some other options that tar doesn't have.


For example, here listed some of featuers that tar doesn't support, you may interested in

remove files from archived file.
DIFFERENTIAL BACKUP
SLICES
DIRECTORY TREE SNAPSHOT
DIRECT ACCESS
SPARSE FILES

Anyway, let's start with some examples:

Create an archive file


$dar -c backup -g ./test1
Furtive read mode has been disabled as dar is not run as root
 --------------------------------------------
 17 inode(s) saved
   including 0 hard link(s) treated
 0 inode(s) changed at the moment of the backup and could not be saved properly
 0 byte(s) have been wasted in the archive to resave changing files
 0 inode(s) not saved (no inode/file change)
 0 inode(s) failed to be saved (filesystem error)
 44 inode(s) ignored (excluded by filters)
 0 inode(s) recorded as deleted from reference backup
 --------------------------------------------
 Total number of inode(s) considered: 61
 --------------------------------------------
 EA saved for 0 inode(s)
 --------------------------------------------
$ls -l *backup*
-rw-r--r-- 1 atlas001 atlas 260827775 Dec 27 23:57 backup.1.dar

If you want to add more files or directories, add -g to each directories, but for multiple files, you have to add -g option to each file if you are backing up individual files.

As you can see that DAR added a number and extension to archive file. The purpose of the extension is clear, it helps to know visually that the file is a DAR backup. The number is called a slice, and this is related to DAR's built-in feature of splitting a backup over several media.

List archive file


$dar -l backup
[data ][ EA  ][compr][S]| permission | user  | group | size  |          date                 |    filename
------------------------+------------+-------+-------+-------+-------------------------------+-
[Saved]       [-----][ ]  drwxr-xr-x   test    test    0    Fri Dec 27 22:24:02 2013    test1
...

Restore from archive file

$mkdir test3;cd test3
$dar -x ../backup
File ownership will not be restored as dar is not run as root. to avoid this message use -O option [return = YES | Esc = NO]
Continuing...

 --------------------------------------------
 17 inode(s) restored
    including 0 hard link(s)
 0 inode(s) not restored (not saved in archive)
 0 inode(s) not restored (overwriting policy decision)
 0 inode(s) ignored (excluded by filters)
 0 inode(s) failed to restore (filesystem error)
 0 inode(s) deleted
 --------------------------------------------
 Total number of inode(s) considered: 17
 --------------------------------------------
 EA restored for 0 inode(s)
 --------------------------------------------

Extract single file or files from archive file

Extract single file or files from archive file

$mkdir test3;cd test3
$dar -x ../backup -g test1/0000000100000918000000EF  -O

 --------------------------------------------
 2 inode(s) restored

In the example above, one inode is for the directory.
Also, in the case above, -O without flag acts as if the "ignore-owner" flag was set

Extract more files

$dar -x ../backup -g test1/0000000100000918000000EF -g <other file> -O

Full backup, with more options

#dar -R /home -m 4096 -y -s 600M -D -c `date -I`_data -Z "*.gz" -Z "*.bz2" -Z "*.zip" -Z "*.png" -Z "*.lrz*" -Z "*.pigz" -Z "*.7z"


This is a full backup command to backup whole /home filesystem, here is the description of used options


       -m, --mincompr <number>
files  which size is below this value will not be compressed. If -m is not specified it is equivalent to giving -m 100 as argument. If you want to compress all file whatever their size is you thus need to type -m 0 on the command line.  The  same number extensions as those used with -s or -S are available here, if you want to specify the size in kilobyte, megabyte, gigabyte etc.
In example above, I use 4k, which is the smallest space allocation unit on most of Linux system.

       -s, --slice <number>
Size of the slices in bytes. If the number is appended by k (or K), M, G, T, P E, Z or Y the size is in kilobytes, megabytes,  gigabytes, terabytes, petabytes, exabytes, zettabytes or yottabytes respectively. Example: "20M" means 20 megabytes, by default, it is the same as giving 20971520 as argument (see also -aSI and -abinary  options).  If -s  is  not  present the backup will be written to a single slice whatever the size of the backup may be

       -D, --empty-dir
At  backup time, when excluding directories either explicitly using -P or -] options, or implicitly by giving a -g or -[ options (a directory is excluded if it does not match mask given with -g options or -[ options) dar does not store  anything  about  these.  But  with  -D option, dar stores them as empty directories. This can be useful, if    excluding a mount point (like /proc or /dev/pts). At restoration time, dar will then  recreate  these  directories (if necessary). This option has no meaning with -C and is ignored in that case. Independently of that, -D can also be used at restoration time, but it activates a slightly different feature (see restoration options below).

       -z[[algo:]level], --compression[=[algo][:][level]]
add compression within slices using gzip, bzip2 or lzo algorithm (if -z is not specified, no compression  is  per formed).  The  compression  level (an integer from 1 to 9) is optional, and is 9 by default, which is max compression/slow processing. At the opposite, 1 means less compression and faster  processing.  "Algo"  is  optional,  it specifies the compression algorithm to use and can take the following values "gzip" "bzip2" or "lzo". "gzip" algorithm is used by default (for historical reasons see --gzip below). If both algorithm and compression are given, a  ’:’  must  be  placed  between  them.  Valid  usage  of -z option is for example: -z, -z9, -zlzo, -zgzip, -zbzip2, -zlzo:6, -zbzip2:2, -zgzip:1 and so on. Usage for long option is the same: --compression, --compression=9,  --compression=lzo,  --compression=gzip,  --compression=bzip2,  --compression=lzo:6,  --compression=bzip2:2,  --compression=gzip:1 and so on.

      -Z, --exclude-compression <mask>
Filenames covered by this mask are not compressed. It is only useful with -z option. By default, all file are compressed  (if  compression is used). This option can be used several times, in that case a file that matches one of the -Z mask will not be compressed. Argument given to -Z must not be include any path, just the filename  (eventually/probably using wildcards).

File list

-rw-r--r-- 1 atlas001 atlas 600M Dec 29 02:13 2013-12-29_data.10.dar
-rw-r--r-- 1 atlas001 atlas 600M Dec 29 02:13 2013-12-29_data.11.dar
-rw-r--r-- 1 atlas001 atlas 205M Dec 29 02:14 2013-12-29_data.12.dar
-rw-r--r-- 1 atlas001 atlas 600M Dec 29 01:59 2013-12-29_data.1.dar
-rw-r--r-- 1 atlas001 atlas 600M Dec 29 01:59 2013-12-29_data.2.dar
-rw-r--r-- 1 atlas001 atlas 600M Dec 29 02:00 2013-12-29_data.3.dar
...

Differential backups with DAR

This is amazing feature dar has. Here is the example for the first incremental backup right after full backup

#dar -R /home -m 4096 -z gzip -s 600M -D -c `date -I`_incremental -Z "*.gz" -Z "*.bz2" -Z "*.zip" -Z "*.png" -Z "*.lrz*" -Z "*.pigz" -Z "*.7z" -A 2013-12-29_data

 --------------------------------------------
 0 inode(s) saved
   including 0 hard link(s) treated
 0 inode(s) changed at the moment of the backup and could not be saved properly
 0 byte(s) have been wasted in the archive to resave changing files
 99 inode(s) not saved (no inode/file change)
 0 inode(s) failed to be saved (filesystem error)
 13 inode(s) ignored (excluded by filters)
 0 inode(s) recorded as deleted from reference backup
 --------------------------------------------
 Total number of inode(s) considered: 112
 --------------------------------------------
 EA saved for 0 inode(s)
 --------------------------------------------

In the case above, there was no file change since the full backup.

Now, I deleted a file, and created a new file, here is incremental backup again.

Here is the command and output looks like

#dar -R /home -m 4096 -z gzip -s 600M -D -c `date +%y-%m-%d-%H`_incremental -Z "*.gz" -Z "*.bz2" -Z "*.zip" -Z "*.png" -Z "*.lrz*" -Z "*.pigz" -Z "*.7z"  -A 2013-12-29_incremental
Furtive read mode has been disabled as dar is not run as root
 --------------------------------------------
 2 inode(s) saved
   including 0 hard link(s) treated
 0 inode(s) changed at the moment of the backup and could not be saved properly
 0 byte(s) have been wasted in the archive to resave changing files
 97 inode(s) not saved (no inode/file change)
 0 inode(s) failed to be saved (filesystem error)
 14 inode(s) ignored (excluded by filters)
 1 inode(s) recorded as deleted from reference backup
 --------------------------------------------
 Total number of inode(s) considered: 114
 --------------------------------------------
 EA saved for 0 inode(s)
 --------------------------------------------

Here is the two new differential backup files look like

-rw-r--r-- 1 atlas001 atlas     10479 Dec 29 02:24 13-12-29-02_incremental.1.dar
-rw-r--r-- 1 atlas001 atlas      8254 Dec 29 02:20 2013-12-29_incremental.1.dar

More details about its featuers in its home page
http://dar.linux.free.fr/