[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 319
  • Last Modified:

Backup a folder with a bat file

Hi,

I have a folder which i need to backup every 1 hr.The folder has many folders and files in it.When it backup to the location it has to create a folder with the current date and time and then copy the contents to the folder.

Regards
Sharath
0
bsharath
Asked:
bsharath
  • 3
  • 2
  • 2
  • +1
1 Solution
 
kamalgopiCommented:
just see the info below. and copy the command to a text file and then change it to .bat and then use the schecdule task to do a recusrsive run of the file every one hour.

Hope this helps
CHeers:)
Kamal
0
 
kamalgopiCommented:
Forgot to post the link
http://www.computerhope.com/issues/ch000766.htm

Cheers:)
Kamal
0
 
bsharathAuthor Commented:
In the list you specified the folders which should be created on each hr which has to be the date and time  is not mentioned
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
kamalgopiCommented:
i am not sure how to do that. but the link below is the software can do that but it cannot automate .
http://www.filedudes.com/SafeCopy_Free_-download-34151.html.

Cheers:)
Kamal
0
 
Farhan KaziSystems EngineerCommented:
:: * You need to set two variables 'SFolder'and 'TFolder' inside the script
::   SET SFolder=C:\MyFiles       <- Source Folder
::   SET TFolder=E:\Backup        <- Target Folder
:: * Copy and paste following script in notepad and save it with any name having .cmd extension

:: *** SCRIPT START ***
@Echo Off
SETLOCAL

SET SFolder=C:\MyFiles  
SET TFolder=E:\Backup

SET BackupCmd=XCopy /s /c /d /e /h /i /r /k /y
SET M=%DATE:~4,2%
SET D=%DATE:~7,2%
SET Y=%DATE:~10,4%
SET DName=%D%_%M%_%Y%

SET Hour=%time:~0,2%
IF "%Hour:~0,1%"==" " set Hour=0%Time:~1,1%
SET DFolder=%DName%_%Hour%_%Time:~3,2%

Echo %DFolder%
%BackupCmd% "%SFolder%" "%TFolder%\%DFolder%\"
Echo.
Echo Backup Complete!
Echo.
ENDLOCAL
:: *** SCRIPT END ***
0
 
bsharathAuthor Commented:
Thanks.

I get the folder name as this.

27_07_2007_11_00

Any way to change the format to 27-07-2007_ 11.00 AM or PM
0
 
Farhan KaziSystems EngineerCommented:
:: * You need to set two variables 'SFolder'and 'TFolder' inside the script
::   SET SFolder=C:\MyFiles       <- Source Folder
::   SET TFolder=E:\Backup        <- Target Folder
:: * Copy and paste following script in notepad and save it with any name having .cmd extension
:: *** SCRIPT START ***

@Echo Off
SETLOCAL

SET SFolder=C:\MyFiles
SET TFolder=E:\Backup

SET BackupCmd=XCopy /s /c /d /e /h /i /r /k /y
SET M=%DATE:~4,2%
SET D=%DATE:~7,2%
SET Y=%DATE:~10,4%
SET DName=%D%-%M%-%Y%
SET Hour=%time:~0,2%
SET AMPM=AM

IF "%Hour:~0,1%"==" " set Hour=0%Time:~1,1%
Time /T | Find "a" >NUL
IF ErrorLevel 1 SET AMPM=PM
SET DFolder=%DName%_%Hour%.%Time:~3,2%.%AMPM%
%BackupCmd% "%SFolder%" "%TFolder%\%DFolder%\"
Echo.
Echo Backup Complete!
Echo.
ENDLOCAL
:: *** SCRIPT END ***
0
 
Expert4XPCommented:
A free (for personal use) program that will append date/time to folders is Replicator.  I've used it in the past to create a 7-day rolling backup.  It's very flexible and automatic.

http://www.karenware.com/powertools/ptreplicator.asp

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now