Sunday, June 4, 2017

backup - Best language/system to auto-batch copy files & dir's with file rename in Windows 8/10?


Robocopy came so close, but is missing file rename on copy. So could people please direct me to a language or system in Windows that would be well suited to the following :


This is meant to be a simple, basic, back-up plan for a home network with a few Win8/10 laptops & PCs and a central network drive (a USB external drive atached to the router's USB port). Almost all files to be backed up are images or video or music - so already compressed, so there's no point using a commercial backup software with compression. Also, I don't want my files encapsulated in a proprietary backup file format. I just need copies.


I'm imagining a command shell batch file, or VBScript, or.....


The ideal system would allow me to program scheduled backups of selected folders (including all their subfolders) on the computers to their respective folders on the network drive. After an initial full backup of each, the system would perform incremental backups. These incremental backups would really just be to make a copy of any new file, and make a new copy with an indexed filename of any file that has changed since the last backup. That's it.


As I said, Robocopy in a batch file came close, but can't rename files. I don't want to create new folders with indexed names - I want the renamed files in the original folders all together.


I could spend months surveying and learning every possible Windows command and system that exist in hopes of finding something that will do this. I've already spent days researching backup software and Robocopy. So I was hoping this board could just point me in the right direction of something that has the necessary commands and functions to do it.


Thanks.


Answer




After an initial full backup of each



This sounds like an ideal situation for robocopy; it sounds like you're getting hung up on this:



..incremental backups would really just be to make a copy of any new file, and make a new copy with an indexed filename of any file that has changed since the last backup.



To handle that situation I would use FC in a loop to compare a file if it exists in the full backup, and if it does, individually copy it over and include your modified name.




So to set this up, I would determine:



  1. how often you want to do your full backup and whether or not it should erase contents that no longer exist in the source folder and

  2. how often you'd like to do your incremental backups, if not manually.


In both cases, I would likely setup a Scheduled Task in Windows to run the batch file needed. The complexity of either script is going to be determined by your directory structure, but for the most part this is sort of what your incremental backup logic would look like:


@echo off
set "dir=C:\Your\Directory"
set "bkp=N:\Your\Backup\Drive"
for %%A in (%dir%\*) do (
if exist "%bkp%\%%~nxA" (
fc "%%A" "%bkp%\%%~nxA"
if %ERRORLEVEL% EQU 1 (copy /y "%%A" "%bkp%\%%~nA MODIFIED%%~xA")
)
)
)

You can use parameter extensions and different for options to customize the loop based on how your directories are setup. If you don't want to delete anything via robocopy you just use robocopy "source" "destination" /e - you can also loop the robocopy with for to do individual folders at a time as opposed to your root directory - that way you can generate a log file for each one if you're looking to have more granular visibility.


Reference: robocopy, fc, for, copy, parameters


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...