0

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.

1
  • I usually just try to get the basic answer out quickly then flesh it out through edits. so yes - I recommend robocopy /e for your full backups and a looping if exist, compare (fc), copy for the incremental stuff. You can check out the updated answer and see if any of this is usable to you.
    – mael'
    Commented Jul 25, 2019 at 18:48

1 Answer 1

1

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

4
  • Yes, the initial backup is ideal for robocopy. It's the incrementals that are problematic. Just looked up FC command. I don't see where it can just check for files with the same name? But that lead me too IF EXISTS - I suppose I could recursively loop through a specified folder's subfolders.
    – Jim_1234
    Commented Jul 25, 2019 at 18:33
  • 1. Never erase, ever. 2. Yes, to be set in a Scheduled Task - probably weekly.
    – Jim_1234
    Commented Jul 25, 2019 at 18:33
  • Well thank you for such an in-depth answer. Had not expected anyone to actually start programming a solution - but there is proof of concept that a command shell script actually can do it. I'll delve into it.
    – Jim_1234
    Commented Jul 26, 2019 at 1:52
  • @jim it’s no problem; good luck and have fun with it
    – mael'
    Commented Jul 26, 2019 at 11:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .