Standalone backup agents for Linux, Mac, AIX & Solaris workloads on-premises or in the public cloud
Post Reply
dave.misko
Novice
Posts: 4
Liked: never
Joined: Sep 28, 2018 7:47 pm
Full Name: Dave Misko
Contact:

Running Script on Linux Backup Job

Post by dave.misko »

I need to run the following script before my backup job starts.

This is a Linux server. I need to know how to set this up. Where does the script file go? How should I have it called?

Here is the script, (edited for confidentiality):

Code: Select all

#!/bin/bash
#
# Script to backup Innovative Library System
#
# May 23, 2005  ;rdj;   created
#
# This script uses the III API called iiictl.  The command is located in the
# /usr/sbin directory. The plan is to create a daily backup directory and then 
# run iiictl to copy the Innovative files into it.
# Then Backup Exec will copy those files and all system files on it's normal run.
# Backup Exec will not backup the III directories.
#
mount | grep noexec | grep tmp
echo "Starting III backup on `date`"
 
# make sure the rm command does not have an alias
unalias rm

# setup date and time variables for directory creation
BUD=`date +%b%d%Y`
echo "BackupDate="$BUD
DOW=`date +%a`
echo "Day of the Week="$DOW
echo "Backup Date="$BUD
echo ""

#
# remove old backup sets first - older than 3 days for now
# This happens only Tuesday-Saturday
# This will leave three days worth of backups online before the oldest ones get deleted
# Note: the find command syntax here is specific for RedHat AS2.1.  This script concept
# was first used on AIX where the find command used the -prune argument

        find /iiibackup/millennium/ -mtime +1 -type d -maxdepth 1 -exec rm -rf {} \;

## Set actual backup directory location

       DBLOC="/iiibackup/millennium/$BUD"
       echo "DBLOC="$DBLOC
#
## Check for todays date.  If it exists, remove it and create a new one
        if [ -d $DBLOC ] ; then
                echo "Backup directory already exists, removing"
                cd /iiibackup/millennium
                rm -rf $BUD
        else
                echo "No duplicate found... continuing"
        fi
#
## Create new directory and copy datafiles
        echo "Creating backup directory for III Millennium"
        mkdir $DBLOC

#
## Run the III commands to prepare for the backup
# 
#
# The set notify only needs to happen once and is stored
#       /usr/sbin/iiictl set notify me@company.com
        /usr/sbin/iiictl get notify
        /usr/sbin/iiictl backup prepare
        prepare_val=$?
        echo "Prepare Value="$prepare_val
        if [ $prepare_val -eq 0 ]
                then
                        cd /
                        tar cf - iiidb --exclude lost+found --exclude /iiidb/sockets | (cd $DBLOC; tar xBf -)
                        tar cf - iii --exclude lost+found | (cd $DBLOC; tar xBf -)
                        tar cf - iiiroot | (cd $DBLOC; tar xBf -)
                        /usr/sbin/iiictl backup success
                        success_val=$?
                        echo "Success Value="$success_val
                                if [ $success_val -neq 0 ]
                                  then
                                     mail -s "III Backup Success command Failed" me@company.com
                                fi
#                       /usr/sbin/iiictl log dump
                else
                        /usr/sbin/iiictl backup fail
                        fail_val=$?
                        echo "Fail Value="$fail_val
                                if [ $fail_val -eq 0 ]
                                  then
                                    mail -s "III Backup Failed" me@company.com
             fi
        fi
#
echo "Backup completed at `date`"
Thanks for any help.

-Dave
PTide
Product Manager
Posts: 6551
Liked: 765 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Running Script on Linux Backup Job

Post by PTide »

Hi,

You can give it any name of your choice, and place at any location that is accessible. In job settings you simply specify the location where the script is placed.

That can be configured both in UI and CLI (use --prejob parameter)

Thanks!
dave.misko
Novice
Posts: 4
Liked: never
Joined: Sep 28, 2018 7:47 pm
Full Name: Dave Misko
Contact:

Re: Running Script on Linux Backup Job

Post by dave.misko »

PTide,

Should it be placed on the Linux (RedHat) Server? If, so, where do you suggest, and how should it be referenced?

-Dave
PTide
Product Manager
Posts: 6551
Liked: 765 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Running Script on Linux Backup Job

Post by PTide »

Yes, if it's just a standalone installation (i.e. not managed by VBR server), then you have to place the script file on the RHEL server. You can place it at any place of your choice, depending on your preferences and security policies in place.

Thanks!
dave.misko
Novice
Posts: 4
Liked: never
Joined: Sep 28, 2018 7:47 pm
Full Name: Dave Misko
Contact:

Re: Running Script on Linux Backup Job

Post by dave.misko »

OK. Say I place in the \etc\scripts folder. Where within the Veeam Console do I call the script? How would I reference that....\etc\scripts? I am not a linux person.
PTide
Product Manager
Posts: 6551
Liked: 765 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Running Script on Linux Backup Job

Post by PTide »

Ok, at this point I'm not really sure if you are trying to backup a Linux physical machine using or a Linux VM, would you clarify that, please?
nitramd
Veteran
Posts: 298
Liked: 85 times
Joined: Feb 16, 2017 8:05 pm
Contact:

Re: Running Script on Linux Backup Job

Post by nitramd »

@dave.misko

What are you trying to accomplish? I have to agree with @PTide that what you're trying to achieve is not clear.

Can you start from the beginning, i.e. is the machine you're trying to back up physical or virtual? Next, do you use Veeam? Etc.

Traditionally, any script you create is placed in the directory structure /usr/local/bin. When you want a script to run regularly then you create an entry in the crontab - I think though that Red Hat may employ a slightly different method of regularly running scripts.

If your copy of Red Hat OS is a paid for version then you should be able to find answers to some of your questions by logging into access.redhat.com

Otherwise, a search engine of your choice is a good friend.
dave.misko
Novice
Posts: 4
Liked: never
Joined: Sep 28, 2018 7:47 pm
Full Name: Dave Misko
Contact:

Re: Running Script on Linux Backup Job

Post by dave.misko »

OK...Very sorry.

The system in question is a physical server, NOT A VM, that is running RedHat Enterprise v7.5.

It is a Library Catalog system. The traditional backup is running with the Veeam Agent installed. The problem, simply, is that the logging service for the data that writes within the catalog, must be stopped before the actual data is copied. The script I posted above, needs to called, before the back process runs, to first stop the logging service, perform the backup job, and restart the logging service.

My question is, where does the script go on the Linux Server? How do I call that script from within the Veeam Configuration Job that is set up to back up that server?

Hope this is more clear.

-Dave
PTide
Product Manager
Posts: 6551
Liked: 765 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Running Script on Linux Backup Job

Post by PTide »

So, you have to use a pre-job and post-job scripts. Two options that you have, depending on how the Agent backup job has been configured:

A) Veeam Agent backup job has been configured via Veeam Backup and Replication server

In this case you need to go to "Storage - Advanced - Scripts" step.

Mind the difference between two modes


MODE-1: Veeam Agent backup job managed by the backup server

The scripts are executed on the backup server.


MODE-2: Veeam Agent backup job managed by Veeam Agent

Veeam Backup & Replication will upload the script(s) to the /var/lib/veeam/scripts directory on each computer added to the configured Veeam Agent backup job. During the Veeam Agent backup job session, Veeam Agent for Linux will execute the script(s) on these computers


B) Veeam Agent backup job has been configured on the Linux server using local UI/CLI

In this case please refer to my previous post.

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests