TiNa - Outsourcing datas

This script allow the TiNa server to launch a script to outsourcing data.

Prerequires

  • Make sure the ANNUAL_OUTSOURCING pool in TiNa exist

    • Menu: Storage > Media Pools > Properties
  • Make sure you have already made in TiNa All necessary FULL backups

    • Right click on strategy on a host > Full Session Now
  • Look at the backup ID

    • Menu: Monitoring > Job Manager

Launch the script

The script can be paced in /root/TiNa-scripts on the TiNa server itself (the full script is bellow).

USAGE:    /root/TiNa-scripts/TiNa-Outsourcing.sh [RANGE-ID-JOB-START] [RANGE-ID-JOB-END]                   
EXAMPLE: /root/TiNa-scripts/TiNa-Outsourcing.sh 2742 2784

This script will lauch the command:

$YourTiNaPATH/Bin/tina_job_control -jobid [StartID-EndID] -duplicate -pool ANNUAL_OUTSOURCING -empty_cart    

After launching it, you should have the output bellow:

Processing Job ID: 135699
Duplicating job "135699"
Job "135699" duplicated
Job ID 135699: Duplication successful.

Processing Job ID: 135700
Duplicating job "135700"
Job "135700" duplicated
Job ID 135700: Duplication successful.

Processing Job ID: 135701
Duplicating job "135701"
Job "135701" duplicated
Job ID 135701: Duplication successful.
[...]

The full script .

In a bash executable file:

#!/bin/bash
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Last version : 2024-12-04
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# README ═══════════════════════════════════════════════════════════════════════════════════════════
# This script
# - Duplicate TiNa backup in order to outsource data
# - Ask for a range of backup (So, make full backup of all host)
# - Copy backup on cartridges on pool "ANNUAL_OUTSOURCING"
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

# ━━━━━━━━━━━━━━━━━━━━━━━
# Usage help
echo -e "\n ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
echo -e " ┃ Before lauch this script, make sure you have already made in TiNa All necessary FULL backup ┃"
echo -e " ┃ ● USAGE: ./TiNa-Outsourcing.sh [RANGE-ID-JOB-START] [RANGE-ID-JOB-END] ┃"
echo -e " ┃ ● EXAMPLE: ./TiNa-Outsourcing.sh 2742 2784 ┃"
echo -e " ┃ > This script will lauch the command: ┃"
echo -e " ┃ tina_job_control -jobid [StartID-EndID] -duplicate -pool "ANNUAL_OUTSOURCING" -empty_cart ┃"
echo -e " ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n"

# ━━━━━━━━━━━━━━━━━━━━━━━
# Prompt for confirmation
read -p "Do you want to proceed with this script? (yes/no): " confirmation

if [[ "$confirmation" != "yes" ]]; then
echo -e "\nScript execution aborted by the user.\n"
exit 0
fi

echo -e "\nContinuing with the script execution...\n"

# ━━━━━━━━━━━━━━━━━━━━━━━
# Check number of arguments
if [ "$#" -ne 2 ]; then
echo -e "Error: This script needs exactly 2 arguments.\n"
exit 1
fi
# Check if arguments are numbers
if ! [[ "$1" =~ ^[0-9]+$ && "$2" =~ ^[0-9]+$ ]]; then
echo -e "Error: Both arguments must be numeric.\n"
exit 1
fi
# Check if $1 < $2
if [ "$1" -ge "$2" ]; then
echo -e "Error: The first argument must be less than the second argument.\n"
exit 1
fi

# ━━━━━━━━━━━━━━━━━━━━━━━
# Launch duplication
for dupjobs in $(seq "$1" "$2"); do

echo -e "\nProcessing Job ID: $dupjobs"

# Execute the TiNa command and capture its output
output=$($YourTiNaPATH/Bin/tina_job_control -jobid "$dupjobs" -duplicate -pool "ANNUAL_OUTSOURCING" -empty_cart 2>&1)
status=$?

# Print the captured output
echo "$output"

# Check the command status
if [ $status -eq 0 ]; then
echo "Job ID $dupjobs: Duplication successful."
else
echo "Job ID $dupjobs: Duplication failed with errors."
fi
done

echo -e "\n\nDuplication process completed.\n\n"

Extraction

You can now extract cartridges with the tag “ANNUAL_OUTSOURCING” from your backup robot.

Documentation

MAN TiNa

Remerciements

Quentin E.

Merci à Quentin E. pour le complément d'informations

🡅 Partager