Difference between revisions of "Bacula and Bareos"

From Hack Sphere Labs Wiki
Jump to: navigation, search
(Configure On CentOS 6.5)
(Configure On CentOS 6.5)
Line 41: Line 41:
  
 
  mke2fs -t ext4 -O large_file /dev/sdc1
 
  mke2fs -t ext4 -O large_file /dev/sdc1
We also have the change the permission of the actual drive so vchanger has the right access to it.
+
We also have the change the permission of the actual drive so vchanger has the right access to it.
 +
*make sure to change the actual permissions of the drive link https://wiki.zmanda.com/index.php/Changer_problems
 
  chown bareos:bareos /dev/sdc1
 
  chown bareos:bareos /dev/sdc1
 
  chown bareos:bareos /dev/sdc
 
  chown bareos:bareos /dev/sdc
 +
  
 
This will create a new ext4 file system on the partition. Now unplug the drive, wait a few seconds, then plug it back in. After re-attaching the drive, the name of the symlink in /dev/disk/by-uuid pointing to the filesystem partition's device node, (/dev/sdc1 in the example above), will reveal the UUID that can be used in a magazine directive in a vchanger configuration file to assign the removable drive to an autochanger. On many systems, the UUID of the filesystem can also be determined with the blkid command.
 
This will create a new ext4 file system on the partition. Now unplug the drive, wait a few seconds, then plug it back in. After re-attaching the drive, the name of the symlink in /dev/disk/by-uuid pointing to the filesystem partition's device node, (/dev/sdc1 in the example above), will reveal the UUID that can be used in a magazine directive in a vchanger configuration file to assign the removable drive to an autochanger. On many systems, the UUID of the filesystem can also be determined with the blkid command.

Revision as of 13:11, 21 March 2014

CentOS 6.5 Install

yum install mysql-server mysql-devel
service mysqld start
chkconfig mysqld on
mysqladmin -u root password Y0uR3l173P455w0rd


yum  install bareos-database-mysql
yum  install bareos


/usr/lib/bareos/scripts/create_bareos_database -u root -p
/usr/lib/bareos/scripts/make_bareos_tables -u root -p
/usr/lib/bareos/scripts/grant_bareos_privileges -u root -p


service bareos-dir start
service bareos-sd start
service bareos-fd start

Links

Archlinux GUI Admin

yaourt bareos-bat

Configure On CentOS 6.5

Since I use disks I start with installing vchanger

You should also download the tar.gz from the vchanger sourceforge and look in the docs for vchangerHowto.html as it has the best info. I followed it while making this guide.

The link above has a script but it looks like the one on sourceforge (which is referenced in the link) is newer and compiles. Even then, I decided to pull the rpm from pbone

wget ftp5.gwdg.de/pub/opensuse/repositories/home:/pstorz/CentOS_CentOS-6/x86_64/vchanger-0.8.6-10.3.x86_64.rpm
yum install vchanger-0.8.6-10.3.x86_64.rpm
  • I am going to start with one drive so first I am going to format it (create a partition first (cfdisk)):
  • Quote:

Assuming the drive was assigned node /dev/sdc, the partition can now be formatted and labeled using:

mke2fs -t ext4 -O large_file /dev/sdc1

We also have the change the permission of the actual drive so vchanger has the right access to it.

chown bareos:bareos /dev/sdc1
chown bareos:bareos /dev/sdc


This will create a new ext4 file system on the partition. Now unplug the drive, wait a few seconds, then plug it back in. After re-attaching the drive, the name of the symlink in /dev/disk/by-uuid pointing to the filesystem partition's device node, (/dev/sdc1 in the example above), will reveal the UUID that can be used in a magazine directive in a vchanger configuration file to assign the removable drive to an autochanger. On many systems, the UUID of the filesystem can also be determined with the blkid command.

ls -al /dev/disk/by-uuid/

The Bacula Storage Daemon does not usually run as root. Since vchanger will be invoked by the Storage Daemon, and so will run as the same user it does, permissions for the magazine's mounted filesystem must be set to allow write access to the user that the Storage Daemon runs as. This can be done by mounting the new partition somewhere, then using chown and chmod to set the appropriate permissions to allow write access for the user that the Storage Daemon runs as.

mkdir /media/temp
mount /dev/xvdc1 /media/temp
chown bareos:bareos -R /media/temp

Need to get autofs up and running so it mounts the disks and stuff:

yum install autofs
nano /etc/auto.vchanger
  • add
# /etc/auto.vchanger
*          -fstype=auto,rw,sync       :/dev/disk/by-uuid/&
# eof
  • Then:
nano /etc/auto.master
  • add
/mnt/vchanger      /etc/auto.vchanger        --timeout=30
  • then
service autofs restart

ls -al /mnt/vchanger/UUID so

ls -al /mnt/vchanger/3c22af77-4881-4a7f-bcfc-517744c964db

Note: After restarting the autofs daemon, whenever a file or directory with a full path beginning with '/mnt/vchanger' is accessed, the autofs filesystem will search the map defined in the /etc/auto.vchanger file for a key matching the path being accessed. In this case, the only key in /etc/auto.vchanger is the wildcard '*', meaning any path name beginning with '/mnt/vchanger' will match. Autofs then automatically mounts the device mapped to the wildcard key at the path being accessed. The /etc/auto.vchanger map file specifies the device to be mounted as /dev/disk/by-uuid/&. The '&' is substituted for the key value. For example, when a program attempts to access /mnt/vchanger/9667f83c-6150-44c7-b0d4-57564f174b35 (or any files or directories below it), the autofs daemon will look at the auto.vchanger map for the key 9667f83c-6150-44c7-b0d4-57564f174b35 and discover that it should mount /dev/disk/by-uuid/9667f83c-6150-44c7-b0d4-57564f174b35 at /mnt/vchanger/9667f83c-6150-44c7-b0d4-57564f174b35 with mount options '-fstype=auto,rw,sync'. After a period of 30 seconds of no activity, autofs will automatically unmount the device.

Always make sure autofs is working properly before continuing with setting up vchanger. If using the above autofs config files, when you plug in a USB drive with filesystem UUID of, say, 9667f83c-6150-44c7-b0d4-57564f174b35, you should be able to list its contents with the commandS

  • This should create some working directories
mkdir /var/lib/bareos/vchanger
mkdir /var/lib/bareos/vchanger/c0
chown bareos:bareos -R /var/lib/bareos/vchanger
  • Next we have to create our config:
nano /etc/bareos/vchanger.conf
  • Put in:
changer_name = "c0"
work_dir = /var/lib/bareos/c0
logfile = /var/lib/bareos/c0.log
log_level = LOG_ERR
virtual_drives = 1
slots_per_magazine = 69
magazine_bays = 1
automount_dir = /mnt/vchanger

magazine = "UUID:3c22af77-4881-4a7f-bcfc-517744c964db"

vchanger -u bareos -g bareos /etc/bareos/vchanger.conf initmag 1
vchanger -u bareos -g bareos /etc/bareos/vchanger.conf list

Should work, if not check all permissions: working dirs, drives, mountpoints

  • More:
vchanger -u bareos -g bareos /etc/bareos/vchanger.conf listmags
  • Output:
1:c0:1:/mnt/vchanger/3c22af77-4881-4a7f-bcfc-517744c964db
  • Test load and unload
vchanger -u bareos -g bareos /etc/bareos/vchanger.conf load 1 /var/lib/bareos/c0/drive0 0
ls -al /var/lib/bareos/c0/0/
vchanger -u bareos -g bareos /etc/bareos/vchanger.conf unload 1 /var/lib/bareos/c0/drive0 0
  • See what mag is installed in the bay:
cat /var/lib/bareos/c0/bay1


Links