Mundy

IT Knowledge Base

User Tools

Site Tools


script_to_record_backup_disk_changes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

script_to_record_backup_disk_changes [2018/04/09 09:56] (current)
Line 1: Line 1:
 +====== Script to record backup disk changes ======
  
 +<code winbatch>​
 +@echo off
 +
 +set driveletter=G
 +set working=C:​Scripts
 +set log=%working%Backup-disk.log
 +
 +set thedate=%date:​Mon =%
 +set thedate=%thedate:​Tue =%
 +set thedate=%thedate:​Wed =%
 +set thedate=%thedate:​Thu =%
 +set thedate=%thedate:​Fri =%
 +set thedate=%thedate:​~6,​4%/​%thedate:​~3,​2%/​%thedate:​~0,​2%
 +set thetime=%time:​~0,​2%:​%time:​~3,​2%:​%time:​~6,​2%
 +set datestamp=%thedate:/​=%%thetime::​=%
 +set datestamp=%datestamp:​ =%
 +
 +if not exist %driveletter%:​diskid2.txt echo %datestamp% > %driveletter%:​diskid2.txt
 +
 +set /p diskid=<​%driveletter%:​diskid2.txt
 +
 +REM :: remove any spaces from the diskid:
 +set diskid=%diskid:​ =%
 +
 +if not exist %working%lastdisk.txt echo None > %working%lastdisk.txt
 +set /p lastdisk=<​%working%lastdisk.txt
 +
 +if not exist %driveletter%:​diskid2.txt (
 +     echo %thedate% - %thetime% - NO DISK FOUND at drive letter %driveletter% >> %log%
 +     exit
 +)
 +
 +if %diskid%==%lastdisk% (
 +     echo %thedate% - %thetime% - Disk was not changed since last check >> %log%
 +)
 +
 +if not %diskid%==%lastdisk% (
 +     echo %thedate% - %thetime% - The disk at drive letter %driveletter% was changed to: %diskid% >> %log%
 +     echo %diskid% > %working%lastdisk.txt
 +)
 +</​code>​
script_to_record_backup_disk_changes.txt · Last modified: 2018/04/09 09:56 (external edit)