1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Windows Backup

Discussion in 'Software' started by afjs1413, 21 Jul 2003.

  1. afjs1413

    afjs1413 Minimodder

    Joined:
    13 Jan 2003
    Posts:
    169
    Likes Received:
    0
    Im looking for a .bat file for backing up some stuff on my PC
    Im not very good with this sorta thing
    What im looking to do is get a folder lets say C:\Documents and Settings\**user**\ and save it to another drive say D:\backup

    It would be great to have it back up all the folders too(im not sure if its possible though)

    Hope this makes sense..
    PS the reason for doing this is so that i can set it to run everynight to back my things up
     
  2. ST8

    ST8 What's a Dremel?

    Joined:
    14 Feb 2003
    Posts:
    596
    Likes Received:
    0
    read the sticky in networking...
     
  3. afjs1413

    afjs1413 Minimodder

    Joined:
    13 Jan 2003
    Posts:
    169
    Likes Received:
    0
    I did read that stickey... but i only want it for my computer.. i just want it to copy to another drive..
    I did try to customise it.. but i failed :grr:
    If you know how to could u advise me plz
     
  4. DeX

    DeX Mube Codder

    Joined:
    22 Jul 2002
    Posts:
    4,152
    Likes Received:
    3
    Damn, just when I got my nifty xcopy code out too. I didn't notice that sticky, afjs1413, just make sure you use xcopy and not the original code posted which uses the normal copy command. Oh I'll just post this anyway:

    xcopy "source*.*" "dest" /E /K /R /I /Y /F /H /D

    eg:

    xcopy "C:\Documents and Settings\Alex\*.*" "D:\Backup\" /E /K /R /I /Y /F /H /D

    This will copy all files from source to dest including subfolders and will only copy if the files are newer than on dest.
     
  5. afjs1413

    afjs1413 Minimodder

    Joined:
    13 Jan 2003
    Posts:
    169
    Likes Received:
    0
    Ahh thanks mate

    Just a quick question what does the " /E /K /R /I /Y /F /H /D" all mean?


    Edit: i just tested it... but it ist copying the subfolders?
     
  6. DeX

    DeX Mube Codder

    Joined:
    22 Jul 2002
    Posts:
    4,152
    Likes Received:
    3
    Here's the full list of commands:


    /A Copies only files with the archive attribute set, doesn't change the attribute.
    /M Copies only files with the archive attribute set, turns off the archive attribute.
    /D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time. .obj extension respectively.
    /P Prompts you before creating each destination file.
    /S Copies directories and subdirectories except empty ones.
    /E Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T.
    /V Verifies each new file.
    /W Prompts you to press a key before copying.
    /C Continues copying even if errors occur.
    /I If destination does not exist and copying more than one file, assumes that destination must be a directory.
    /Q Does not display file names while copying.
    /F Displays full source and destination file names while copying.
    /L Displays files that would be copied.
    /G Allows the copying of encrypted files to destination that does
    not support encryption.
    /H Copies hidden and system files also.
    /R Overwrites read-only files.
    /T Creates directory structure, but does not copy files. Does not include empty directories or subdirectories. /T /E includes empty directories and subdirectories.
    /U Copies only files that already exist in destination.
    /K Copies attributes. Normal Xcopy will reset read-only attributes.
    /N Copies using the generated short names.
    /O Copies file ownership and ACL information.
    /X Copies file audit settings (implies /O).
    /Y Suppresses prompting to confirm you want to overwrite an existing destination file.
    /-Y Causes prompting to confirm you want to overwrite an existing destination file.
    /Z Copies networked files in restartable mode.
     
  7. afjs1413

    afjs1413 Minimodder

    Joined:
    13 Jan 2003
    Posts:
    169
    Likes Received:
    0
    Dex its not copying the subfolders
     
  8. DeX

    DeX Mube Codder

    Joined:
    22 Jul 2002
    Posts:
    4,152
    Likes Received:
    3
    That's strange. I tested it and it copies subfolders for me. What's the exact line you're using?
     
  9. afjs1413

    afjs1413 Minimodder

    Joined:
    13 Jan 2003
    Posts:
    169
    Likes Received:
    0
    Just what u gave me.. but with my name :D

    xcopy "C:\Documents and Settings\Adam\*.*" "D:\Backup\" /E /K /R /I /Y /F /H /D
     
  10. DeX

    DeX Mube Codder

    Joined:
    22 Jul 2002
    Posts:
    4,152
    Likes Received:
    3
    Ah yeah, it's probably because you cannot copy the registry files. You'll need to exclude them. Let me look up the command.
     
  11. afjs1413

    afjs1413 Minimodder

    Joined:
    13 Jan 2003
    Posts:
    169
    Likes Received:
    0
    Well iv got it to copy the folders.. but thats all its copying, there empty
     
  12. DeX

    DeX Mube Codder

    Joined:
    22 Jul 2002
    Posts:
    4,152
    Likes Received:
    3
    Hmm well I can't figure it out. I can't get the exclude thing to work. I don't have the problem with empty folders though. Try copying another directory anyway. I'm off to bed.
     
  13. afjs1413

    afjs1413 Minimodder

    Joined:
    13 Jan 2003
    Posts:
    169
    Likes Received:
    0
    Yeah you are right.. it works copying from another directory.. but not the one i want..
    Do u know of any other solution?
     
  14. DeX

    DeX Mube Codder

    Joined:
    22 Jul 2002
    Posts:
    4,152
    Likes Received:
    3
    Well the following works fine for me:

    xcopy "C:\Documents and Settings\Alex\*.*" "D:\Backup\" /E /K /R /I /Y /F /H /D /C /exclude:c:\exclusions.txt



    Change the folder names with the ones you want.
    In exclusions.txt you should have the following lines:

    ntuser.dat
    UsrClass.dat
    Content.IE5

    The last line will stop any of the tempory internet files being copied since this takes forever and there's not much point in backing them up. I reccomend you keep the exclusions.txt file in the root of C:\ because you might have problems if you want to put it in other directories. Also I added the /C to the list of switches which means if an error occurs it will continue copying. I did this because I got some problems when it tried to copy files with a file name ending with a period (.).

    Hope this works. :p
     
  15. afjs1413

    afjs1413 Minimodder

    Joined:
    13 Jan 2003
    Posts:
    169
    Likes Received:
    0
    I have put this in
    xcopy "C:\Documents and Settings\Adam*.*" "I:\Backup\" /E /K /R /I /Y /F /H /D /C /exclude:c:\exclusions.txt

    And it copys nothing at all
    I cant work out y its not working correctly

    Edit: and if i take the /exclude:c:\exclusions.txt section off the ed it will copy all the folders but not files again
     
  16. DeX

    DeX Mube Codder

    Joined:
    22 Jul 2002
    Posts:
    4,152
    Likes Received:
    3
    Try this for a start:

    "C:\Documents and Settings\Adam\*.*" "I:\Backup\" /E /K /R /I /Y /F /H /D /C /exclude:c:\exclusions.txt

    also try removing the /D switch and see if it works then.
     
  17. afjs1413

    afjs1413 Minimodder

    Joined:
    13 Jan 2003
    Posts:
    169
    Likes Received:
    0
    Ok i tryed that
    It still copyed nothing with the \D or without it
     
  18. pszaro

    pszaro What's a Dremel?

    Joined:
    11 Mar 2002
    Posts:
    206
    Likes Received:
    0
    May I suggest that you use ROBOCOPY! Ok, I just did. Robocopy is far more advanced than the standard copy, xcopy programs. You can also have it output everything to a log file.

    Here is the readme for robocopy:


    ----------------------------------------------------------------------
    ROBOCOPY v 1.96 : Robust File Copy for Windows NT
    ----------------------------------------------------------------------

    Usage : ROBOCOPY source destination [file [file]...] [options]

    source : Source Directory (drive:\path or \\server\share\path).
    destination : Destination Dir (drive:\path or \\server\share\path).
    file : File(s) to copy (names/wildcards: default is "*.*").

    Copy options: /S : copy Subdirectories, but not empty ones.
    /E : copy subdirectories, including Empty ones.
    /LEV:n : only copy the top n LEVels of the source directory tree.

    /Z : copy files in restartable mode.

    /SEC : copy SECurity info (both source and dest must be NTFS).
    /SECFIX : FIX SECurity info on existing files and dirs.
    /TIMFIX : FIX TIMestamps on existing destination files.

    /MOV : MOVe files (delete from source after copying).
    /MOVE : MOVE files AND dirs (delete from source after copying).

    /PURGE : delete dest files/dirs that no longer exist in source.
    /MIR : MIRror a directory tree (equivalent to /E plus /PURGE).

    /A+:[R][A][H] : add the given Attributes to copied files.
    /A-:[R][A][H] : remove the given Attributes from copied files.

    /CREATE : CREATE directory tree structure + zero-length files only.
    /FAT : create destination files using 8.3 FAT file names only.

    File Selection: /A : copy only files with the Archive attribute set
    /M : like /A, but remove Archive attribute from source files.
    /IA:[R][A][H] : Include only files with some of the given Attributes set.
    /XA:[R][A][H] : eXclude files with any of the given Attributes set.

    /XF file [file]... : eXclude Files matching given names/paths/wildcards.
    /XD dirs [dirs]... : eXclude Directories matching given names/paths.

    /XC | /XN | /XO : eXclude Changed | Newer | Older files.
    /XX | /XL : eXclude eXtra | Lonely files and dirs.
    /IS : Include Same files.

    /MAX:n : MAXimum file size - exclude files bigger than n bytes.
    /MIN:n : MINimum file size - exclude files smaller than n bytes.

    /MAXAGE:n : MAXimum file AGE - exclude files older than n days/date.
    /MINAGE:n : MINimum file AGE - exclude files newer than n days/date.
    (If n < 1900 then n = n days, else n = YYYYMMDD date).

    Retry Options: /R:n : number of Retries on failed copies: default is 1 million.
    /W:n : Wait time between retries: default is 30 seconds.

    /REG : Save /R:n and /W:n in the Registry as default settings.

    /TBD : wait for sharenames To Be Defined (retry error 67).

    Logging Options: /L : List only - don't copy, timestamp or delete any files.
    /X : report all eXtra files, not just those selected.
    /V : produce Verbose output, showing skipped files.

    /NP : No Progress - don't display % copied.
    /ETA : show Estimated Time of Arrival of copied files.

    /LOG:file : output status to LOG file (overwrite existing log).
    /LOG+:file : output status to LOG file (append to existing log).
     
Tags:

Share This Page