Simple backup script (daily)

Call the script “backup_daily.cmd” and run it on weekdays.  You don’t have to run it each day; you can run it only on saturdays or every other day; you decide.  It will save data in the following folders:

1_Monday
2_Tuesday
3_Wednesday
4_Thursday
5_Friday
6_Saturday
7_Sunday

Each time the script is run, the appropriate weekday folder will be overwritten.

Note: You will need a longer term backup job as well, as after 1 week you can no longer restore files you deleted more than a week ago.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: If site uses multiple HDDs for backup rotation:           ::
::   - only connect one HDD at a time to retain drive letters::
::   - make sure they all are assigned the same drive letter ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@echo off
SETLOCAL

:::::::::::::
:: Weekdays ::
::::::::::::::

for /f "tokens=1" %%i in ('date /t') do set shortday=%%i
if %shortday% == Mon set today=1_Monday
if %shortday% == Tue set today=2_Tuesday
if %shortday% == Wed set today=3_Wednesday
if %shortday% == Thu set today=4_Thursday
if %shortday% == Fri set today=5_Friday
if %shortday% == Sat set today=6_Saturday
if %shortday% == Sun set today=7_Sunday

::::::::::::::::::::
:: Site Variables ::
::::::::::::::::::::

set usb=F:
set dest=%usb%\Backup\%today%
set switches=/E /NP /NFL /tee /R:1 /W:1 /MIR /COPYALL
set robocopy=%windir%\system32\robocopy.exe

::::::::::::::::::::
:: Initialization ::
::::::::::::::::::::

if not exist "%usb%"  exit
if not exist "%dest%" md "%dest%"

:::::::::::::
:: Backup  ::
:::::::::::::

"%robocopy%" "c:\folder1" "%dest%\folder1" %switches% /LOG:"%dest%\backup_folder1.log"
"%robocopy%" "c:\folder2" "%dest%\folder2" %switches% /LOG:"%dest%\backup_folder2.log"
"%robocopy%" "c:\folder3" "%dest%\folder3" %switches% /LOG:"%dest%\backup_folder3.log"

:End
ENDLOCAL
:Exit

Simple backup script (daily) was last modified: March 20th, 2015 by tabcom