Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    New Lounger
    Join Date
    Dec 2009
    Location
    oregon,il
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a command file that I use to copy files from the original location, to a backup location. I just noticed, that the "Files" are copying OK, but the "Folders" contained in the source folder, are NOT being copied.

    Can anybody help me edit this file to also copy the folders?


    Xcopy D:\"My Documents"\*.* D:\QBackup\"My Documents"\*.* /y
    Side Note: A BIG hug to Fred Langa, for opening the door to command files for backup purposes, many years ago

  2. #2
    New Lounger
    Join Date
    Feb 2010
    Location
    Mississauga, ON, Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You need to add the /s or /e switch to your command, i.e.

    Xcopy D:\"My Documents"\*.* D:\QBackup\"My Documents"\*.* /s /y or
    Xcopy D:\"My Documents"\*.* D:\QBackup\"My Documents"\*.* /e /y

    You can also use

    Xcopy D:\"My Documents" D:\QBackup\"My Documents" /s /y or
    Xcopy D:\"My Documents" D:\QBackup\"My Documents" /e /y

    See xcopy /?

    Ed

  3. #3
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,417
    Thanks
    33
    Thanked 195 Times in 175 Posts
    Quote Originally Posted by Larry Bogie View Post
    Side Note: A BIG hug to Fred Langa, for opening the door to command files for backup purposes, many years ago
    If I recommend RoboCopy instead of the rather dated Xcopy, do I get a hug too?!
    BATcher

    Time prevents everything happening all at once...

  4. #4
    3 Star Lounger
    Join Date
    Dec 2009
    Location
    Sydney, Australia
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by BATcher View Post
    If I recommend RoboCopy instead of the rather dated Xcopy, do I get a hug too?!
    I would second this suggestion it is a much better solution for a point to point backup. Much more extensive than the old faithful Xcopy

  5. #5
    New Lounger
    Join Date
    Feb 2010
    Location
    Mississauga, ON, Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No argument from me.

    Just responding to his original question, but should've mentioned it.

    Ed

  6. #6
    New Lounger
    Join Date
    Dec 2009
    Location
    oregon,il
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Ed...I got the command file to do what I want now!

    I looked at robocopy GUI, & did some testing. It is extremely fast, even though my command file is plenty fast enough for me. I ran robocopy to replicate the same line as my command file, but I have the same (original) problem with it NOT copying folders. I'm sure there is a command that I could use to include folders, but I don't know what it is.

    I may move on to using robocopy when I have some time to put it ALL together.

    I should say that the complete command file I use, does not just have the line I posted, but it is a single line of a multi-line command. All total I have 9 different backup task included in the command, with each one running one after another. I then have it run using "Schedule Task" at night.

    Can I setup a robocopy command to run multiple tasks, all in the same command (i.e 9 different backup tasks)?

  7. #7
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,417
    Thanks
    33
    Thanked 195 Times in 175 Posts
    Like almost all the backup programs I know of, each execution with back up a set of folders using specified criteria. So nine sets of folders means nine backups.

    If I understand you correctly, you are saying that only the files in the 'root' are being backed up, and not subfolders or the files in them? Then for RoboCopy specify /s to do subdirectories, also.

    Here's an example use of RoboCopy (somewhat simplified!) - look up the options in the documentation:

    Code:
    :: set up the source and target paths
    set source=C:\
    set target=E:\RoboCopy of C drive\Monday
    set log=E:\RoboLogs\RoboCopy_Monday.log
    :: build up the options/parameters
    set opts=/mir /np /r:0 /w:0 /ndl
    :: excludes
    set opts=%opts% /xd Recycler "System Volume Information" cache bases
    set opts=%opts% /xf hiberfil.sys pagefile.sys
    :: perform the backup
    robocopy "%source%" "%target%" %opts% > %log%
    BATcher

    Time prevents everything happening all at once...

  8. #8
    New Lounger
    Join Date
    Dec 2009
    Location
    oregon,il
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That worked Batcher.

    So i am taking the plunge into robocopy to build my 9 backup script, by creating each one at a time...then when successful I C & P the working individual script to, lets say my "Master Script".

    Here's where I am stuck...several of my backup jobs are for individual files (not folders). Again, I am using the Robocopy GUI to make the scripts. When I browse to the source folder, I am not able to browse to the individual file I want, so after I choose the folder, I manually type in the file. The file I type in is highlighted in red.
    robocopy "H:\Program Files\KeePass Password Safe 2\Keypass.kdbx"

    "D:\QBackup\KeePass" /S /V /NP /R:10 /W:30
    pause
    When I run the script, I get this error: " The file name, directory name, or volume syntax is incorrect". Can anyone direct me as how to get this to work?

  9. #9
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,417
    Thanks
    33
    Thanked 195 Times in 175 Posts
    Larry, you have forgotten the syntax of the RoboCopy command and have reverted to Xcopy syntax!
    !
    Code:
                  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 "*.*").
    If you are copying all files then the default is *.* and so this parameter usually gets left out...
    I leave the correction of your command as an exercise for you...
    BATcher

    Time prevents everything happening all at once...

  10. #10
    Bronze Lounger DrWho's Avatar
    Join Date
    Dec 2009
    Location
    Central Florida
    Posts
    1,501
    Thanks
    30
    Thanked 205 Times in 163 Posts
    I've been using XCOPY almost as long as it has existed in MS-DOS.

    It helps if you just go to a command prompt and type:

    XCOPY /? (press Enter)

    That will give you a complete list of all the switches that can be used with XCOPY.

    The switch you needed in the above problem was the /s switch, to copy sub-directories.

    I have used xcopy to back up whole drives before.

    One typical line I use to backup the entire "My Documents" folder to my storage drive is:

    Rem Backup My Documents and all sub-folders/files.
    xcopy "C:\Documents and Settings\Alex\My Documents\*.*" "D:\My Documents\" /s /y /H /R /D


    Xcopy works great when properly applied.
    I like using what MS gave me instead of downloading more programs to add to the HD bloat.
    I've been doing it for thirty years, so I probably won't change now.
    My first HD was only 20 megs in capacity, so I learned real quick to save HD space wherever possible.

    Cheers mates!
    the Doctor
    Experience is truly the best teacher.

    Backup! Backup! Backup! GHOST Rocks!

  11. #11
    New Lounger
    Join Date
    Dec 2009
    Location
    oregon,il
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by BATcher View Post
    Larry, you have forgotten the syntax of the RoboCopy command and have reverted to Xcopy syntax!
    !
    Code:
                  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 "*.*").
    If you are copying all files then the default is *.* and so this parameter usually gets left out...
    I leave the correction of your command as an exercise for you...
    Let me clarify where I'm at...I have solved my first problem of being able to copy "sub-folders", by adding the /s switch to the script...SOLVED

    BUT, my 2nd problem is when trying to copy (backup) an individual file.

    Again, I am using robocopy GUI to create the script...it will not "browse" to an individual "file", but it will browse to the folder (which I select)...I then, manually type in the "file" I want to backup by adding "\keypas.kdbx" to the end of the script> save & run. This is where I get the error as shown in the screen shot...the problem resides in the "source", which I can't figure out (& believe me I have spent 4 hours trying different switches)

    DocWho, My original problem with my xcopy command was answered with success above, but a couple of expert replies recommended that I use robocopy instead of xcopy...so they planted a mountain for me to climb, & now I have invested a lot of time trying to figure out robocopy...not sure if this journey is worth taking, as I have used xcopy for years myself with GREAT success...the quest for knowledge is painful at times LOL!
    Attached Images Attached Images

  12. #12
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Larry Bogie View Post
    Let me clarify where I'm at...I have solved my first problem of being able to copy "sub-folders", by adding the /s switch to the script...SOLVED

    BUT, my 2nd problem is when trying to copy (backup) an individual file.

    Again, I am using robocopy GUI to create the script...it will not "browse" to an individual "file", but it will browse to the folder (which I select)...I then, manually type in the "file" I want to backup by adding "\keypas.kdbx" to the end of the script> save & run. This is where I get the error as shown in the screen shot...the problem resides in the "source", which I can't figure out (& believe me I have spent 4 hours trying different switches)

    DocWho, My original problem with my xcopy command was answered with success above, but a couple of expert replies recommended that I use robocopy instead of xcopy...so they planted a mountain for me to climb, & now I have invested a lot of time trying to figure out robocopy...not sure if this journey is worth taking, as I have used xcopy for years myself with GREAT success...the quest for knowledge is painful at times LOL!
    I don't get it. It looks like BATcher gave you the answer in his last post. Did you try the syntax he showed you?

    robocopy "H:\Program Files\KeePass Password Safe 2" "D:\QBackup\KeePass" "Keypass.kdbx" [--other options go here--]

  13. #13
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,417
    Thanks
    33
    Thanked 195 Times in 175 Posts
    I'm afraid I can't help you with the RoboCopy GUI - I've never bothered with it as unnecessary to the CLI enthusiast!

    Setting your task up manually, you want something like

    Code:
    robocopy "H:\Program Files\KeePass Password Safe 2"  "D:\QBackup\KeePass" Keypass.kdbx /S /V /NP /R:0 /W:0 
             Source Directory                             Destination         File         Parameters
    I have never seen any point in setting the /R and /W parameters to anything other than zero, because I've never found a condition which a small amount of more time would correct!
    BATcher

    Time prevents everything happening all at once...

  14. #14
    New Lounger
    Join Date
    Dec 2009
    Location
    oregon,il
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I got it now!

    I seemed to have been blinded as to where to put the "source individual" file I wanted to backup...with xcopy, the file has to be behind the source path in the command, which I was trying to do the same with robocopy...I finally realized that the individual file has to be at the end of the script with a space in between, & also learned that the quotes have to include the drive...whereas with xcopy the quotes are behind the drive. It's hard to break OLD habits!

    The one job I had trouble with is my address book. I used this script that would not work
    robocopy "C:\Documents and Settings\larry bogie\Application Data\Microsoft\Address Book" "D:\QBackup\Address Book" larry bogie.wab /S /V /NP /R:0 /W:0
    Yet this script did work
    robocopy "C:\Documents and Settings\larry bogie\Application Data\Microsoft\Address Book" "D:\QBackup\Address Book" /S /V /NP /R:0 /W:0
    There are 2 files: larry bogie.wab, & larry bogie.wab~. The only thing I can think of, is that is both files needed to be copied together...I duno!

    I did most of the scripts manually (without using robocopy GUI) to learn the inter workings.

    I now have all 9 of my backup jobs in 1 master script...tried & tested the script, and everything is working as I want.

    Have a look-see at my New Creation...I am VERY proud of it!
    robocopy "D:\Bogie Documents" "D:\QBackup\Bogie Documents" /S /V /NP /R:0 /W:0

    robocopy "D:\Bids" "D:\QBackup\Bids" /V /NP /R:0 /W:0

    robocopy "D:\Contracts" "D:\QBackup\Contracts" /V /NP /R:0 /W:0

    robocopy "C:\Documents and Settings\larry bogie\Application Data\Opera\Opera" "D:\QBackup\Opera" /S /V /NP /R:0 /W:0 this script includes 3 backup files, that I used to do in 3 separate commands

    robocopy "H:\Program Files\KeePass Password Safe 2" "D:\QBackup\KeePass" Keypass.kdbx /S /V /NP /R:0 /W:0

    robocopy "H:\Program Files\Intuit\Quickbooks 2008" "D:\QBackup\Quick Books\QBW" BLACKHAW.QBW /S /V /NP /R:0 /W:0

    robocopy "C:\Documents and Settings\larry bogie\Application Data\Microsoft\Address Book" "D:\QBackup\Address Book" /S /V /NP /R:0 /W:0
    pause
    Big Hugs to all who helped me accomplish this task

  15. #15
    New Lounger
    Join Date
    Feb 2010
    Location
    Mississauga, ON, Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    WTG, Larry.

    One other switch you might want to have a look at is /LOG:file (or /LOG+:file).

    Using this will let you verify that everything worked OK, or, if not, what the problem was.

    e.g. robocopy "D:\Bogie Documents" "D:\QBackup\Bogie Documents" /S /V /NP /R:0 /W:0 /LOG:"D:\QBackup.log"

    or, if you want to keep the logs for, say, a week or so, then delete it and start a new one

    robocopy "D:\Bogie Documents" "D:\QBackup\Bogie Documents" /S /V /NP /R:0 /W:0 /LOG+:"D:\QBackup.log"

    Using the same file name in all of your backups will create just the one log, or, if you prefer, you can log them to separate files.

    Very useful tool, is RoboCopy...

    Ed

    P.S. You really don't need the quotes in D:\QBackup.log but when I tried to post /LOG+:"D:\QBackup.log" without them it showed as /LOG+\QBackup.log

    Always remember that computers are strange beasts...

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •