BackUp Data | Periodic Offline Backup With a Click | Windows | DOS

How to create a batch file in Windows/DOS and run the file to create a new backup or update previous backup with a simple click

Steps

  • Using any editor create a file with “BAT” extension e.g. “backup.bat”
  • Type the following example script (replace file & paths as per your requirement) and save.
  • Run the file anytime to take or update backup of any drive/folder/file

Code

REM === MY PERIODIC BACKUP ===
xcopy/E/D/Y/R/I “C:\Document” “D:\WorkDocument”
xcopy/E/D/Y/R/I “D:\Music” “E:\MyMusic”

Explanation 

XCOPY – is the command

C:\Document” – Is the Source (from where to copy) – Need to change with your source
D:\WorkDocument” – Is the Destination (to where to paste) – Need to change with your destination

NOTE – Add a line of command for each source

Arguments (optional)

/E - Copies directories and sub-directories, including empty ones.
/D - Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
/Y - Suppresses prompting to confirm you want to overwrite an
existing destination file.
/R - Overwrites read-only files.
/I - If destination does not exist and copying more than one file,
assumes that destination must be a directory; and creates it.

NOTE – In general all will be needed; but feel free to omit as per your requirement.

Leave a Reply

Your email address will not be published. Required fields are marked *