Advertisement
Guest User

Backup OneDrive

a guest
Feb 23rd, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.08 KB | None | 0 0
  1. @echo off
  2. REM :: Enter the drive letter of your backup drive and the path to your Onedrive folder here. %USERPROFILE% refers to your home folder
  3. SET driveLetter=Z
  4. SET onedrivePath=%USERPROFILE%\OneDrive
  5.  
  6. REM :: Below code sets date information for folder formatting
  7.  
  8. for /F "skip=1 delims=" %%F in ('
  9.     wmic PATH Win32_LocalTime GET Day^,Month^,Year /FORMAT:TABLE
  10. ') do (
  11.     for /F "tokens=1-3" %%L in ("%%F") do (
  12.         set CurrDay=0%%L
  13.         set CurrMonth=0%%M
  14.         set CurrYear=%%N
  15.     )
  16. )
  17. set CurrDay=%CurrDay:~-2%
  18. set CurrMonth=%CurrMonth:~-2%
  19.  
  20. set hour=%time:~0,2%
  21. if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
  22.  
  23. set min=%time:~3,2%
  24. if "%min:~0,1%" == " " set min=0%min:~1,1%
  25.  
  26. set secs=%time:~6,2%
  27. if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
  28.  
  29. REM :: makes folder for backup; copies onedrive folder.
  30. set foldername="%driveLetter%:\Backups\%CurrDay%_%CurrMonth%_%CurrYear%\%hour%_%min%_%secs%\"
  31. mkdir %foldername%
  32. echo Now Backing up OneDrive...
  33. timeout /t 5 /nobreak >nul 2>&1
  34. xcopy %onedrivePath% %foldername% /I /S
  35. echo.
  36. echo.
  37. echo Backup Complete.
  38. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement