Using batch file to create / move backup across network.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
SteveNetadmn
Posts: 3
Joined: 31 May 2012 12:42

Using batch file to create / move backup across network.

#1 Post by SteveNetadmn » 11 Jun 2012 07:06

Made some great headway over the weekend. Here's a script I wrote that does the job could stand for some improvement. I had to do this over two batch files since the Shoretel backup script apparently short circuits everything below the command in the batch file.

Some folder names, etc censored.

First batch file:
REM delete previous backup folders generated by Shoretel backup script.
set folder="c:\backupfolder\
cd /d %folder%
for /f "delims=" %%i in ('dir /b') do (rmdir "%%i" /s /q || del "%%i" /s /q)

REM run shoreware backup script
cd /d "C:\path\to\script\"
"c:\path\to\script\script.bat"


Second batch file:
REM zip new backup folder to a server with current date stamp in zip file name
cd "c:\program files\7-zip"
7z.exe a r:\%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%_Backup.zip "c:\backupfolder\*"

REM delete files (what will be zip files) from remote server older than 10 days old from mapped network drive r:
forefiles -p r:\ -s -m *.* -d 10 "cmd /c if @isdir==false echo del @path"





This has worked so far, the 11'th day will be a real test. One of the remaining problems is that the administrator user for the phone server must remain logged in because the NT SYSTEM account that handles scheduled tasks when no one is logged in does not handle mapped network drives very well. I could probably get buy with a NET USE command but I REALLLLLLLLLY don't feel like storing a username / password for where the backup will end up in a plain text file, know what I mean? Hence the mapped network drive under the user. I have not really been able to get deeper into programming to do obfuscation or whatever to encrypt a password in a script and make it all fancy. Sadly I deal mostly with network administration.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Using batch file to create / move backup across network.

#2 Post by foxidrive » 15 Jun 2012 01:11

I would comment that deleting all backups is not as good as having generations of backups.

Did you have a question regarding this?

Post Reply