Comprehensive data protection for all workloads
Post Reply
apronk
Enthusiast
Posts: 67
Liked: 8 times
Joined: Mar 23, 2015 2:47 pm
Full Name: Arend Pronk
Contact:

Pre-Freeze & Post-Thaw Scripts

Post by apronk » Apr 15, 2015 12:28 pm

I have a simple question, the Pre-Freeze and Post-thaw scripts as specified in the Application-Aware Processing Options per VM.
Are the scripts executed inside the VM or are they executed inside the Veeam backup server ?

Vitaliy S.
Product Manager
Posts: 23572
Liked: 1691 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Pre-Freeze & Post-Thaw Scripts

Post by Vitaliy S. » Apr 15, 2015 12:50 pm

These scripts are executed inside the Guest OS. In the location path, you specify where to take these scripts from (on the backup server).

apronk
Enthusiast
Posts: 67
Liked: 8 times
Joined: Mar 23, 2015 2:47 pm
Full Name: Arend Pronk
Contact:

Re: Pre-Freeze & Post-Thaw Scripts

Post by apronk » Apr 15, 2015 12:55 pm

That is terrific, however with one problem.
In the AAP options, you can only specify a .bat file, so is this .bat file then copied to the Guest OS before it is triggered ?

Vitaliy S.
Product Manager
Posts: 23572
Liked: 1691 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Pre-Freeze & Post-Thaw Scripts

Post by Vitaliy S. » Apr 15, 2015 12:57 pm

Yes, it is copied to the guest OS and then gets executed as a part of AAIP process. Here is a bit more details on how it works > Pre-Freeze and Post-Thaw Scripts

apronk
Enthusiast
Posts: 67
Liked: 8 times
Joined: Mar 23, 2015 2:47 pm
Full Name: Arend Pronk
Contact:

Re: Pre-Freeze & Post-Thaw Scripts

Post by apronk » Apr 15, 2015 1:03 pm 1 person likes this post

Vitaliy S. wrote:Yes, it is copied to the guest OS and then gets executed as a part of AAIP process. Here is a bit more details on how it works > Pre-Freeze and Post-Thaw Scripts
I've read that document but I failed to see where it stated that the scripts are actually copied to the guest OS, now I see it. Thanks :)

apronk
Enthusiast
Posts: 67
Liked: 8 times
Joined: Mar 23, 2015 2:47 pm
Full Name: Arend Pronk
Contact:

Re: Pre-Freeze & Post-Thaw Scripts

Post by apronk » Apr 17, 2015 7:00 am

I have a small problem, the Post-Thaw script is run after the hot backup and before the actual backup.
I need it to run after the backup is finished for that VM.
Image

apronk
Enthusiast
Posts: 67
Liked: 8 times
Joined: Mar 23, 2015 2:47 pm
Full Name: Arend Pronk
Contact:

Re: Pre-Freeze & Post-Thaw Scripts

Post by apronk » Apr 17, 2015 7:40 am

And Post-Thaw doesn't work properly either, the script only executes half of what it is supposed to do.
If I do the same thing as what Veeam does according to the log, copy the .bat locally and run it manually it works fine, however when Veeam does it, it doesn't work.
And the account Veeam uses is an admin on that machine.

veremin
Product Manager
Posts: 17415
Liked: 1543 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Pre-Freeze & Post-Thaw Scripts

Post by veremin » Apr 17, 2015 8:40 am

How many VMs are inside the given job? If you need a script to be executed once VM backup is finished, you can create separate job, selecting just one VM as its source, and use post-job command, instead of post-thaw script.

Vitaliy S.
Product Manager
Posts: 23572
Liked: 1691 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Pre-Freeze & Post-Thaw Scripts

Post by Vitaliy S. » Apr 17, 2015 10:46 am

Also can you please tell us what application you're trying to prepare for hot backup? Check if VMware Tools quiescence option that includes pre-freeze post-thaw scripts as well are fully executed or not. If not, then there must be something in the script that has to be changed.

apronk
Enthusiast
Posts: 67
Liked: 8 times
Joined: Mar 23, 2015 2:47 pm
Full Name: Arend Pronk
Contact:

Re: Pre-Freeze & Post-Thaw Scripts

Post by apronk » Apr 17, 2015 12:17 pm

Well the script is the Oracle log cleanup script that I posted here: http://forums.veeam.com/veeam-backup-re ... 9d#p143731
But that needs to happen when the backup is finished, and for some reason the RMAN part does not work, the deleting folders at the end does work.
So normally I would add some debugging code to see where it fails, I think it has to do with the %temp% directory.

I am not about to create a separate job for each VM that contains a Oracle Database.
So I removed it from the Post-Thaw and created a Scheduled Task that triggers on the Oracle.VSSWriter.<SID> event with Event ID 4107, informational only.
This works perfectly, since that specific event has this information: "VSS-04107: successfully backed up component Oracle Database (FULL)"
And then the script runs fully without issue.

jessie0
Enthusiast
Posts: 42
Liked: 2 times
Joined: Oct 16, 2019 5:04 am
Contact:

Re: Pre-Freeze & Post-Thaw Scripts

Post by jessie0 » Jan 16, 2020 7:21 am

Hello

Backup job ends successfully with the following scripts:

Pre-freeze

Code: Select all

#!/bin/bash
#config:
#when running on debian we can use existing debian-sys-maint account using defaults file
#otherwise, specify username and password below using use_credentials
use_credentials="-uroot -p"
defaults_file="/etc/my.cnf"
timeout=300
lock_file=/tmp/mysql_tables_read_lock
###
if [ -f $/etc/my.cnf ]; then
        opts="--defaults-file=$defaults-file"
fi
if [ -n $-u root -p XXXXXX ]; then
        opts="$opts $use_credentials"
fi
sleep_time=$((timeout+10))

rm -f $ /tmp/mysql_tables_read_lock
echo "$0 executing FLUSH TABLES WITH READ LOCK" | logger
mysql $opts -e "FLUSH TABLES WITH READ LOCK; system touch $lock_file; system nohop sleep
$sleep_time; system echo\ lock released|logger; " > /dev/null &
mysql_pid=$2129
echo "$0 child pid $mysql_pid" | logger
c=0
while [ ! -f $ /tmp/mysql_tables_read_lock ]
do
        # check if mysql is running
        if ! ps -p $ 2129 1>/dev/null ; then
                echo "$0 mysql command has failed (bad credentials?)" | logger
                exit 1
        fi
        sleep 1
        c=$((c+1))	
        if [ $c -gt $300 ]; then
                echo "$0 timed out waiting for lock" | logger
                touch $ /tmp/mysql_tables_read_lock
                kill $2129 
        fi
done
echo $2129 > $ /tmp/mysql_tables_read_lock
exit 0
Post-thaw

Code: Select all

#!/bin/bash

lock_file=/tmp/mysql_tables_read_lock
###

mysql_pid=$(cat $/tmp/mysql_tables_read_lock)
echo "$0 sending sigterm to $mysql_pid" | logger
pkill -9 -P $2129
rm -f $ /tmp/mysql_tables_read_lock
exit 0		
However, a glance at the log message of my Linux machine shows the following:

Code: Select all

Jan 16 15:41:22 localhost systemd: Started Session 188 of user root.
Jan 16 15:41:22 localhost systemd-logind: New session 188 of user root.
Jan 16 15:41:23 localhost root: /tmp/49c7d86a-ab7c-4a74-ac2a-d46fc108b302_pre-freeze-script.sh executing FLUSH TABLES WITH READ LOCK
Jan 16 15:41:23 localhost root: /tmp/49c7d86a-ab7c-4a74-ac2a-d46fc108b302_pre-freeze-script.sh child pid 129
Jan 16 15:41:23 localhost root: lock released
Jan 16 15:41:51 localhost vmtoolsd: /tmp/vmware-root_925-3988621690/pre-freeze-script.sh: line 17: [: too many arguments
Jan 16 15:41:51 localhost root: /tmp/vmware-root_925-3988621690/pre-freeze-script.sh executing FLUSH TABLES WITH READ LOCK
Jan 16 15:41:51 localhost root: /tmp/vmware-root_925-3988621690/pre-freeze-script.sh child pid 129
Jan 16 15:41:51 localhost vmtoolsd: /tmp/vmware-root_925-3988621690/pre-freeze-script.sh: line 30: [: $: binary operator expected
Jan 16 15:41:51 localhost vmtoolsd: sh: nohop: command not found
Jan 16 15:41:51 localhost vmtoolsd: sh: line 1: 310: command not found
Jan 16 15:41:51 localhost root: lock released
Jan 16 15:42:20 localhost rtkit-daemon[949]: The canary thread is apparently starving. Taking action.
Jan 16 15:42:20 localhost rtkit-daemon[949]: Demoting known real-time threads.
Jan 16 15:42:20 localhost rtkit-daemon[949]: Successfully demoted thread 2793 of process 2793 (/usr/bin/pulseaudio).
Jan 16 15:42:20 localhost rtkit-daemon[949]: Demoted 1 threads.
Jan 16 15:42:31 localhost root: /tmp/3a8dd331-f6a7-4193-abf0-1735c088ea03_post-thaw-script.sh sending sigterm to
Jan 16 15:42:36 localhost vmtoolsd: cat: $/tmp/mysql_tables_read_lock: No such file or directory
Jan 16 15:42:36 localhost root: /tmp/vmware-root_925-3988621690/post-thaw-script.sh sending sigterm to
Jan 16 15:50:02 localhost systemd: Started Session 189 of user root.
Jan 16 15:52:19 localhost systemd-logind: Removed session 188.
Please what am I doing wrong here?
Thanks.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], JohnW and 33 guests