{"id":427,"date":"2007-05-09T07:54:24","date_gmt":"2007-05-09T12:54:24","guid":{"rendered":"http:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script"},"modified":"2007-05-17T09:33:38","modified_gmt":"2007-05-17T14:33:38","slug":"create-a-windows-daily-backup-script","status":"publish","type":"post","link":"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script","title":{"rendered":"Create a Windows Daily Backup Script"},"content":{"rendered":"

This tutorial will show you how to use a simple Windows Batch file and the task scheduler to create an automated daily backup. We will use the date variable to backup the files into folders with the first three letters of the day as the folder name.<\/p>\n

First you will need to open notepad. The easiest way is going to start > run and typing notepad.
\nCreate a Windows Daily Backup Script<\/p>\n

We will use notepad to create are batch file. A windows batch file is a set of instructions that tells the computer what to do. All we really need to do is add the command to copy the folder that we want to backup. I have a folder called \u2018test\u2019 that I want to backup to a folder called \u2018backup on a network drive which I have mapped as the x drive. It only takes one simple command to do that actual backup. (note: there is no | in the command next the the word date, that is just the cursors)
\nCreate a Windows Daily Backup Script<\/p>\n

Now I will explain the command \u201cxcopy c:\\test\\* x:\\backup\\%date:~0,3%\\* \/Y \/Q \/S\u201d<\/p>\n

The xcopy commands will copy files and folders. The syntax for the command is xcopy [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 wouldn\u2019t be automated. \/Q doesn\u2019t 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 \/?.<\/p>\n

Where you see \\%date:~0,3%\\ is the name of the destination folder. If you didn\u2019t want to change the name daily you could simple call it \\backup\\ or something like that. The %date% is a variable. If you type %date at the command line, you will get the current date and time output. The :~0,3 tells the command line to return the first three letters of that date (0-3) and trim off the rest. <\/p>\n

Once you have made the changes that you nee, save the file as backup.bat
\nCreate a Windows Daily Backup Script<\/p>\n

Now Open the Control Panel and select Scheduled Tasks
\nCreate a Windows Daily Backup Script<\/p>\n

Now we want to add a new task so click the \u201cAdd Scheduled Task\u201d button.
\nCreate a Windows Daily Backup Script<\/p>\n

Click next and then browse. Locate the backup script you just saved and click open.
\nCreate a Windows Daily Backup Script<\/p>\n

Select perform this action daily and then click the next button.
\nCreate a Windows Daily Backup Script<\/p>\n

Select enter the time you want the task to run at in the start time box. Then make sure daily is selected and change the date to the day you would like this task to start running on.
\nCreate a Windows Daily Backup Script<\/p>\n

Enter your password and click next. (note: if you do not have a password, you may have problems with the scheduled tasks running correctly. I recommend adding a password to your account, or setting up a separate account to run scripts.)
\nCreate a Windows Daily Backup Script<\/p>\n

Click finish. Now we can test the backup script. Located the script in the scheduled tasks folder, Right click it and select run.
\nCreate a Windows Daily Backup Script<\/p>\n

You should see the command window open. When the task is finished, browse to your backup folder and verify that the files have been copied.
\nCreate a Windows Daily Backup Script<\/p>\n

This is a very basic idea of how to use the task scheduler and batch files to make backups.<\/p>\n","protected":false},"excerpt":{"rendered":"

This tutorial will show you how to use a simple Windows Batch file and the task scheduler to create an automated daily backup. We will use the date variable to backup the files into folders with the first three letters of the day as the folder name.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[15,12],"tags":[],"yoast_head":"\nCreate a Windows Daily Backup Script<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to use a simple Windows Batch file and the task scheduler to create an automated daily backup. We will use the date variable to backup the files into folders with the first three letters of the day as the folder name.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Johnathan Ward\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/teamtutorials.com\/#website\",\"url\":\"https:\/\/teamtutorials.com\/\",\"name\":\"Team Tutorials\",\"description\":\"Learn something new today\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/teamtutorials.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/teamtutorials.com\/wp-content\/uploads\/2007\/05\/windows-daily-backup-script-tutorial-01.jpg\",\"contentUrl\":\"http:\/\/teamtutorials.com\/wp-content\/uploads\/2007\/05\/windows-daily-backup-script-tutorial-01.jpg\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script#webpage\",\"url\":\"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script\",\"name\":\"Create a Windows Daily Backup Script\",\"isPartOf\":{\"@id\":\"https:\/\/teamtutorials.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script#primaryimage\"},\"datePublished\":\"2007-05-09T12:54:24+00:00\",\"dateModified\":\"2007-05-17T14:33:38+00:00\",\"author\":{\"@id\":\"https:\/\/teamtutorials.com\/#\/schema\/person\/3abea1fc71644afe035403357450b9d9\"},\"description\":\"This tutorial will show you how to use a simple Windows Batch file and the task scheduler to create an automated daily backup. We will use the date variable to backup the files into folders with the first three letters of the day as the folder name.\",\"breadcrumb\":{\"@id\":\"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/teamtutorials.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create a Windows Daily Backup Script\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/teamtutorials.com\/#\/schema\/person\/3abea1fc71644afe035403357450b9d9\",\"name\":\"Johnathan Ward\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/teamtutorials.com\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/93d667fe5dc6df5c722e0df5eac14d40?s=96&d=mm&r=r\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/93d667fe5dc6df5c722e0df5eac14d40?s=96&d=mm&r=r\",\"caption\":\"Johnathan Ward\"},\"description\":\"Johnathan Ward is an experienced developer and consultant that writes tutorials to help other developers. In his day job, he is an IBM Watson Consultant with several years of experience deploying and customizing Watson Explorer solutions.\",\"sameAs\":[\"http:\/\/johnathanward.com\",\"https:\/\/twitter.com\/spyderman4g63\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create a Windows Daily Backup Script","description":"This tutorial will show you how to use a simple Windows Batch file and the task scheduler to create an automated daily backup. We will use the date variable to backup the files into folders with the first three letters of the day as the folder name.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script","twitter_misc":{"Written by":"Johnathan Ward","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/teamtutorials.com\/#website","url":"https:\/\/teamtutorials.com\/","name":"Team Tutorials","description":"Learn something new today","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/teamtutorials.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script#primaryimage","inLanguage":"en-US","url":"http:\/\/teamtutorials.com\/wp-content\/uploads\/2007\/05\/windows-daily-backup-script-tutorial-01.jpg","contentUrl":"http:\/\/teamtutorials.com\/wp-content\/uploads\/2007\/05\/windows-daily-backup-script-tutorial-01.jpg"},{"@type":"WebPage","@id":"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script#webpage","url":"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script","name":"Create a Windows Daily Backup Script","isPartOf":{"@id":"https:\/\/teamtutorials.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script#primaryimage"},"datePublished":"2007-05-09T12:54:24+00:00","dateModified":"2007-05-17T14:33:38+00:00","author":{"@id":"https:\/\/teamtutorials.com\/#\/schema\/person\/3abea1fc71644afe035403357450b9d9"},"description":"This tutorial will show you how to use a simple Windows Batch file and the task scheduler to create an automated daily backup. We will use the date variable to backup the files into folders with the first three letters of the day as the folder name.","breadcrumb":{"@id":"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/teamtutorials.com\/windows-tutorials\/create-a-windows-daily-backup-script#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/teamtutorials.com\/"},{"@type":"ListItem","position":2,"name":"Create a Windows Daily Backup Script"}]},{"@type":"Person","@id":"https:\/\/teamtutorials.com\/#\/schema\/person\/3abea1fc71644afe035403357450b9d9","name":"Johnathan Ward","image":{"@type":"ImageObject","@id":"https:\/\/teamtutorials.com\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/93d667fe5dc6df5c722e0df5eac14d40?s=96&d=mm&r=r","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/93d667fe5dc6df5c722e0df5eac14d40?s=96&d=mm&r=r","caption":"Johnathan Ward"},"description":"Johnathan Ward is an experienced developer and consultant that writes tutorials to help other developers. In his day job, he is an IBM Watson Consultant with several years of experience deploying and customizing Watson Explorer solutions.","sameAs":["http:\/\/johnathanward.com","https:\/\/twitter.com\/spyderman4g63"]}]}},"_links":{"self":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/posts\/427"}],"collection":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/comments?post=427"}],"version-history":[{"count":0,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/posts\/427\/revisions"}],"wp:attachment":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/media?parent=427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/categories?post=427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/tags?post=427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}