Drive Snapshot

Discussion in 'backup, imaging & disk mgmt' started by Hadron, Nov 11, 2019.

  1. Hadron

    Hadron Registered Member

    Joined:
    Apr 1, 2014
    Posts:
    1,395
    I am using Drive Snaphot with scripts, and have found it to be very reliable.

    The help page here has a "Date" command line string, but I cannot see a "Time" string.
    A "Time" string would make it very simple to be able to do more than one backup in a day.

    Is it just that the help page hasn't been updated, or isn't there a "Time" string?
    Below is what I found on the website.

     
  2. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,370
    Location:
    NSW, Australia
    Hadron, you could adapt this...

    Code:
    @echo off
    CD /d %~dp0
    set hh=%time:~0,2%
    if "%time:~0,1%"==" " set hh=0%hh:~1,1%
    set timestamp=%time:~0,8%
    if @%timestamp:~0,1% == @ set timestamp=0%timestamp:~1,7%
    set timestamp=%date:.=%_%timestamp::=%
    echo.Timestamp :: %timestamp%
    ren hadron-C.sna hadron-C-%timestamp%.sna
    
    The output is (time = hhmmss)...

    hadron-C-2019-Nov-11_181335.sna
     
  3. Hadron

    Hadron Registered Member

    Joined:
    Apr 1, 2014
    Posts:
    1,395
    Hi Brian.

    I currently use this.
    Code:
    @echo off
    CD /d %~dp0
    if not defined RunTask set RunTask=1 & start "Snapshot" /min %SystemRoot%\system32\cmd.exe /c "%0" & goto :EOF
    snapshot64.exe HD1:* "D:\System_Backup\Drive_Snapshot\$DISK-$DATE.sna" -o -L0 --UseVSS
    exit


    Would this work?
    Code:
    @echo off
    CD /d %~dp0
    if not defined RunTask set RunTask=1 & start "Snapshot" /min %SystemRoot%\system32\cmd.exe /c "%0" & goto :EOF
    snapshot64.exe HD1:* "D:\System_Backup\Drive_Snapshot\$DISK-$DATE-$TIME.sna" -o -L0 --UseVSS
    exit
    Also, what is HD1:* denoting?
     
  4. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,370
    Location:
    NSW, Australia
    $TIME isn't a DS variable.

    HD1:* is an Entire Disk backup for DS HD1.

    Change $DISK-$DATE-$TIME.sna to EntireHD1.sna

    Code:
    @echo off
    CD /d %~dp0
    if not defined RunTask set RunTask=1 & start "Snapshot" /min %SystemRoot%\system32\cmd.exe /c "%0" & goto :EOF
    snapshot64.exe HD1:* "D:\System_Backup\Drive_Snapshot\EntireHD1.sna" -o -L0 --UseVSS
    
    CD /d D:\System_Backup\Drive_Snapshot
    
    set hh=%time:~0,2%
    if "%time:~0,1%"==" " set hh=0%hh:~1,1%
    set timestamp=%time:~0,8%
    if @%timestamp:~0,1% == @ set timestamp=0%timestamp:~1,7%
    set timestamp=%date:.=%_%timestamp::=%
    echo.Timestamp :: %timestamp%
    ren EntireHD1.sna EntireHD1-%timestamp%.sna
    
    
    In Control Panel, Region, must have yyyy-MMM-dd, not yyyy/MMM/dd for the Short date.

    Edit... added... CD /d D:\System_Backup\Drive_Snapshot
     
    Last edited: Nov 12, 2019
  5. Hadron

    Hadron Registered Member

    Joined:
    Apr 1, 2014
    Posts:
    1,395
    Thanks for the reply, Brian.

    OK. Regarding HD1:*, I was looking at my SSD in Diskpart. I couldn't remember about that. :argh:

    Regarding adding the time, is that my only option?
     
  6. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,370
    Location:
    NSW, Australia
    The script works fine. Just tested it. Let me know if you see a "press any key". Your file will be...

    EntireHD1-2019-Nov-11_181335.sna
     
  7. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,370
    Location:
    NSW, Australia
    Apologies. I was testing partition backups and you want Disk backups. How many partitions are on your DS HD1?
     
  8. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,370
    Location:
    NSW, Australia
    This should work for DS HD1

    Code:
    @echo off
    CD /d %~dp0
    if not defined RunTask set RunTask=1 & start "Snapshot" /min %SystemRoot%\system32\cmd.exe /c "%0" & goto :EOF
    snapshot64.exe HD1:* "D:\System_Backup\Drive_Snapshot\$DISK.sna" -o -L0 --UseVSS -W
    
    CD /d D:\System_Backup\Drive_Snapshot
    
    :: +++++++++  Move all .sna to another folder  +++++++++
    set hh=%time:~0,2%
    if "%time:~0,1%"==" " set hh=0%hh:~1,1%
    set timestamp=%time:~0,8%
    if @%timestamp:~0,1% == @ set timestamp=0%timestamp:~1,7%
    set timestamp=%date:.=%_%timestamp::=%
    echo.Timestamp :: %timestamp%
    MD %timestamp%
    MOVE *.sna %timestamp%
    
    exit
     
  9. Hadron

    Hadron Registered Member

    Joined:
    Apr 1, 2014
    Posts:
    1,395
    My OS drive, which is 0 has three partitions. System Reserved | OS | Recovery.
     
  10. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,370
    Location:
    NSW, Australia
    Thanks.

    I used a similar script several months ago on my test computer. The DS backups go to a date/time folder. Worked fine.

    As you have found, Windows Disk 0 is DS HD1.
     
  11. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,370
    Location:
    NSW, Australia
    Hadron, I'd be grateful if you could try the above script. Just once. I like it.
     
  12. Hadron

    Hadron Registered Member

    Joined:
    Apr 1, 2014
    Posts:
    1,395
    I will do. Do I still have to change my Windows date format first?
     
  13. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,370
    Location:
    NSW, Australia
    You can change it back later if you don't like the script but you must have - and not /

    Any date format should be OK...

    dd-MM-yy
    dd-MMM-yy
    dd-MMMM-yy
    yyyy-MM-dd
    yyyy-MMM-dd

    Try this test before you create the image. In D:\System_Backup\Drive_Snapshot create a New Text Document and rename it test.sna (the .txt extension will be removed). So you have a pretend .sna.

    Run this batch file (as an Admin)...

    Code:
    CD /d D:\System_Backup\Drive_Snapshot
    
    :: +++++++++  Move all .sna to another folder  +++++++++
    set hh=%time:~0,2%
    if "%time:~0,1%"==" " set hh=0%hh:~1,1%
    set timestamp=%time:~0,8%
    if @%timestamp:~0,1% == @ set timestamp=0%timestamp:~1,7%
    set timestamp=%date:.=%_%timestamp::=%
    echo.Timestamp :: %timestamp%
    MD %timestamp%
    MOVE *.sna %timestamp%
    exit
    It should create a date/time folder and move test.sna into the folder.
    If you have other .sna in D:\System_Backup\Drive_Snapshot move them into a sub folder before creating test.sna.
     
  14. Hadron

    Hadron Registered Member

    Joined:
    Apr 1, 2014
    Posts:
    1,395
    It worked.
     
  15. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,370
    Location:
    NSW, Australia
    Excellent. I like it because each backup will be in its own folder and you don't have to be concerned about each backup having the same name.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.