Jump to content

Batch File That Copies 1 Drive to Another

AverageHardware

Hello,

 

I want to use Task Scheduler to automatically run a script that clones my F drive to my G drive at a specified time.

I'd like, if possible, to do differential backups(meaning it only backs up what has changed since the last backup). I'd also like a log if possible, retry if file fails to copy, etc. I was looking at robocopy. Any suggestions? Using Windows 10.

i7 4790k | GTX 970 | 16GB

That's all you need to know. It's a beast.

 

Link to comment
Share on other sites

Link to post
Share on other sites

how about windows backup...

lol

NEW PC build: Blank Heaven   minimalist white and black PC     Old S340 build log "White Heaven"        The "LIGHTCANON" flashlight build log        Project AntiRoll (prototype)        Custom speaker project

Spoiler

Ryzen 3950X | AMD Vega Frontier Edition | ASUS X570 Pro WS | Corsair Vengeance LPX 64GB | NZXT H500 | Seasonic Prime Fanless TX-700 | Custom loop | Coolermaster SK630 White | Logitech MX Master 2S | Samsung 980 Pro 1TB + 970 Pro 512GB | Samsung 58" 4k TV | Scarlett 2i4 | 2x AT2020

 

Link to comment
Share on other sites

Link to post
Share on other sites

how about windows backup...

lol

because eww Windows Backup.

i7 4790k | GTX 970 | 16GB

That's all you need to know. It's a beast.

 

Link to comment
Share on other sites

Link to post
Share on other sites

because eww Windows Backup.

...and your reason is...?

 

it works, and it does what you want, and you can schedule it, and you can choose what files to back up, etc.

NEW PC build: Blank Heaven   minimalist white and black PC     Old S340 build log "White Heaven"        The "LIGHTCANON" flashlight build log        Project AntiRoll (prototype)        Custom speaker project

Spoiler

Ryzen 3950X | AMD Vega Frontier Edition | ASUS X570 Pro WS | Corsair Vengeance LPX 64GB | NZXT H500 | Seasonic Prime Fanless TX-700 | Custom loop | Coolermaster SK630 White | Logitech MX Master 2S | Samsung 980 Pro 1TB + 970 Pro 512GB | Samsung 58" 4k TV | Scarlett 2i4 | 2x AT2020

 

Link to comment
Share on other sites

Link to post
Share on other sites

@AverageHardware Windows 10 is pretty good. I mean... Windows Defender is good?!! So why not give Windows backup a chance? 

CPU: i5 4670k @ 3.4GHz + Corsair H100i      GPU: Gigabyte GTX 680 SOC (+215 Core|+162 Mem)     SSD: Kingston V300 240GB (OS)      Headset: Logitech G930 

Case: Cosair Vengance C70 (white)                RAM: 16GB TeamGroup Elite Black DDR3 1600MHz       HDD: 1TB WD Blue                              Mouse: Logitech G602

OS: Windows 7 Home Premium                       PSUXFX Core Edition 750w                                                Motherboard: MSI Z97-G45               Keyboard: Logitech G510

Link to comment
Share on other sites

Link to post
Share on other sites

Hello,

 

I want to use Task Scheduler to automatically run a script that clones my F drive to my G drive at a specified time.

I'd like, if possible, to do differential backups(meaning it only backs up what has changed since the last backup). I'd also like a log if possible, retry if file fails to copy, etc. I was looking at robocopy. Any suggestions? Using Windows 10.

 

Robocopy is the way to go:

robocopy "f:\" "g:\f-backup" /mir /Z /r:1 /log+:c:\logs\f-backup.txt
  • Will mirror f:\ to "g:\f-backup" >> "f:\" "g:\f-backup" /mir
  • Will resume large files if connection is lost mid-stream >> /Z
  • Will retry once if it fails after waiting 30 seconds >> /r:1
  • Will log to c:\logs\f-backup.txt >> /log+:c:\backup\logs\f-backup.txt

Put that in a bat file in c:\backup and create a task to run daily and invoke that batch file OR you can invoke robocopy directly:

 

fkmUJLp.png

Link to comment
Share on other sites

Link to post
Share on other sites

For this kind of thing I suggest to use PowerShell scripts, way more powerful than batch. You can use .NET libraries to do directory scans and other useful stuff for automation and you could script some extra features in that you could not do with cmd.

 

EDIT:

For example if you are doing backups, you could script into a feature that will only copy changed files, like a version control of sorts, that way you can save space, and use another script to 'collect' the complete file set (maybe even by date). The ultimate backup script IMO.

 

EDIT EDIT:

Turns out that's exactly you want to do lol.

Link to comment
Share on other sites

Link to post
Share on other sites

I second Robocopy.  It is so good at the one thing it does (copy files) people still use it in the server room.

Fractal Design Define R5 | i7-4790k | Corsair H80 | Asus Z97-Pro WiFi | 2 x EVGA GTX 970 SSC+ | 16GB G.Skill Sniper@1866MHz | Samsung 840 Evo 256 GB | 1TB + 750GB drives | EVGA 750W G2 | 27" BenQ IPS 1440p@60Hz | Windows 10

Link to comment
Share on other sites

Link to post
Share on other sites

For this kind of thing I suggest to use PowerShell scripts, way more powerful than batch. You can use .NET libraries to do directory scans and other useful stuff for automation and you could script some extra features in that you could not do with cmd.

 

EDIT:

For example if you are doing backups, you could script into a feature that will only copy changed files, like a version control of sorts, that way you can save space, and use another script to 'collect' the complete file set (maybe even by date). The ultimate backup script IMO.

 

EDIT EDIT:

Turns out that's exactly you want to do lol.

While powershell gets me hard also, let's not re-invent the wheel here. As others have mentioned robocopy is the way to go, unless you are looking for a more robust archival/back-up solution. (which to be honest, if robocopy could manage a tape library, i'd be fine with using it).

Link to comment
Share on other sites

Link to post
Share on other sites

...and your reason is...?

 

it works, and it does what you want, and you can schedule it, and you can choose what files to back up, etc.

Issue is that windows backup was removed from windows 8.1+ (heck they called it windows 7 backup in windows 8.0). They do have File history, or full system images now. I'd recommend using either robocopy or something to interface with VSS.

Link to comment
Share on other sites

Link to post
Share on other sites

Issue is that windows backup was removed from windows 8.1+ (heck they called it windows 7 backup in windows 8.0). They do have File history, or full system images now. I'd recommend using either robocopy or something to interface with VSS.

oh did they really

 

what is this then

Windows-10-Build-9901-Features-New-Cloud

"local backup"

NEW PC build: Blank Heaven   minimalist white and black PC     Old S340 build log "White Heaven"        The "LIGHTCANON" flashlight build log        Project AntiRoll (prototype)        Custom speaker project

Spoiler

Ryzen 3950X | AMD Vega Frontier Edition | ASUS X570 Pro WS | Corsair Vengeance LPX 64GB | NZXT H500 | Seasonic Prime Fanless TX-700 | Custom loop | Coolermaster SK630 White | Logitech MX Master 2S | Samsung 980 Pro 1TB + 970 Pro 512GB | Samsung 58" 4k TV | Scarlett 2i4 | 2x AT2020

 

Link to comment
Share on other sites

Link to post
Share on other sites

oh did they really

 

what is this then

Windows-10-Build-9901-Features-New-Cloud

"local backup"

a2c68d48-827b-4641-a415-6d07babf724d_38.

Your referring to file history.

 

Windows 7 Backup and restore will let you continue backing up if you had a previously configured backup, otherwise nope. Keep in mind this info is from my back when I did my MCSA windows 8.0/8.1/2012/2012R2 If they have brought it back that'd be great (I still wouldn't use it).

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×