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
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 If you know how to could u advise me plz
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.
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?
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.
Just what u gave me.. but with my name xcopy "C:\Documents and Settings\Adam\*.*" "D:\Backup\" /E /K /R /I /Y /F /H /D
Ah yeah, it's probably because you cannot copy the registry files. You'll need to exclude them. Let me look up the command.
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.
Yeah you are right.. it works copying from another directory.. but not the one i want.. Do u know of any other solution?
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.
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
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.
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).