bareos-fuse: Virtual File System for Bareos

bareos-fuse (bareosfs) connects to the Bareos Director and presents backup information in a virtual file system. As a result, users can access information about clients, backup jobs, volumes and pools on the command line or via the graphical file manager.

Accessing Bareos information via the file system instead of the WebUI or the bconsole is possible thanks to bareos-fuse. FUSE (Filesystem in User Space) is a kernel module which allows file system drivers to be moved from kernel mode to user mode. FUSE is used, for example, to mount remote computers via SSH, cloud storage or cluster file systems. Bareos makes use of this technology to mount a virtual file system and display information about backup jobs, volumes and more.

With bareos-fuse you can mount a virtual file system that provides information about Bareos.

This article gives an introduction to the Python module bareos-fuse. Although it is maintained in the Bareos GitHub repository, it isn’t an official part of our Open Source backup software. Instead, bareos-fuse is a standalone project for which the Bareos developers do not provide official support. If you have any further questions, please use our mailing list bareos-users.

pip install bareos-fuse

You can install bareos-fuse via the Python Package Index (PyPI):

The Python module additionally requires the FUSE development files, which you can add via your distribution’s package manager.

Mounting bareosfs

An overview of the available bareos-fuse options is provided by the following command: --help

To mount the bareosfs virtual file system to /mnt, enter this shell command on the Bareos Director: -o address=localhost,password=secret /mnt

For your first few attempts, it’s a good idea to start the tool in the foreground and enable the debugging mode. You can also specify a log file: -f -d -o address=localhost,password=secret,logfile=/var/log/bareosfs.log /mnt

If you later run into trouble when trying to unmount it, feel free to terminate the program with killall

Mounting does not necessarily require root privileges; on most distributions there is a corresponding group which allows users to handle FUSE and thus enables them to mount such file systems. By the way, the password is the same as the one in bconsole.conf for accessing the Bareos Console.

Note: It’s possible to set up a separate user account for mounting bareosfs. Of course, you can also define a separate password for this account:

echo "configure add console name=bareosfs password=secret profile=operator" | bconsole

Please adjust the mount command accordingly: -f -d -o address=localhost,name=bareosfs,password=secret,
logfile=/var/log/bareosfs.log /mnt

Display Informationen about Jobs and Volumes

Next, information about all clients, backup jobs, pools, and volumes is available under the /mnt/ mount point:

# ls -la /mnt/
drwxr-xr-x   38 root root 4096 Jan  1  1970 clients/
drwxr-xr-x    2 root root 4096 Jan  1  1970 jobs/
drwxr-xr-x    2 root root 4096 Jan  1  1970 pools/
drwxr-xr-x 2516 root root 4096 Jan  1  1970 volumes/

# ls -la /mnt/jobs/all/
drwxr-xr-x  5 root root 4096 Apr 23 22:12 jobid=128_level=F_status=T
drwxr-xr-x  5 root root 4096 Apr 23 22:12 jobid=129_level=F_status=T

In the /mnt/jobs directory you will find several subdirectories:

  • jobs/job=JOBNAME
    one subdirectory for each job name defined in the Director; all completed jobs are located here
  • jobs/all
    a list of all backup jobs
  • jobs/each_jobname_last_run
    the last job for each job name; this indicates whether the last run was successful or not
  • jobs/running
    list of jobs currently running

The volumes are also mounted under /mnt/ and can therefore be inspected with ls:

# ls -la /mnt/volumes/
drwxr-xr-x  5 root root       4096 Jan  1  1970 Full-0001
-r--r-----  1 root root 1073693339 Sep 18 09:00 Full-0001=Full
drwxr-xr-x  5 root root       4096 Jan  1  1970 Full-0002
-r--r-----  1 root root 1073678209 Sep 18 15:00 Full-0002=Full
drwxr-xr-x  5 root root       4096 Jan  1  1970 Full-0003
-r--r-----  1 root root 1073685404 Sep 18 18:00 Full-0003=Full
drwxr-xr-x  5 root root       4096 Jan  1  1970 Full-0010
-rw-rw----  1 root root  732319090 Sep 22 15:00 Full-0010=Append

In addition to the file name and size, you can also see the volume status after the =, for example, Full, Append, Used, etc. If you list the contents of a volume directory, you will see the status information and a subdirectory with the jobs as well as an info.txt file with internal information. You can, however, take a closer look at the jobs elsewhere in bareosfs.

List the Content of Backup Jobs

To view the content of a backup job on the command line, you can simply use the ls command and enter the path to the file daemon (/mnt/clients/…), followed by backups and the job directory:

# ls -la /mnt/clients/client1-fd/backups/jobid\=887_level\=F_status\=T/
total 13
drwxr-xr-x  5 root root    4096 Jul  1 07:04 ./
drwxr-xr-x 22 root root    4096 Jan  1  1970 ../
drwxr-xr-x  6 root root       0 Jan  1  1970 data/
-r--r--r--  1 root root     661 Jan  1  1970 info.txt
-r--r--r--  1 root root    4070 Jan  1  1970 job.log

The directory names consist of the job ID, the level (full, incremental, etc.) and the status (for example: T = completed successfully, W = terminated with warnings, etc.).

Restore Files

Restoring files and directories from a backup job is also supported on the command line thanks to bareos-fuse. Note that you must mount the file system with the two mount parameters -o restoreclient and -o restorejob for this to succeed.

To prevent a normal read access from accidentally triggering a restore job, bareosfs uses extended attributes. In addition to the “normal” attributes of a file, such as owner or permissions, Linux knows the so-called extended attributes. Each of these attributes has a name and a value. To define extended attributes, the tool getfattr is used, for viewing setfattr.

Let’s take a look at the extended attributes first:

# cd /mnt/clients/client1-fd/backups/jobid\=887_level\=F_status\=T/data/
# getfattr -d .
user.bareos.do_options="mark | restore"

To restore data on the shell, it is sufficient to set the extended attribute for a file or directory to the value restore:

# setfattr -n -v restore .
# getfattr -d ."restore"
user.bareos.do_options="mark | restore"

It is also possible to restore individual files from such a backup. In that case, set the restore value for individual files, for example, like this:

# ls
file1   file2   dir/   dir/
# setfattr -n -v restore file1
# getfattr -d file1
file: file1"restore"
user.bareos.do_options="mark | restore"
# cat file1
Hello. This is the content of file1.

As soon as the user.bareos.restored attribute changes to yes, the file is available for read access at this location. If you want to know where the restored file is actually located, look at the user.bareos.restorepath attribute. (For normal use, however, this is irrelevant, since the file is made directly available via bareosfs.)

Virtual File System as an Alternative

Thanks to bareos-fuse, it’s possible to access the backup information directly via a virtual file system using command line tools such as find, grep, or awk. The graphical file managers also provide a good overview of the backup system. On top of that, it can be very interesting to look at the size of your backups with a program like QDirStat. Keep in mind that every operation involves a query to the Bareos Director. So, if you use a program which scans all subdirectories, it can generate some extra load.

Do you have any questions or suggestions about this article? Then please feel free to leave a comment. You can also discuss this with other Bareos users on our mailing list diskutieren.

Kommentar verfassen

Your email address is not required. Required fields are marked with *.

Nach oben scrollen