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,517
    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,612
    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,517
    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,612
    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,517
    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,612
    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,612
    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,612
    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,517
    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,612
    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,612
    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,517
    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,612
    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,517
    It worked.
     
  15. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,612
    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.
     
  16. Hadron

    Hadron Registered Member

    Joined:
    Apr 1, 2014
    Posts:
    1,517
    Is there a way to get Drive Snapshot to automatically remove / delete / purge images after a defined number?
     
  17. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,612
    Location:
    NSW, Australia
    Easy to do if all images are created as hadron.sna

    This script saves the 3 most recent files...

    Code:
    IF EXIST c_C.sna (DEL c_C.sna)
    IF EXIST c_B.sna (REN c_B.sna c_C.sna)
    IF EXIST c_A.sna (REN c_A.sna c_B.sna)
    REN hadron.sna c_A.sna
     
  18. Hadron

    Hadron Registered Member

    Joined:
    Apr 1, 2014
    Posts:
    1,517
    Thanks for the reply, Brian.
    I am currently using this script.

    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
    How can I implement your code into that?
     
  19. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,612
    Location:
    NSW, Australia
    Does that produce 3 sna files?

    What are their names?
     
  20. Hadron

    Hadron Registered Member

    Joined:
    Apr 1, 2014
    Posts:
    1,517
    Yes, on this computer, it produces 3 SNA files.
    But Snapshot produces an SNA file for each partition.

    I have Snaphot running on 2 other computers, and it produces 5 SNA files on another desktop, and 4 SNA files on a notebook.

    PS: I always backup entire system drive.
     
  21. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,612
    Location:
    NSW, Australia
    OK. I keep forgetting these are Entire Drive images. My batch file above won't help. I can't think of an auto method to control sna numbers.

    Try this for new switches. You should be delighted.

    snapshot64.exe /?
     
  22. Hadron

    Hadron Registered Member

    Joined:
    Apr 1, 2014
    Posts:
    1,517
    What does that switch do?
     
  23. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,612
    Location:
    NSW, Australia
    It is to see all the DS switches and methods for backup/restore.
     
  24. Hadron

    Hadron Registered Member

    Joined:
    Apr 1, 2014
    Posts:
    1,517
    Nice one. :thumb:
     
  25. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    10,612
    Location:
    NSW, Australia
    I thought you would like...


    $hour is substituted with the hour
    $minute is substituted with the minute
    $second is substituted with the second
     
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.