User Tools

Site Tools


removable_disk

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
removable_disk [2009/07/20 18:51]
sathe markup fixes
removable_disk [2010/11/12 20:08] (current)
darrick
Line 2: Line 2:
 ===Josh Fisher=== ===Josh Fisher===
 ==Revision History== ==Revision History==
 +
 +Revision 0.9.1 2009-10-27
 +  * Vchanger is now an open source project hosted at SourceForge at http://​sourceforge.net/​projects/​vchanger/​. The most recent howto is included in the source tarball.
  
 revision 0.9 2009-01-26 revision 0.9 2009-01-26
  
-  * Moved to http://​wiki.backula.org+  * Moved to http://​wiki.bacula.org
  
 Revision 0.8 2008-12-06 Revision 0.8 2008-12-06
Line 23: Line 26:
   * Initial version.   * Initial version.
  
-This document describes how to utilize removable disk drives as backup media for a backup solution using [[http://​www.bacula.org/​|Bacula]] +This document describes how to utilize removable disk drives as backup media for a backup solution using [[http://​www.bacula.org/​|Bacula]].\\  
- +In addition to reading this guide you could check out [[http://​bacula.svn.sourceforge.net/​viewvc/​bacula/​trunk/​bacula/​scripts/​disk-changer.in?​view=markup|"​disk-changer"​ script]] which is part of bacula distribution.
  
 ====1. Introduction==== ====1. Introduction====
Line 88: Line 90:
 The second parameter is the autochanger command to be performed and is either one of the standard Bacula autochanger API commands: The second parameter is the autochanger command to be performed and is either one of the standard Bacula autochanger API commands:
  
-  * load                 Load a "​tape"​ from a magazine "​slot"​ into a "​drive"​. Vchanger creates a symlink with the name passed in parameter 4 (archive_device) pointing to the file mIIsJJJ, where II is the two digit magazine index and JJJ is the slot number passed to Vchanger as parameter 3.+  ​* **load**                 Load a "​tape"​ from a magazine "​slot"​ into a "​drive"​. Vchanger creates a symlink with the name passed in parameter 4 (archive_device) pointing to the file mIIsJJJ, where II is the two digit magazine index and JJJ is the slot number passed to Vchanger as parameter 3.
  
-  * unload ​            ​Unload a "​tape"​ from the "​drive"​ back into the magazine "​slot"​. Vchanger deletes the symlink that was created by a previous load command for the drive.+  ​* **unload**             Unload a "​tape"​ from the "​drive"​ back into the magazine "​slot"​. Vchanger deletes the symlink that was created by a previous load command for the drive.
  
-  * loaded ​            ​Return the "​slot"​ currently loaded into the "​drive"​.+  ​* **loaded**             Return the "​slot"​ currently loaded into the "​drive"​.
  
-  * list                   List the barcodes of the "​tapes"​ in each of the "​slots"​ in this magazine.+  ​* **list**                   List the barcodes of the "​tapes"​ in each of the "​slots"​ in this magazine.
  
-  * slots                Return the number of slots per magazine.+  ​* **slots**                ​Return the number of slots per magazine.
  
 ... or one of the vchanger extended commands: ​ ... or one of the vchanger extended commands: ​
  
-  * purge               ​Delete all volumes in a magazine and re-create them using the bconsole 'label barcodes'​ command. Volumes are deleted from the Bacula catalog using the bconsole '​delete volume'​ command, and the files acting as virtual tapes containing those volumes are deleted from the virtual magazine filesystem.+  ​* **purge**               Delete all volumes in a magazine and re-create them using the bconsole 'label barcodes'​ command. Volumes are deleted from the Bacula catalog using the bconsole '​delete volume'​ command, and the files acting as virtual tapes containing those volumes are deleted from the virtual magazine filesystem.
  
 The third parameter is the slot number to use for the current command. The third parameter is the slot number to use for the current command.
Line 144: Line 146:
 ====6. Preparing USB Disk Drives==== ====6. Preparing USB Disk Drives====
  
-Preparing the USB drives for use with the virtual autochanger is fairly simple. All that is needed is a partition on the drive with a filesystem that has a filesystem label named appropriately for the virtual autochanger it will be used with. Most USB drives come from the factory with a single large FAT32 partition. While that could be used by simply giving it a filesystem label and adjusting the autofs configuration from [[#​using_autofs_to_mount_magazine_partitions|5.2]] above appropriately,​ in this example we will be using a ext3 filesystem on a single partition encompassing the entire disk. The preparation procedure detailed in [[#​partitioning|6.1]] and [[#​formatting_labeling_magazine_partitions|6.2]] below is used to prepare each drive to be used.+Preparing the USB drives for use with the virtual autochanger is fairly simple. All that is needed is a partition on the drive with a filesystem that has a filesystem label named appropriately for the virtual autochanger it will be used with. Most USB drives come from the factory with a single large FAT32 partition. While that could be used by simply giving it a filesystem label and adjusting the autofs configuration from [[#​using_autofs_to_mount_magazine_partitions|section ​5.2]] above appropriately,​ in this example we will be using a ext3 filesystem on a single partition encompassing the entire disk. The preparation procedure detailed in [[#​partitioning|section ​6.1]] and [[#​formatting_labeling_magazine_partitions|section ​6.2]] below is used to prepare each drive to be used.
  
 ===6.1 Partitioning=== ===6.1 Partitioning===
Line 152: Line 154:
 ===6.2 Formatting / Labeling Magazine Partitions=== ===6.2 Formatting / Labeling Magazine Partitions===
  
-Assuming the drive was assigned node /dev/sdc, the partition can now be formatted and labeled using:+Assuming the drive was assigned node /dev/sdX, the partition can now be formatted and labeled using:
  
-  mke2fs -j -T largefile -L "​usbchanger1"​ /dev/sdc1+  mke2fs -j -T largefile -L "​usbchanger1" ​-m 0 /dev/sdX1
  
 This will create a new ext3 filesystem on the partition with filesystem label '​usbchanger1'​. Now unplug the USB drive, wait a few seconds, then plug it back in. A few seconds after plugging it in you should see a symlink /​dev/​disk/​by-label/​usbchanger1 pointing to whatever device node udev decided to assign to the partition. Now try: This will create a new ext3 filesystem on the partition with filesystem label '​usbchanger1'​. Now unplug the USB drive, wait a few seconds, then plug it back in. A few seconds after plugging it in you should see a symlink /​dev/​disk/​by-label/​usbchanger1 pointing to whatever device node udev decided to assign to the partition. Now try:
Line 168: Line 170:
 ====7. Installing vchanger==== ====7. Installing vchanger====
  
-Place a copy of the [[#​vchanger|vchanger shell script]] in the /etc/bacula directory, than change its owner and permissions as foolows:+Place a copy of the [[#​vchanger|vchanger shell script]] in the /etc/bacula directory, than change its owner and permissions as follows:
  
   chown root.disk /​etc/​bacula/​vchanger   chown root.disk /​etc/​bacula/​vchanger
Line 175: Line 177:
 The first positional parameter passed to vchanger from Bacula specifies the [[#​example_autochanger_config_file|autochanger configuration file]]. Each virtual autochanger will have its own configuration file. An autochanger configuration file defines the following values: The first positional parameter passed to vchanger from Bacula specifies the [[#​example_autochanger_config_file|autochanger configuration file]]. Each virtual autochanger will have its own configuration file. An autochanger configuration file defines the following values:
  
-baculasd ​         [Required] The name of the autochanger,​ as defined in bacula-dir.conf by the Name parameter of the Storage resource for the autochanger device.<br/> +  * "**baculasd**" ​[Required] ​(Default: none) The name of the autochanger,​ as defined in bacula-dir.conf by the Name parameter of the Storage resource for the autochanger device. 
-Default: none+  * "​**baculasd_user**"​ (Default: bacula) ​ Specifies the user that the Bacula Storage Daemon bacula-sd runs as. 
 +  * "​**bconsole**"​ (Default: ​/etc/​bacula/​bconsole) Path to the bconsole executable. 
 +  * "​**magslots**"​ (Default: 10) The number of slots in each magazine. 
 +  * "​**maxdrive**"​ (Default: 0 (which defines 1 virtual drive)) The maximum zero-based drive index number to use. This defines the number of virtual drives the autochanger uses. Multiple drives allow Bacula to concurrently access multiple volumes. The number of virtual drives used must be less than or equal to the number of slots in a magazine. 
 +  * "​**mountpoint**"​ [Required] (Default: none) Path to where the magazine partitions get mounted by autofs. 
 +  * "​**purgepool**"​ (Default: Scratch) Specifies the pool that all volumes will be placed in following a purge command that deletes and then re-creates a magazine'​s volumes. 
 +  * "​**statedir**"​ [Required] (Default: none) Path to the working directory for this autochanger.
  
-baculasd_user ​ Specifies the user that the Bacula Storage Daemon bacula-sd runs as.<​br/>​ +For example, let's say we have two USB disk drives, each of which has been initialized as in [[#​preparing_usb_disk_drives|section 6]] above to contain a single large ext3 filesystem with filesystem label '​usbchanger1'​ that gets mounted at /​mnt/​usbchanger1/​magazine. The following vchanger configuration file defines an autochanger that has 20 slots in a magazine, two virtual drives, and its state information stored in /​var/​bacula/​usbchanger1:​
-Default: bacula +
- +
-bconsole ​         Path to the bconsole executable<​br/>​ +
-Default: /​etc/​bacula/​bconsole +
- +
-magslots ​         The number of slots in each magazine<​br/>​ +
-Default: 10 +
- +
-maxdrive ​        The maximum zero-based drive index number to use. This defines the number of virtual drives the autochanger uses. Multiple drives allow Bacula to concurrently access multiple volumes. The number of virtual drives used must be less than or equal to the number of slots in a magazine.<​br/>​ +
-Default: 0 (which defines 1 virtual drive) +
- +
-mountpoint ​     [Required] Path to where the magazine partitions get mounted by autofs<​br/>​ +
-Default: none +
- +
-purgepool ​       Specifies the pool that all volumes will be placed in following a purge command that deletes and then re-creates a magazine'​s volumes.<​br/>​ +
-Default: Scratch +
- +
-statedir ​           [Required] Path to the working directory for this autochanger<​br/>​ +
-Default: none +
- +
-For example, let's say we have two USB disk drives, each of which has been initialized as in section ​<a href="#​preparing_drives">​6</​a> ​above to contain a single large ext3 filesystem with filesystem label '​usbchanger1'​ that gets mounted at /​mnt/​usbchanger1/​magazine. The following vchanger configuration file defines an autochanger that has 20 slots in a magazine, two virtual drives, and its state information stored in /​var/​bacula/​usbchanger1:​+
  
   # /​etc/​bacula/​usbchanger1.conf   # /​etc/​bacula/​usbchanger1.conf
Line 230: Line 217:
 ====9. Configuring Bacula To Use The Autochanger==== ====9. Configuring Bacula To Use The Autochanger====
  
-The virtual autochanger must be defined by adding **Autochanger** and **Device** resources to Bacula'​s configuration files as described in <a href="#sd_conf">​8.1</​a> ​and <a href="#dir_conf">​8.2</a>. After making changes to Bacula'​s configuration,​ the Storage Daemon and Director must be restarted for these changes to take effect.+The virtual autochanger must be defined by adding **Autochanger** and **Device** resources to Bacula'​s configuration files as described in [[#configuring_the_storage_daemon|section 9.1]] and [[#configuring_the_director|section 9.2]]. After making changes to Bacula'​s configuration,​ the Storage Daemon and Director must be restarted for these changes to take effect.
  
 ===9.1 Configuring The Storage Daemon=== ===9.1 Configuring The Storage Daemon===
  
-To configure the Bacula storage daemon (bacula-sd) we add an Autochanger resource and associated Device resource(es) to bacula-sd.conf. For the example 2 drive, 20 slot autochanger we created in <a href="#install">​7</​a> ​above, we define:+To configure the Bacula storage daemon (bacula-sd) we add an Autochanger resource and associated Device resource(es) to bacula-sd.conf. For the example 2 drive, 20 slot autochanger we created in [[#installing_vchanger|section ​7]] above, we define:
  
 <​file>​ <​file>​
Line 272: Line 259:
 </​file>​ </​file>​
  
-In the **Autochanger** resource, the **Changer Device** value is the path to the  vchanger configuration file for this autochanger. The **Changer Command** value is the command Bacula will execute when it needs the autochanger to perform some function, (like loading a &ldquo;tape&rdquo;). Here, we have installed the vchanger script at /​etc/​bacula/​vchanger,​ and bacula is going to pass the **Changer Device** value in parameter 1, the command (load, unload, etc) in parameter 2, the slot number for the command in parameter 3, the **Archive Device** value from the **Device** resource that has a **Drive Index** value equal to the drive index for the command in parameter 4, and the drive index for the command in parameter 5.+In the **Autochanger** resource, the **Changer Device** value is the path to the  vchanger configuration file for this autochanger. The **Changer Command** value is the command Bacula will execute when it needs the autochanger to perform some function, (like loading a "tape"). Here, we have installed the vchanger script at /​etc/​bacula/​vchanger,​ and bacula is going to pass the **Changer Device** value in parameter 1, the command (load, unload, etc) in parameter 2, the slot number for the command in parameter 3, the **Archive Device** value from the **Device** resource that has a **Drive Index** value equal to the drive index for the command in parameter 4, and the drive index for the command in parameter 5.
  
-In the **Device** resource(es) it is important to set **Device Type** = File so that Bacula understands it is reading/​writing a **File Storage** type volume. The **ArchiveDevice** value is set to a path where vchanger will dynamically create a symlink to the requested slot's file when a &ldquo;tape&​rdquo; ​is loaded. The vchanger script requires that this path be STATEDIR/​driveN,​ where STATEDIR is the working directory for the autochanger that was defined in the vchanger config file and N is the drive index. In the example, the statedir was defined in /​etc/​bacula/​usbchanger1.conf as /​var/​bacula/​usbchanger1,​ so we used ArchiveDevice=/​var/​bacula/​usbchanger1/​drive0 for drive index 0 and ArchiveDevice=/​ var/​bacula/​usbchanger1/​drive1 for drive index 1.+In the **Device** resource(es) it is important to set **Device Type** = File so that Bacula understands it is reading/​writing a **File Storage** type volume. The **ArchiveDevice** value is set to a path where vchanger will dynamically create a symlink to the requested slot's file when a "tape" ​is loaded. The vchanger script requires that this path be STATEDIR/​driveN,​ where STATEDIR is the working directory for the autochanger that was defined in the vchanger config file and N is the drive index. In the example, the statedir was defined in /​etc/​bacula/​usbchanger1.conf as /​var/​bacula/​usbchanger1,​ so we used ArchiveDevice=/​var/​bacula/​usbchanger1/​drive0 for drive index 0 and ArchiveDevice=/​ var/​bacula/​usbchanger1/​drive1 for drive index 1.
  
 ===9.2 Configuring The Director=== ===9.2 Configuring The Director===
Line 310: Line 297:
 ===10.1 Labeling Volumes In New Magazines=== ===10.1 Labeling Volumes In New Magazines===
  
-Plug in one of the newly prepared USB drives from <a href="#preparing_drives">​6.</​a> ​above, then from bconsole execute the command 'label barcodes'​. ​ When prompted for the pool to place the newly labeled volumes into, select the Scratch pool. Bacula will ask the vchanger script for the barcodes of the &ldquo;tapes&​rdquo; ​in each of the  magazine'​s ​&ldquo;slots&​rdquo; ​and use those barcodes will be used as the volume label names for the virtual tapes. The first magazine added to the autochanger will be given magazine index 1. The next will be given index 2, and so on.+Plug in one of the newly prepared USB drives from [[#preparing_usb_disk_drives|section ​6]] above, then from bconsole execute the command 'label barcodes'​. ​ When prompted for the pool to place the newly labeled volumes into, select the Scratch pool. Bacula will ask the vchanger script for the barcodes of the "tapes" ​in each of the  magazine'​s ​"slots" ​and use those barcodes will be used as the volume label names for the virtual tapes. The first magazine added to the autochanger will be given magazine index 1. The next will be given index 2, and so on.
  
 ==10.2 Unloading Magazines== ==10.2 Unloading Magazines==
Line 322: Line 309:
 ===10.4 Adding New Magazines=== ===10.4 Adding New Magazines===
  
-You can add up to 99 magazines to an existing autochanger. Just prepare a new USB drive as described in <a href="#preparing_drives">​6.</​a> ​above and then label its volumes as in <a href="#labeling_volumes">​9.1</​a> ​above. A new magazine will be created using the next available magazine index number.+You can add up to 99 magazines to an existing autochanger. Just prepare a new USB drive as described in [[#preparing_usb_disk_drives|section ​6]] above and then label its volumes as in [[#labeling_volumes_in_new_magazines|section 10.1]] above. A new magazine will be created using the next available magazine index number.
  
 ===10.5 Purging All Volumes In a Magazine=== ===10.5 Purging All Volumes In a Magazine===
Line 399: Line 386:
 # Return length of string $1 # Return length of string $1
 # #
-function strlen () +if [ `uname` = "​FreeBSD"​ ] 
-+then 
-   ​expr length $1 +        ​function strlen () 
-}+        
 +                expr -- "​$1"​ : "​.*"​ 
 +        } 
 +else 
 +        function strlen () 
 +        { 
 +                ​expr length $1 
 +        } 
 +fi 
  
 # #
removable_disk.1248112304.txt.gz · Last modified: 2009/07/20 18:51 (external edit)