Gentoo Wiki




Baras is a file backup tool written in perl. Baras is suitable for backing up single computers to disk, tape, or anything that can be mounted on the computer being backed up, including a network file system on a backup server. Baras is not as powerful as backup tools such as Amanda or Bacula that are intended for enterprise (multi-computer) use, but it is easier to install, configure, and use for simple backups. Unfortunately, documentation for Baras is very limited; hence this HOWTO.

Baras is derived from SaraB, a shell script front end for DAR (Disk Archiver). Baras is more powerful than SaraB and as of baras-099a appears bug-free, whereas SaraB 0.2.4 has a simple-to-fix bug that prevents execution as installed. For someone who wants to use SaraB, note that, as distributed, several SaraB 0.2.4 configuration files, including sarab.conf and sarab.dcf, use DOS style line termination, 0d0a. Linux uses Unix style line termination, 0a. The extra 0d causes SaraB to emit error messages and fail. To fix the bug examine the files using hexdump and run misformed files through the utility dos2unix. But back to Baras.

Installing Baras

To install and run Baras you need to be root. Baras needs perl (dev-lang/perl), dar (app-backup/dar), parchive (app-arch/par2cmdline), and cron (sys-process/vixie-cron or another cron of your choice), so emerge these before installing Baras. If a mail transfer agent (MTA) such as postfix is installed, Baras can send email to report its actions.

At this writing the Baras package is not in portage, but it is just a Perl script and a few configuration files, so manual installation is not difficult. To install Baras su to root and create the directory /var/adm/. Log on to, search for baras, and download baras-099a.tar.bz2 to /var/adm. Execute tar xjf baras-0999.tar.bz2 to expand the files. The included Baras README file gives adequate instructions for installing Baras. Some of the directories and links may seem awkward, but follow the instructions exactly until you have things working. Then you can consider moving things to other directories.

Baras Configuration Files

The Baras package includes three configuration files: baras.conf, baras.dcf, and rotation.schedule. this section discusses these in order.

Configuration File baras.conf

baras.conf is sourced by, the actual Baras program; it contains options you can customize . If you installed Baras as in the README, most of the defaults in baras.conf should be OK. Until you master Baras, use the default backup destination, /mnt/backup. This could either be a mounted device or just a directory used for testing purposes. To simplify things, use the default of no email (set EMAIL="no"). Baras will create a log file in /var/log.

Set BARAS_VERBOSE="yes" for initial debugging purposes. Keep the default settings in the section # PAR2 usage. PAR2 refers to Parchive, specifically the par2cmdline package. Parchive creates redundant files that help recover from media errors in the backup media; it will be discussed later. Set DAR_MGR=yes, also discussed later. If you are running Gentoo, point to the correct paths by changing the relevant options: DAR_BINARY="/usr/bin/dar", DAR_MGR_BINARY="/usr/bin/dar_manager", and DAR_STATIC="/usr/bin/dar_static".

Configuration File baras.dcf

baras.dcf is fed directly as a batch file to dar, so the dar documentation helps to understand this file. Keep most of the defaults initially. dar uses relative path names, so you have to specify the root of the filesystem to be backed up. The default, --fs-root /, sets root to /, but you could, for example, set it to /home. Initially stick with the default of /. In the section [list of paths] you must specify directories to back up, or dar will do nothing. A simple initial test entry could be -g etc. This will back up the /etc directory and subdirectories, assuming you kept the default --fs-root /. Initially you can probably keep all the other defaults.

Configuration File rotation.schedule

One of the strengths of Baras is that it easily implements a backup strategy to manage a backup schedule and an orderly set of backups. The simplest backup strategy would be full backups of the selected directories (or whole filesystem) on a constant interval. But there are many other backup strategies with ardent supporters for them. The Wikipedia article on "backup" provides a good introduction to these.

The supplied file, rotation.schedule, uses a two-week schedule of weekly full backups and daily incremental backups. This means that you will always be able to restore the last two weeks of your backed-up directories. More complicated strategies allow restoring from further into the past while limiting the number of retained backups. The SaraB package contains several examples of rotation.schedule files that are compatible with Baras. Download Sarab 0.2.4 to examine these. (At this writing SaraB is masked for the x86 architecture, so you might as well download it from For example, a four-tape Towers-of-Hanoi incremental backup strategy using weekly full backups and daily incremental backups goes back 99 days (but not every day) using only four full backups and 24 incremental backups.

If you use the rotation.schedule supplied with Baras, be sure to edit it so the first backup in the list corresponds to today. For example, if today is Thursday, cut the top four lines from the list and paste them on the bottom. Then the list will start with the line "4_Thursday Week1". Baras rotates the list each time it does a backup.

Testing Baras

Initial Baras Run

The Baras README file shows how to do an initial test after setting up the configuration files: just run /var/adm/baras/ If you have set BARAS_VERBOSE="yes" Baras should produce output on the terminal similar to:

Code: Output from
Reading settings from: /etc/baras/baras.conf
Using Dar configuration file named: /etc/baras//baras.dcf
Using rotation.schedule named: /etc/baras//rotation.schedule
Virtual-tapes are located under: /mnt/backup/
Log file located at: /var/log/baras.log

Read from rotation: current 'tape' is 'A', reference 'tape' is ''
Creating a full backup on the virtual tape named A
Creating backup with DAR... '/usr/bin/dar -Q --batch /etc/baras/baras.dcf -c /mnt/backup/.baras_temp_workdir/08-03-2008_1154 --noconf  > /tmp/tmp.6649'
 19066 inode(s) saved
 with 0 hard link(s) recorded
 0 inode(s) changed at the moment of the backup
 0 inode(s) not saved (no inode/file change)
 0 inode(s) failed to save (filesystem error)
 89 inode(s) ignored (excluded by filters)
 0 inode(s) recorded as deleted from reference backup
 Total number of inode considered: 19155
 EA saved for 0 inode(s)

Testing the archive for errors...
/usr/bin/dar -t /mnt/backup/.baras_temp_workdir/08-03-2008_1154 --noconf
 19066 inode(s) treated
 0 inode(s) with error
 0 inode(s) ignored (excluded by filters)
 Total number of inode considered: 19066

Generating PAR2 hashes...
Command: /usr/bin/par2 c -r5 backup.par2 *
Copying the static dar executable...
Moving files to the correct virtual-tape...

Updating dar_manager database '/mnt/backup/dar_manager/dave'...
dar path    :
dar options :

archive #   |    path      |    basename
        1       /mnt/backup/test        08-01-2008_1630
        2       /mnt/backup/Csaturday   08-02-2008_1112
        3       /mnt/backup/A   08-03-2008_1154
  archive #   |  most recent/total data |  most recent/total EA
        1 7/18920                        0/0
        2 204/19089                      0/0
        3 19066/19066                    0/0

Final archive sizes:
*.dar   : 16435498KB
*.par2  : 828243KB
The backup process took 5 hour(s), 57 minute(s), and 9 second(s).

Most of this listing is fairly obvious. First reports which files are used. The line starting "Creating backup with DAR" gives the exact command used to invoke dar. If you need to debug the dar command line, start with this. Note that baras.dcf is a batch file for dar. The testing phase compares the CRC (cyclic redundancy check) of the files on the backup to that stored as the files were being written. man dar gives more information about this. The PAR2 phase creates par2 files with sufficient redundancy to recover from fairly large media failure. More about this later.

Examining the Backup Directory

If you used the default settings, your backup will be in /mnt/backup, in a subdirectory whose name is the same as that in the rotation schedule. For the example above it would be /mnt/backup/4_Thursday Week1. In that subdirectory will be several files with names ending in .dar. These are your backup. There will be several other files with names ending in .par. These are the files produced by the par2 program. The file dar_static is a statically linked binary version of dar that you could use to restore files in case your system suffers major damage.

Managing the Backup Set

The program dar_manager, included in the dar package, is very helpful for managing the backup sets (and for restoring a few files, see below.) If you used the default setting in baras.conf, the dar_manager database file is /mnt/backup/dar_manager/[hostname]; where [hostname] is your hostname, as learned by from the command uname -n.

To explore dar_manager, start it interactively, using the -i option. The -B option identifies the database. (In the following command line substitute [hostname] with the actual name of your database file.)
dar_manager -B /mnt/backup/dar_manager/[hostname] -i
The output of this command gives a menu of choices. (Note that in this example [hostname] was Dave.)

Code: Output from dar_manager
Uncompressing and loading database to memory...

         Dar Manager Database used [Saved] : /mnt/backup/dar_manager/dave
         Pause each 25 line of output

 l : list database contents      A : Add an archive
 u : list archive contents       D : Remove an archive
 f : give file localization      m : modify archive order
 p : modify path of archives     b : modify basename of archives
 d : path to dar                 o : options to dar
 w : write changes to file       s : database statistics
 a : Save as                     n : pause each 'n' line (zero for no pause)

 q : quit


man dar_manager describes each of these choices. Note that actual file restoration can't be done via the menu. It must be done from the command line, as discussed shortly. Useful choices to try are l, u, f, and n. l shows which backups are in the database. u lists the files in a backup. f finds in the database a known file and tells you which backups contain it and what different versions exist. n changes the number of lines displayed (e.g. from invoking f) For example, choosing n and then 100 at the next prompt will cause display of 100 lines before pausing.

Restoring Files

"The backup is nothing; restoring is everything" is attributed to Dwight D. Eisenhower, except he said "the plan" and "planning" instead of "the backup" and "restoring." Original or not, the quote emphasizes that the whole purpose of backing up is to be able to restore. Baras itself is useless for restoring, but if you set DAR_MGR=yes in baras.conf, Baras will engage dar_manager to help in restoring.

Restoring a few files

dar_manager is very helpful for for restoring a few files, but it is inappropriate for restoring a whole filesystem. If you used the default setting, the dar_manager database is in the file /mnt/backup/dar_manager/[hostname], where [hostname] is the name created by Baras by running the command uname -n.

Here is a simple way to restore a file: Suppose you want to restore the file /home/nelson/Mailbox. Change directory to /mnt/backup/dar_manager and execute the following command:

dar_manager -B [hostname] -r home/nelson/Mailbox

The option -B says which database to use, so replace [hostname] with the actual name of your database. The option -r says to restore the file that follows. (Remember that paths are relative, so don't include the initial /.) Where is the file restored to? In fact, it is placed in a subdirectory of {{Filename|dar_manager}, specifically in /mnt/backup/dar_manager/home/nelson. You will want to move the file, but this simple example shows exactly what the command does without causing damage, such as overwriting a file.

To restore the file in one step to its original location you need to tell dar what to use for root and then restore the file. Execute these two commands:

dar_manager -B dave -o -R /
dar_manager -B dave -r home/nelson/Mailbox

In the first command the option -o says to pass the rest of the line directly to dar, and then the option -R / sets root to /, similar to the option --fs-root / in baras.dcf. The second command is exactly the same as the previous restore, except this time dar puts the file in its original place.

Restoring a whole backup

To restore a whole backup use the dar command directly. (One user tried to use dar_manager to restore a filesystem after it had been damaged. Unfortunately the last incremental backup was taken after the damage occurred, so many files were missing. dar_manager restored a full backup and then happily deleted the files that weren't present in the last incremental backup. Not exactly the intended result!)

The dar documentation explains how to do use dar to restore a backup, so this HOWTO gives just a short summary. (The dar documentation is in /usr/share/doc/dar-2.3.7-r1/html. Tutorial.html is especially useful.)

Suppose you want to restore to a new disk drive. Create a filesystem on the disk and mount it at /disk. (For practice you could just create a directory /disk.) Change directory to /mnt/backup/[yourbackup], where [yourbackup] is the name of the backup subdirectory you want to restore, presumably a full backup. Note the names of the backup files, those ending in .dar. They should have names like "08-03-2008_1154.n.dar", where the first part is a date and time, and n ranges from 1 to the last file. Each of these files is called a slice; all the slices taken together form the whole backup.

If you left the parameter COPY_DAR="yes" unchanged in baras.conf, dar_static should also be in this subdirectory. If so, while in this directory execute the following command:

./dar_static -x ./[backupname] -R /disk

In this example [backupname] is 08-03-2008_1154, and in general [backupname] is the date and time part of the name of the backup, i.e., before the first period. This command will restore the backup to /disk, keeping all the relative paths. If you don't have dar_static in this directory, use dar instead in the above command.

What Are These PAR2 Files?

Baras will use the package Parchive to create redundant files (ending in .par2) that allow recovery of the backup from significant media errors, if you included PAR_ARCHIVE="two" in baras.conf. Each backup directory should include the file backup.par2 and several other files ending in .par2. Recovery is perhaps more important for backups on tape, because of the inevitable degradation of tape media, but even disks can develop hard errors.

If you need to use parchive, I suggest looking at the documentation in /usr/share/doc/par2cmdline-0.4-r2/README.bz2. (A good way to read a bz2 file is the command bzless README.bz2.) To get you started, here are a couple of the most useful commands. First change directory to the backup directory /mnt/backup/[backupdirectory]. To verify that your backup is not corrupted, execute this command:

par2 verify backup.par2

In this command the file backup.par2 points to your backup files and launches a lengthy verification process that uses the other .par2 viles to verify that none of the .dar files are corrupted.

To repair a damaged backup execute

par2 repair backup.par2

This will verify whether the backup is damaged, and if so, try to repair it.

Using Baras in Production Mode

If the test of Baras went well, it is now time to set it up for automatic periodic backups using cron. First, turn off the verbose reporting. The defaut in baras.conf is BARAS_VERBOSE="no", so you can just comment out this option by changing it back to #BARAS_VERBOSE="yes".

Next set up the cron job. The README file in the Baras package shows how to do this; a summary is presented here. The default rotation.schedule makes daily backups, so make sure that the top entry in rotation.schedule refers to tomorrow's day of the week (unless you are doing this between midnight and 3 am) because cron runs daily jobs at about 3 am. To set up the cron job, as root enter the following command:

ln -s /var/adm/baras/ /etc/cron.daily/zzz_baras

Check that the cron daemon is running by executing rc-update show. If it isn't, set it to start automatically. If you don't know how to do this, execute rc-update for a brief help.

After cron runs, examine /var/log/baras to verify that it ran correctly. Also check /mnt/backup to be sure your backup is there.

Other Baras Features

Baras offers several features that have not been covered. One of them is email notification of the backup. To use this you must have a mail transfer agent installed and set EMAIL="yes" in baras.conf.

Another feature is setting the slice size for the backup. The default in baras.conf is --slice 650M; this divides the backup into roughly 650 Megabyte pieces. Larger or smaller slices are also possible.

Another feature lets you adjust the size and redundancy of the parchive files by un-commenting and changing the default option #PAR2_PERCENTAGE=5 in baras.conf. Larger numbers create more redundancy and the ability to recover from more serious media errors. For example, if your backup media is quite error prone, you might try PAR2_PERCENTAGE=10.

The configuration files baras.conf and baras.dcf are reasonably well commented and contain other options that can be adjusted to your needs. You can also examine to see how it works. Even if you don't know perl, you can understand most of what the program does. Happy backups! And even happier restoring!

Retrieved from ""

Last modified: Fri, 05 Sep 2008 01:12:00 +0000 Hits: 714