I wanted to chime back in on this. I've worked out a script that will delete files in directories only after a successful backup. This will work for Windows only:
@echo off
ECHO =====NetWorker SAVE SET COMMAND=======
SHIFT
SET arg=%0
:loop
SHIFT
IF %0.==. GOTO save
SET arg=%arg% %0
SET delpath=%0
GOTO loop
REM These are the save commands that run the required
REM NetWorker backup commands.
:save
REM Note: Enter correct path to your NetWorker bin
REM directory (line below is default path)
"C:\Program Files\Legato\nsr\bin\save.exe" %arg%
IF %ERRORLEVEL% EQU 0 (GOTO success) ELSE (GOTO failure)
:success
del /s /q %delpath%\*.*
echo Successful, contents of %delpath% deleted.
GOTO end
:failure
echo An error was found. Contents of %delpath% not deleted.
Really? Nobody has done anything like this? C'mon community, I know you can do better than that!
In 21st century most people use online backup so they do not need to mess around with scripts. There are several ways how to do this, but I would suggest to include del command to be part of SQL dump instead. That way, old dump stays there until new one is ready to go (unless those overwrite each other already where in such case you do not need delete action at all).
You need to add into your script a test to check the last backup, something like running an mminfo:
mminfo -q "savetime>1 day ago,name=MSSQL:,client=clientname,incomplete=false" -r {some fields}
Then querying the results you get out until you are happy what you have is deleteable - when you are using the delete command in a script it is sensible to put as many checks in as you can to make really really sure you have backed your data up before deleting it.
Yes..that works. But problem with doing a "push" backup (client initiated), is that you dont know if tape drive is
available, tape media is available etc. That's why savepnpc is there. it creates a small "script" which you can modify to what you want.
In my case, I use it to backup MYSQL database. using the savepnpc "script" , I stop the slave threads, take backup and once backup is done, restart slave threads. This is all done in 3 lines.
I dont know much about your configuration. In an enterprise tuned setup i would assume that devices and media were available. Its still possible to check this client side via script.
I havent heard great things about savepnpc over the years but maybe its better now.
imasock
16 Posts
0
June 11th, 2012 12:00
I wanted to chime back in on this. I've worked out a script that will delete files in directories only after a successful backup. This will work for Windows only:
@echo off
ECHO =====NetWorker SAVE SET COMMAND=======
SHIFT
SET arg=%0
:loop
SHIFT
IF %0.==. GOTO save
SET arg=%arg% %0
SET delpath=%0
GOTO loop
REM These are the save commands that run the required
REM NetWorker backup commands.
:save
REM Note: Enter correct path to your NetWorker bin
REM directory (line below is default path)
"C:\Program Files\Legato\nsr\bin\save.exe" %arg%
IF %ERRORLEVEL% EQU 0 (GOTO success) ELSE (GOTO failure)
:success
del /s /q %delpath%\*.*
echo Successful, contents of %delpath% deleted.
GOTO end
:failure
echo An error was found. Contents of %delpath% not deleted.
:end
imasock
16 Posts
0
March 22nd, 2012 14:00
Really? Nobody has done anything like this? C'mon community, I know you can do better than that!
ble1
4 Operator
•
14.3K Posts
0
April 30th, 2012 09:00
In 21st century most people use online backup so they do not need to mess around with scripts. There are several ways how to do this, but I would suggest to include del command to be part of SQL dump instead. That way, old dump stays there until new one is ready to go (unless those overwrite each other already where in such case you do not need delete action at all).
DavidHampson-rY
294 Posts
0
May 2nd, 2012 07:00
One more thing, you are using NMM so will not have NMSQL type savesets (MSSQL:)
DavidHampson-rY
294 Posts
0
May 2nd, 2012 07:00
You need to add into your script a test to check the last backup, something like running an mminfo:
mminfo -q "savetime>1 day ago,name=MSSQL:,client=clientname,incomplete=false" -r {some fields}
Then querying the results you get out until you are happy what you have is deleteable - when you are using the delete command in a script it is sensible to put as many checks in as you can to make really really sure you have backed your data up before deleting it.
satishs
50 Posts
0
May 3rd, 2012 09:00
Did you try "savepnpc"...it allows you to do pre/post commands (i.e. before/after a backup)
nicbone
116 Posts
0
May 11th, 2012 03:00
On UNIX i test the return code from the actual save command. If its not return code 0 then dont delete anything and alert out for investigation
Assume windows allows the same type of thing?
sks20
13 Posts
0
May 11th, 2012 07:00
Yes..that works. But problem with doing a "push" backup (client initiated), is that you dont know if tape drive is
available, tape media is available etc. That's why savepnpc is there. it creates a small "script" which you can modify to what you want.
In my case, I use it to backup MYSQL database. using the savepnpc "script" , I stop the slave threads, take backup and once backup is done, restart slave threads. This is all done in 3 lines.
nicbone
116 Posts
0
May 11th, 2012 07:00
I dont know much about your configuration. In an enterprise tuned setup i would assume that devices and media were available. Its still possible to check this client side via script.
I havent heard great things about savepnpc over the years but maybe its better now.