Thursday, April 2, 2009

CREATE A BATCH FILE TO TAKE DAILY BACKUP

Daily backup for a selected folder or file...
this batch file wil create a new folder with curent date automaticaly....

how to create a batch file...
1. open a notepad file
2. copy the entir contnt which 1 i hd givn below
3. save the file with extensn (.bat) ex..(new backup.bat)

@echo off
:: variables
set drive= E:\DAILY BACKUPS\MY DATA
set folder=%date:~0,2%-%date:~3,2%-%date:~6,4%
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ######## PLEASE WAIT SYSTEM BACKINGUP SOME DATA########...
%backupcmd% "E:\calseadata" "%drive%\%FOLDER%"

echo !!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!
@pause


1. RED color for (which folder u want to take backup)
2. GREEN color for (where u want to save the backup)

15 comments:

sivashankar said...

Thank you,

Its working...!

Anonymous said...

I think it's better to use Dr.Batcher ( http://www.drbatcher.com ). It offers special wizard to create backups with help of batch files. It works quite fine.

Anonymous said...

nice sharing..

Tech Tips & Tricks - computer internet how-to guides

Unknown said...


attractive piece of information, I had come to know about your blog from my friend arjun, ahmedabad,i have read atleast eleven posts of yours by now, and let me tell you, your website gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanks a lot once again, Regards, How to create batch file


Unknown said...

Unfortunately, it's not working.
I copied the whole source code.
@echo off
:: variables
set drive= D:\SVN\Repositories
set folder=%date:~0,2%-%date:~3,2%-%date:~6,4%
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ######## PLEASE WAIT SYSTEM BACKINGUP SOME DATA########...
%backupcmd% "D:\SVN\DailyBackup\" "%drive%\%FOLDER%"

echo !!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!
@pause
Could you write me where I did wrong?

Mike said...

I have fixed the script. this should work.
replace value of SRCFOLDER and DESTFOLDER.

@echo on

:: variables

set SRCFOLDER=C:\SOURCEFOLDER
set DESTFOLDER=c:\DESTFOLDER
set folder=%date:~5,2%-%date:~8,2%-%date:~0,4%

set backupcmd= /I /E /H /Y




echo ######## PLEASE WAIT SYSTEM BACKINGUP SOME DATA########...
xcopy "%SRCFOLDER%" "%
DESTFOLDER%" %backupcmd%

echo !!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!!!!!!!
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

S(you)NNY said...

final script (with SRCFOLDER and DESTFOLDER) is working fine.

could this be automated without using task scheduler?

Unknown said...

Mega is cloud storage that provides you online memory area that helps you to save or share your file, images and videos easily. Using these types of service you can easily backup your file, image and videos online.

Unknown said...

thanks friends..I have a doubt.this method will work in linux os????
I have tried but nothing happened in the destination folder.I'm using centos 6.6

Unknown said...

how to backup extension like *.dbf or *.fpt any idea. im using cmd + 7-zip.

Indian-Traveller said...

Its not working with share folder i want transfer the local data to network folder

Unknown said...

Ans:
*.dbf or *.ftp extension daily backup
It is a Batch file coding:

E:
CD E:\JENSON\JOHN
MD E:\Dailybackup\
LHA A mydata *.DBF *.FPT
COPY mydata.LZH E:\Dailybackup\
@rem *********************** Create file ***************************
:create
@rem Create file name
echo Backup Time : %time% %date%>> E:\JENSON\JOHN\log.txt
Echo============Result=============
Echo The Data Successfully copied
Echo===============================
Echo off

Unknown said...

Hai mike,

i tried your codes as below,

@echo on

:: variables

set SRCFOLDER= C:\menhali2
set DESTFOLDER= c:\backup
set folder=%date:~5,2%-%date:~8,2%-%date:~0,4%

set backupcmd= /I /E /H /Y




echo ######## PLEASE WAIT SYSTEM BACKINGUP SOME DATA########...
xcopy "%SRCFOLDER%" "%
DESTFOLDER%" %backupcmd%

echo !!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!!!!!!!
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

GETTING ERROR, COULD YOU PLEASE RECTIFY IT






Naveen Kongati said...

Thanks for your support. Your script is not solving my problem which is as I would like to copy certain folders into a External Hard Disk. I have tried changing source and destination folders but it did not work. Can you give me a new script to resolve this issue.

Rahu said...

I need to insert the perl script (.pl) to run and in batch file ?

How we can do for perl script using batch file...?