Jump to content

Backing up script


Recommended Posts

Hello all,

i need help with a small script which will backup a whole drive e.g. D:\ into local disc.

I already wrote some but it dont works as I want. it use DirCopy function with nooverwrite like this:

DirCopy("d:\", "c:\backup\d\" & @UserName, 0)

this work great until I put another CD, then because the directory c:\backup\d\ already exists on the disc, the script will not copy any file

if i use

DirCopy("d:\", "c:\backup\d\" & @UserName, 1)

then it works with new CD but it overwrits files still around (I have a loop in the script) and it take too much CPU even if i put sleep (10000).

Here is whole script:

$i=0

do

$varCD = DriveStatus( "d:\" )

if $varUSB = "READY" then

DirCopy("d:\", "c:\d\" & @UserName, 1)

endif

sleep (10000)

until $i=1

Thank you for help.

Link to comment
Share on other sites

Even if i dont see the sense of using a loop for this you could do it like this:

Because in your script the loop would never end because $i would never become 1 since you never add 1 to $i

$i=0

do
$varCD = DriveStatus( "d:\" )

if $varUSB = "READY" then
DirCopy("d:\", "c:\d\" & @UserName, 1)
endif

sleep (10000)
$i += 1
until $i=1
Edited by Arterie
Link to comment
Share on other sites

A better way to split up the drive into smaller parts is to do a folder search, nonrecursive. First copy all files in the root directory of the drive to the backup directory. Then do a nonrecursive search for the folders in the root. You can then copy each folder separately to the backup directory. In between each folder copy, you can sleep to lower the cpu usage. If the cpu is still too high, just split up each folder using these steps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...