Eject tape after backup, only single drive license, no library

G'day,

after seeking several blogs, I'm still searching for a cli command with does same as GUI right-click on tape device, scan and option eject.

Only command I found, which ejects tape is omnimver -device "<devicename>" -eject, which takes quite a bit of time verifying tape.

We cannot create a second tape due to license limitations and it's a single drive, not a library/changer. For we have several backup jobs, so it's also not possible to check eject after backup in device.

Thanks and regards.

O. Knopff

 

Parents
  • Hello

    FRom HELP online

    Example of Scheduling Eject of Media
    This example describes how to schedule an eject of all backup media used during the night at 6:00 A.M. every day. A Perl script is used in this example.

    Prerequisite
    A program or script must be created on the Cell ManagerThe main system in the cell where the essential Data Protector software is installed and from which all backup and restore activities are managed. The GUI used for management tasks can be located on a different system. Each cell has one Cell Manager system. to perform the ejection, and any applicable interpreters must also be installed on the Cell Manager.

    Configuration Phases
    Scheduling the report group

    Adding the report to the report group and configuring it

    Copying the script to the specified directory

    Scheduling the report group
    Steps
    In the Context List, select Reporting.

    In the Scoping Pane, expand Reporting. Right-click Reports and click Add Report Group to open the wizard.

    Name your report group(Microsoft Cluster Server specific term) A collection of resources (for example disk volumes, application services, IP names and addresses) that are needed to run a specific cluster-aware applications. and then click Next. The Data ProtectorSchedulerA function that controls when and how often automatic backups occur. By setting up a schedule, you automate the start of backups. is displayed.

    Select the day on which you want the report group to start and click Add. The Schedule Report Distribution dialog window opens.

    Under Recurring, select Daily. Under Time options, select the starting time for the report group.

    Click OK and then click Finish to start the Add New Report Wizard.

    Adding the report to the report group and configuring it
    Steps
    In the Add Report section of the Add New Report wizard, select Reports on media and media pools.

    Name the report and select the List of Media type. Click Next.

    To eject all media regardless of media poolA set of media of the same type (such as DDS) used and tracked as a group. Media are formatted and assigned to a media pool. and location, leave all fields set to default settings. Click Next four times.

    Select the Relative time and specify 8 for the Started within last hours and 8 for the Duration hours text boxes. This causes only the media that were used for backup in the last eight hours from the point of starting a report to be listed in the report. Click Next.

    In the Send drop-down list select External and in the Format drop-down list select Tab. In the Script text box, provide the name of the script (HP-UX systems) or the batch file containing the command that starts the script (Windows systems). The script is given below. The script must reside in the /opt/omni/lbin directory (HP-UX Cell Managers). The starting batch file must reside in the Data_Protector_homeA reference to the directory containing Data Protector program files (on Windows Vista, Windows 7, Windows 8, Windows Server 2008, and Windows Server 2012) or the directory containing Data Protector program files and data files (on other Windows operating systems). Its default path is %ProgramFiles%\OmniBack, but the path can be changed in the Data Protector Setup Wizard at installation time. See also Data_Protector_program_data.\bin directory (Windows Cell Managers). On Windows Cell Managers, the contents of the batch file containing command for starting the script is:

    perl_home\perl.exe "Data_Protector_home\bin\omnirpt_eject.pl".

    Click the button to add this recipient and then click Finish. The scheduled and configured report group appears in the Results Area.

    Copying the script to the specified directory
    Steps
    Copy or create the script with the name omnirpt_eject.pl in the /opt/omni/lbin (HP-UX Cell Managers) or Data_Protector_home\bin directory (Windows Cell Managers):


    #!/usr/contrib/bin/perl

    #=================================================================================
    # FUNCTION Library_Eject
    #
    # ARGUMENTS param 1 = Library to eject from
    # param 2 = Slots to eject
    #
    # DESCRIPTION Function ejects specified slots from specified libraryAlso called autochanger, jukebox, autoloader, or exchanger. A library contains media in repository slots. Each slot holds one medium (for example, DDS/DAT). Media are moved between slots and drives by a robotic mechanism, allowing random access to media. The library can contain multiple drives.
    #=================================================================================

    sub Library_Eject {
    local ($lib,$slots)=@_;
    print "[Normal] Ejecting slotA mechanical position in a library. Each slot can hold a medium, such as a DLT tape. Data Protector references each slot with a number. To read a medium, a robotic mechanism moves the medium from a slot into the drive.(s) ${slots}from library \"$lib\"\n";
    print("[Normal] Executing \"${OMNIBIN}omnimm\" -eject \"$lib\" $slots\n");
    $report =`"${OMNIBIN}omnimm" -eject \"$lib\" $slots 2>&1`;
    #print "\debug>\n$report\n<debug\n";
    if ($report !~/Final report: (\d ) cartridges out of (\d ) successfully ejected\./) {
    print "[Critical] Eject has failed!\n\nReport:\n$report\n";
    return (1);
    }
    print "$report\n";
    if ($1 ne $2) {
    print "[Warning] Not all media successfully ejected!\n";
    return (2);
    }
    print "[Normal] Eject from library \"$lib\" successfully completed.\n";
    return (0);
    }


    #=================================================================================
    # FUNCTION Eject
    #
    # ARGUMENTS none
    #
    # DESCRIPTION Function for each library in %List call Library_Eject
    #=================================================================================

    sub Eject {
    local ($lib,$slot,$result);
    while (($lib, $slot) = each(%List)){
    $result |=&Library_Eject($lib,$slot);
    }
    if ($result) {
    return (1);
    } else {
    print "[Normal] All operations successfully completed.\n";
    return (0);
    }
    }


    #=================================================================================
    # FUNCTION Omnirpt
    #
    # ARGUMENTS none
    #
    # DESCRIPTION Function get slots to eject from omnirpt report
    #=================================================================================

    sub Omnirpt {
    @lines=STDIN;
    for ($i=5;$i<@lines;$i ){
    @Line=split(/\t/,$lines[$i]);
    if ($line[2] =~/^\[([\w:\-\s] ):\s (\w )\]/){
    $List{$1}.=$2.' '; # $1= "Library name", $2= "Slot ID"
    }
    }
    if (!keys(%List)) {
    print "[Warning] No tape(s) to eject.\n";
    return (1);
    }
    return (0);

    }


    #------------------------------------------------------------------------
    # MAIN
    #------------------------------------------------------------------------

    if ($ENV{"OS"}=~/Windows_NT/) { # Windows
    $OMNIBIN ='c:\\program files\\omniback\\bin\\';
    } else {
    local($uname)=`uname -a`;
    chop $uname;
    @uname=split(' ', $uname);
    if ($uname[0]) {
    if ($uname [0] eq 'HP-UX' || $uname [0] eq 'SunOS') {
    $OMNIBIN ='/opt/omni/bin/';
    } else {
    $OMNIBIN ='/usr/omni/bin';
    }
    } else {
    exit (1);
    }
    }

    print "[Normal] Starting eject of media that have been used in the last x hours.\n";

    exit (0) if (&Omnirpt());
    exit (1) if (&Eject());

  • Hello,

    will this also do for single drive???

    Taking a look at script, I see ARGUMENTS ... Library to eject from an Slots to eject....

    And after all: that's quite a bit of code and work for such a simple task, which is done in GUI by three clicks, isn't it? :-)

    I cannot imagine that there is no command for just ejecting a tape from a single drive, not library!
    For libraries it's quite easy with omnimm -eject, why is there no such command for single drive?

    Many thanks!

     

     

     

  • There is no CLI command for that, but a simple workaround exists.

    You need to create two logical instances of the same device (make sure the same lockname is used). Lets say you have a logical device named LTO6 and one named LTO6_EJECT. Make sure LTO6_EJECT has the Eject media after session option checked. Use LTO6 for all backups except the last one. The last backup job should use LTO6_EJECT. Does this work for you?

    Regards,
    Sebastian Koehler

Reply
  • There is no CLI command for that, but a simple workaround exists.

    You need to create two logical instances of the same device (make sure the same lockname is used). Lets say you have a logical device named LTO6 and one named LTO6_EJECT. Make sure LTO6_EJECT has the Eject media after session option checked. Use LTO6 for all backups except the last one. The last backup job should use LTO6_EJECT. Does this work for you?

    Regards,
    Sebastian Koehler

Children