| 1. |
Solve : Batch job that send out email and deletes previous backup? |
|
Answer» I have written a working batch file to back up some folders/application 1. I want to send out email notification after the backup is completed=> before the last command There are more reliable ways to get a date and time string which do not depend on the user locale and/or MACHINE and which sort naturally in a batch script. Some questions you'd need to answer are:
----- The filename format is an application based format that ends with . A typical example is this Test.out-20151206_0953.isx Are there any other files in the folder with the backup files? ----- There will be other files from previous backup in this directory reading different timestamp What is the name of the backup folder location ---- The name of the backup location is a subfolder under the folder where the script is located. SO if my script is in D:\Istool. My backup will be D:\istool\Backup Do you have admin permissions ----- Yes What tool do you want to send the email with? ---- Pure MSDOS batch command. No third party tool What is the actual number of files being kept - a range of the actual number would be nice. 10 to 200 for example. --- 30 meaning one backup per day Quote from: Great! on June 12, 2015, 12:53:45 PM What is the filename format of the backup files? You use YYYYDDMM format ? Quote from: Great! on June 12, 2015, 12:53:45 PM Are there any other files in the folder with the backup files? Are there only .isx files in the backup folder? One per backup? Quote What tool do you want to send the email with? There's a problem there. No pure MSDOS batch command exists, to send an email."You use YYYYDDMM format "? -Yes appended to the file "Are there only .isx files in the backup folder? One per backup?" -Yes Only .isx file "What tool do you want to send the email with?" -What options available here Here's a snippet that will keep the 30 newest files in the backup folder that is in the current folder. Remove the echo after testing. It will simply echo the delete commands to the console at the moment. Code: [Select]echo off for /f "skip=30 delims=" %%a in ('dir backup /b /o-d /a-d') do echo del "backup\%%a" pause A VBS script has the ability to send email sendmail, blat, and others are free email sending tools. |
|