File History is not backing up my work

Page 2 of 2 FirstFirst 12

  1. Posts : 7,607
    Windows 10 Home 20H2
       #11

    perkinw said:
    Yes, that is insurance against accidental deletion of a file. File History gives you that insurance.
    The following command gives you that insurance too.

    Xcopy /E /D /Y "D:\Source folder" "E:\Destination folder"

    It will not delete files from "E:\Destination folder".
    It is also a built-in tool: C:\Windows\system32\xcopy.exe
      My Computer


  2. Posts : 31,663
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #12

    Matthew Wai said:
    The following command gives you that insurance too.

    Xcopy /E /D /Y "D:\Source folder" "E:\Destination folder"

    It will not delete files from "E:\Destination folder".


    Unfortunately it will overwrite an older version of a file in the destination folder with the latest one from the source. The OP needs to keep older versions in case of errors in the new one. File History has the ability to restore previous versions.

    But you're on the right track. XCopy can be useful, particularly its /M option which only copies files with the Archive attribute set, then clears the Archive attribute. This ensure that only modified files will be copied. The /S option will copy subdirectories too, but not if they're empty.

    What we need to mimic File History is to keep multiple copies in the destination folder, each under a folder with a date stamp of the time the backup was made. That's a little more complicated than a single command line and need a batch file to do it. Here's one (with help on generating the date stamp from Stack Overflow)

    Code:
    @echo off
    for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
    set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
    set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
    
    set "datestamp=%YYYY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%"
    set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
    echo datestamp: "%datestamp%"
    echo timestamp: "%timestamp%"
    echo fullstamp: "%fullstamp%"
    pause
    mkdir "D:\Destination_Folder\%fullstamp%"
    XCopy Source_Folder\*.* "D:\Destination_Folder\%fullstamp%" /S /M


    Saved as XCopy_File_History.bat it works like this...

    File History is not backing up my work-image.png

    ..and results in this.

    File History is not backing up my work-image.png
      My Computers


  3. Posts : 7,607
    Windows 10 Home 20H2
       #13

    Bree said:
    Saved as XCopy_File_History.bat it works like this...
    It will create an empty backup folder if no files in "\Source_Folder\" have been modified. Adding the following line at the bottom will remove such an empty folder.

    rmdir "D:\Destination_Folder\%fullstamp%"
      My Computer


  4. Posts : 31,663
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #14

    Matthew Wai said:
    It will create an empty backup folder if no files in "\Source_Folder" have been modified. Adding the following line at the bottom will remove such an empty folder.

    rmdir "D:\Destination_Folder\%fullstamp%"
    Good addition.

    If the backup folder is empty it will just delete it without any message. If it has anything in it the message 'The directory is not empty.' will appear beneath the list of file(s) copied.
      My Computers


  5. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #15

    Bree said:
    Good addition.

    If the backup folder is empty it will just delete it without any message. If it has anything in it the message 'The directory is not empty.' will appear beneath the list of file(s) copied.
    How about? rmdir "D:\Destination_Folder\%fullstamp%" >nul 2>&1
    You could also use an If...Else statement.
      My Computer


  6. Posts : 7,607
    Windows 10 Home 20H2
       #16

    The batch script can be run in the background via VBScript. You will not see a window.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 08:23.
Find Us




Windows 10 Forums