Solved XCOPY for SkyDrive backup

adamf

Banned
Messages
1,870
I'm trying to make a script to backup SkyDrive folder which I'll schedule in Task Scheduler. This is it..

Code:
@echo off
if not exist E:\FileHistory\%username%\SkyDrive MD E:\FileHistory\%username%\SkyDrive  
xcopy %userprofile%\SkyDrive\*.* E:\FileHistory\%username%\SkyDrive /c /d /e /g /h /i /k /o /q /r /v /x /y > E:\FileHistory\%username%\SkyDrive\xcopy.log

This works fine but my E: drive is in a docking station so I want to check that the docking station is connected (that is the E: drive exists) before running it. Is that possible?
 

My Computer

System One

  • OS
    Windows 10 Pro Prieview x64
    Computer type
    Laptop
    System Manufacturer/Model
    MacBook Pro Core2Duo
    CPU
    T7600
    Memory
    3
    Graphics Card(s)
    ATI Radeon X1600
    Monitor(s) Displays
    Internal
    Screen Resolution
    1440 x 800
    Hard Drives
    40GB
    Keyboard
    Apple
    Mouse
    Apple
    Internet Speed
    Varies
    Browser
    Various
    Antivirus
    Defender
Pick a known file (or create a dummy file) on drive E: and test for it.

Code:
@echo off
IF NOT EXIST E:\test.fil goto not_fnd
if not exist E:\FileHistory\%username%\SkyDrive MD E:\FileHistory\%username%\SkyDrive  
xcopy %userprofile%\SkyDrive\*.* E:\FileHistory\%username%\SkyDrive /c /d /e /g /h /i /k /o /q /r /v /x /y > E:\FileHistory\%username%\SkyDrive\xcopy.log
goto :xit
:not_fnd
ECHO Drive E: not found
:xit
 

My Computer

System One

  • OS
    W10 Pro (desktop), W10 (laptop), W10 Pro (tablet)
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Home built i7-8700K, Hp Envy x360 EVO Laptop, MS Surface Pro 7
    CPU
    3.7Ghz Core i7-8700K, 11th Gen Core i7-1165G7 4.7Ghz, 10th Gen Core™ i5-1035G4 1.1Ghz
    Motherboard
    ASUS TUF Z370-Pro Gaming, HP, MS
    Memory
    16G, 8G, 8G
    Graphics Card(s)
    AMD Radeon RX580, Intel Iris X Graphics, Intel Iris Plus Graphics G4
    Sound Card
    ATI High Definition Audio (Built-in to mobo)
    Monitor(s) Displays
    Dual Samsung U32J59 32 inch monitors, 13.3" display, 12.3" display
    Screen Resolution
    3840x2160 (Desktop), 1920x1080 (laptop), 2736x1824 Pro 7
    Hard Drives
    500GB ssd boot drive with 2 & 10TB Data (Desktop), 512GB ssd (laptop), 128GB SSD (tablet)
    PSU
    Corsair CX 750M
    Case
    Antec 100
    Cooling
    Coolermaster CM 212+
    Keyboard
    IBM Model M - used continuously since 1986
    Mouse
    Microsoft IntelliMouse
    Internet Speed
    665Mbps/15Mbps down/up
    Browser
    FireFox, MS Edge
    Antivirus
    Defender on all
    Other Info
    Retired in 2015 after working in the tech industry for 41 years. First 10 years as a Technician, the rest as a programmer/software engineer. After 1 year of retirement, I was bored so went back to work as a Robotic Process Automation Consultant. Retired for 3rd (and final) time in 2019.
Excellent, thanks. I've done this and scheduled it to run every hour and it works perfectly.

Is there any way however to stop the empty black cmd.exe box flashing up for a split second every time it runs?
 

My Computer

System One

  • OS
    Windows 10 Pro Prieview x64
    Computer type
    Laptop
    System Manufacturer/Model
    MacBook Pro Core2Duo
    CPU
    T7600
    Memory
    3
    Graphics Card(s)
    ATI Radeon X1600
    Monitor(s) Displays
    Internal
    Screen Resolution
    1440 x 800
    Hard Drives
    40GB
    Keyboard
    Apple
    Mouse
    Apple
    Internet Speed
    Varies
    Browser
    Various
    Antivirus
    Defender

My Computer

System One

  • OS
    W10 Pro (desktop), W10 (laptop), W10 Pro (tablet)
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Home built i7-8700K, Hp Envy x360 EVO Laptop, MS Surface Pro 7
    CPU
    3.7Ghz Core i7-8700K, 11th Gen Core i7-1165G7 4.7Ghz, 10th Gen Core™ i5-1035G4 1.1Ghz
    Motherboard
    ASUS TUF Z370-Pro Gaming, HP, MS
    Memory
    16G, 8G, 8G
    Graphics Card(s)
    AMD Radeon RX580, Intel Iris X Graphics, Intel Iris Plus Graphics G4
    Sound Card
    ATI High Definition Audio (Built-in to mobo)
    Monitor(s) Displays
    Dual Samsung U32J59 32 inch monitors, 13.3" display, 12.3" display
    Screen Resolution
    3840x2160 (Desktop), 1920x1080 (laptop), 2736x1824 Pro 7
    Hard Drives
    500GB ssd boot drive with 2 & 10TB Data (Desktop), 512GB ssd (laptop), 128GB SSD (tablet)
    PSU
    Corsair CX 750M
    Case
    Antec 100
    Cooling
    Coolermaster CM 212+
    Keyboard
    IBM Model M - used continuously since 1986
    Mouse
    Microsoft IntelliMouse
    Internet Speed
    665Mbps/15Mbps down/up
    Browser
    FireFox, MS Edge
    Antivirus
    Defender on all
    Other Info
    Retired in 2015 after working in the tech industry for 41 years. First 10 years as a Technician, the rest as a programmer/software engineer. After 1 year of retirement, I was bored so went back to work as a Robotic Process Automation Consultant. Retired for 3rd (and final) time in 2019.
Thanks. In the end I changed the code to this:

Code:
@echo off
set backupdrive=E:
set users=%SystemDrive%\Users
   
if not exist %backupdrive%\FileHistory goto End
for /d %%x in (%users%\*) do (
  call:FnCopy %%~nxx    
  )
  
:FnCopy
  if not exist %users%\%1\SkyDrive\ goto :EOF
  if not exist %backupdrive%\FileHistory\%1\SkyDrive MD %backupdrive%\FileHistory\%1\SkyDrive 
  robocopy %users%\%1\SkyDrive %backupdrive%\FileHistory\%1\SkyDrive /b /e /r:0 /w:0 /copyall /mt /log:%backupdrive%\FileHistory\%1\SkyDriveLog.log         
  goto :EOF
  
:End

And scheduled the task to run under SYSTEM profile - no more pop-up and all users SkyDrive now backed up
 

My Computer

System One

  • OS
    Windows 10 Pro Prieview x64
    Computer type
    Laptop
    System Manufacturer/Model
    MacBook Pro Core2Duo
    CPU
    T7600
    Memory
    3
    Graphics Card(s)
    ATI Radeon X1600
    Monitor(s) Displays
    Internal
    Screen Resolution
    1440 x 800
    Hard Drives
    40GB
    Keyboard
    Apple
    Mouse
    Apple
    Internet Speed
    Varies
    Browser
    Various
    Antivirus
    Defender
Back
Top