Advertisement
Najeebsk

AutomaticBackup.txt.bat

Dec 4th, 2022 (edited)
1,157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.85 KB | None | 0 0
  1. How to create an Automatic Backup from One Folder to Another Folder
  2. BackUp.bat
  3. robocopy "Folder A" "Folder B" /E
  4. robocopy "Folder A" "Folder B" /E /MIR
  5. robocopy "Folder A" "Folder B" /MIR + /E
  6. robocopy "Folder A" "Folder B" /E /MIR /COPYALL /ZB /R:5 /W:8
  7. robocopy "Folder A" "Folder B" /E /COPYALL /ZB /R:5 /W:8 /MOVE
  8. robocopy "Folder A" "Folder B" /E /COPYALL /ZB /R:5 /W:8 /MOVE /MOT:1
  9. --------------------------------------------------------------
  10. This time instead of xcopy, we are using robocopy. Robocopy is the upgraded form of xcopy. Save the batch file with any name but don't keep the name as robocopy because it crashes the robocopy system.
  11.  
  12. /E This can copy all the files including subdirectories and empty directories.
  13.  
  14. /MIR can copy all the files including subdirectories and empty directories, delete destination files and directories that no longer exist in the source, and using the /MIR + /E option can overwrite the destination directory security settings.
  15.  
  16. /COPYALL copies file information such as data, attributes, time stamps, NTFS access control list, Owner information, and  Auditing information.
  17.  
  18. /ZB copies files in restartable mode. If file access is denied, it switches to backup mode.
  19.  
  20. /R:5 retries five times if runs into any issues.
  21.  
  22. /W:8 waits for 8 seconds between each of those (/R:5) five retries.
  23.  
  24. /COPYALL and /ZB require to run as administrator.
  25.  
  26. Delete /MIR and add /MOV. We cannot use /MIR with /MOV and /MOVE.
  27.  
  28. /MOV can move the files but it will leave the source folder and subfolders empty after the files are moved. This can be pretty handy if you have assigned subfolders.
  29.  
  30. /MOVE moves the files and subdirectories completely to the destination folder and the source folder gets deleted.
  31.  
  32. Using /MOT:1 together with /MOVE can help us to retain only the source after the files are moved to the destination. This can be useful if someone doesn't want to retain files and empty subfolders in the source.
  33.  
  34. The actual function of /MOT:1 is to monitor the source and run again in 1 minute if changes are detected.
  35. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  36. BackUp.bat
  37. xcopy "SOURCE" "DESTINATION" /Y /E /D /C /F /H /I /Z /J  
  38. ---------------------------------------------------------------------------------
  39. RunBat.vbs
  40. Set WshShell = CreateObject("WScript.Shell" )
  41. WshShell.Run chr(34) & "C:\Users\Najeeb\Desktop\BackUp.bat" & Chr(34), 0
  42. Set WshShell = Nothing
  43. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  44. BackUps.bat
  45. xcopy "SOURCE" "DESTINATION" /Y /E /D /C /F /H /I /Z /J /S /K /R /G
  46. xcopy "SOURCE2" "DESTINATION2" /Y /E /D /C /F /H /I /Z /J /S /K /R /G
  47. xcopy "SOURCE3" "DESTINATION3" /Y /E /D /C /F /H /I /Z /J /S /K /R /G
  48. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  49. How to create an automated task using Task Scheduler on Windows 7
  50. --------------------------------------------------------------------------------
  51. WIN+R =Run Commmad :-Taskschd.msc
  52. 1-Open Task Scheduler Click Action Menu Select Create Task  = Name (Name of Task)=EXM:-(NajeebBackUp)OR (EmptyRecycleBin)
  53. 2-Click Triggers And Select New (New Trigger Win) Check Daily ; And Check (Repeat task every: and Chosse hour and mints)
  54. 3-Click Actions And Select New (New Action Win) Program/Script: ( wscript.exe )  Or (CMD.exe) And
  55.  Add arguments(optional): ("C:\Users\Najeeb\Desktop\Run.vbs") Or (/c "echo Y|PowerShell.exe -NoProfile -Command Clear-RecycleBin")
  56. 4-Click condditions And Power UnCheck 1-(Stop if the Computer swiches to bettery power)
  57. 2-(start the task only if the computer is on AC power
  58. 5-Click Settings Check (Run task as soon as possible after a scheduled start is missed
  59. 6 Ok Finished
  60. -------------------------------------------------------------------------------
  61. How to Empty Recycle Bin Automatically in windows 7&10. It is very easy.
  62. Code:
  63. cmd.exe
  64. /c "echo Y|PowerShell.exe -NoProfile -Command Clear-RecycleBin"
  65. OR
  66. C:\Windows\nircmd.exe
  67. emptybin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement