Created
September 6, 2021 14:16
-
-
Save Esl1h/cddf9872ef62a56409bef5076a9e418d to your computer and use it in GitHub Desktop.
simple batch script to backup folders and files in Windows hosts to another drive or network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo | |
set source=C:\ | |
set destination=\\servername\d$ | |
set command=xcopy /c /d /e /f /g /h /i /r /s /y | |
set log=D:\backup_log_file.txt | |
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b) | |
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b) | |
echo # # # Starting files %mydate% at %mytime% >> %log% | |
%command% "%source%\My_Backups" "%destination%\Backups" >> %log% | |
echo # # %mydate% at %mytime% Complete! >> %log% | |
:: xcopy /c /d /e /g /h /i /r /s /y "C:\My_Backups" "\\servername\d$\Backups" >> D:\backup_log_file.txt | |
:: Alternative to xcopy: robocopy, copy, copy-item (PowerShell) | |
:: To use 'forfiles' command to copy all files except that was created today? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment