[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

i need to write a script to copy backup data to a netwrok share day per day

hi guys,
i want to write a script that copies data from a specific directory in windows to a directory in a network share.and i want the script run daily(could be dne with task scheduler) but i need the copies to be named as the per the the date that it was taken. i hope i was clear in my request.Does anyone have a sample or template that i can use it have this script.thank to you all
1 Solution

"xcopy c:\data\* f:\backup\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup\* /Y /Q /S" This is simple Windows Batch file and the task scheduler to create an automated daily backup.
 Save this command in notepad & save as backup.bat file.
 In this the xcopy commands will copy files and folders. The syntax for the command is xcopy [source] [destination] [arguments]. Where source is the folder that you want to backup and destination is the backup on the network drive. The arguments tell xcopy how to handle certain situations. For my script I used /Y to suppress prompting when overwriting files. If you do not include this the script will ask you before copying each file, that wouldnt be automated. /Q doesnt display the file names while copying. /S copies directories and sub directories. You can find more arguments by opening the command windows and typing xcopy /?.
%date:~10,4%_%date:~4,2%_%date:~7,2%_backup will create folder with current date.

kadadi_vIT AdminCommented:
Start>run>ntbackup and use the backup wizard as per your requirement daily/weekly & monthly basis.


Vijay kadadi
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

sparks2000Author Commented:
dear srawale,
i did not get what are the 4,2%...and all the percentages .any way it did not work, it gave me anneror so i had to remove them.can u send it again please??
hi Sparks

Rename this file as .txt to .bat  change folder name as your requirment.

sparks2000Author Commented:
when i run the script :xcopy c:\dell\* d:\backup\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup\* /Y /Q /S

it gave me this message:
Invalid switch - /_00_backup\*

xcopy c:\dell\* d:\backup\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup\* /Y /Q /S

In this script all data of c:\dell folder will copied to d:\backup folder with current year_current month_current date_backup folder in short script will create the destination folder as d:\backup\2008_02_06_backup.

  You cross check the command again. as per my eariler attachment.

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now