How to backup important data via Robocopy? | MiniCoder

What is Robocopy ?

There are two mainly command line tools often used in file transfers for Windows, Robocopy (Robust File Copy) and XCopy. However, robocopy is more powerful and has better performance for mass files migration.

'Description:
'    Function to make full backup
'        [/Z]: Able to continue transferring after restart
'        [/NP]: without UI interface
'        [/NDL]: No extra resource consuming for folder name
'        [/MIR]: use clone copy instead of incremental copy, the clone copy will delete all old files/folders
'        [/R:0]: No repeat attempt
'        [/W:0]: 10 seconds wait time for repeat attempt
'Input: 
'    sourceDir: The source path which requires full backup
'    objectDir: The destination path for saving latest full backup 
'    optionalCMD: The optional command for robocopy.exe 
'Output:
'    None
'Throw Exception When:
'    None

public function do_Full_Backup(sourceDir, objectDir, optionalCMD)
    on error resume next

        cmd = "robocopy " & masterDir & " " & masterOldDir & " /MIR /R:0 /W:10 /Z /NP /NDL" & optionalCMD
        result = execute_Shell(cmd)

    on error goto 0
end function

Except full backup , you can also use robocopy to exclude files with specific file extensions from backup , such as media file  , temp file , log file etc. Here is the best  practice of shared exclude members.

optionalCMD = "/XF *.zip *.rar *.exe *.mov *.avi *.tar *.gzip *.gz *.mp3 *.mgp *.wma *.wmv *.avi *.wav *.log *.peg *.mp4 *.iso *.psd *.swf *.mpg *.tmp *.tmp.* *.pdf"

Generally speaking, the shared hosting provider do not allow storage large files on there backup device, we can

'do not copy files over 100MB
optionalCMD = "/max:100000000" 

If there are too match small files, it will slow down the copy process, we can exclude small files as well

'do not copy files less than 1KB
optionalCMD = "/min:1000"

Do the difference backup to save disk space

'copy last 7 days difference backup files except today
optionalCMD = "/maxage:7 /minage:1"

If you want run task at non-busy time , you can

'run task at 0am to 7am
optionalCMD = "/rh:0000-0700"

Adjust the task speed via threads numbers. Please note the threads can not exceed 150

optionalCMD = "/mt:30"

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章