1

I recently backed up the data on my computer, using the xcopy command. I briefly looked through some of my backup files and directories, and they looked the same as the originals. However, I understand that some people use backup wizards instead of xcopy, and I was wondering whether xcopy provides a safe means of backing up data.

I typed the following command in the Windows command prompt terminal:

xcopy [Source] [Destination] /s /e /v

My source was my home directory on my hard drive. (My hard drive is not partitioned, and I have only one home directory.) My destination was a new directory to be created on a flash drive. After typing the command, I was asked whether the destination was a directory or a file, and I indicated a directory. I used the "/s"-option to copy subdirectories. I used the "/e"-option to copy empty directories. I used the "/v"-option to verify that all copies were the same as the originals. There were no encrypted files to copy.

For the parameters that I included in my command, I believe the correct order was, "/s /e /v". However, I do not remember for certain that this was the order which I used. Does the order of these parameters matter?

Because my source was my home directory, I know that I did not create any backups of software on my computer. However, I only wanted to back up my data, not software.

I understand that there is a "/h"-option to copy hidden files. I did not include this option, since none of my data would be in hidden files, and I read that it is best to leave hidden files alone. I understand that hidden files are created by Windows for the purpose of running the operating system and programs, and are hidden so that users do not unintentionally fiddle with them.

I backed up my data, because I am planning on installing Ubuntu on my computer. To be safe, I created several backups, each on a different flash drive. I understand that I should periodically back up my data, and I plan to do that after I install Ubuntu. Since my data are saved in Windows directories, I understand that I might need to use Wine to access my data from Ubuntu.

Before I attempt the installation, I thought I should ask whether my method of using the xcopy command was safe. Would my command be expected to copy all of my data from my home directory? Would the process have stopped and given me an error message if a file or subdirectory had not been copied correctly? Is there any reason to use a backup wizard instead?

Thank you.

3
  • 2
    I myself would come back with robocopy to make sure I got all of my data and only use that in the future. robocopy will ensure that source and destination are the same without copying the files all over again. Google "using robocopy to sync folders" .. once you get to Linux land, you would use rsync the exact same way and not cp if you were trying to accomplish this same thing. May 31, 2022 at 20:04
  • xcopy and robocopy are an inefficient means of backing files up, with no guarantee of data integrity, no compression, and an incorrect use case for both, as backing up files is not the purpose of either; instead capturing/appending to a WIM would be the recommended native route. Linux shouldn't be used to backup files in Windows and is really bad advice, generally recommended when folks who primarily use Linux don't know how to do so natively in Windows (would Wine be recommended to backup Linux?).
    – JW0914
    Jun 1, 2022 at 3:07
  • Thank you to both SenorCMasMas and JW0914. I appreciate your input. I believe I might have found a safe way to back up my data with xcopy. In the answer below, I explain what I did. I would appreciate any additional input you might have to offer. Once again, thank you. Jun 1, 2022 at 4:20

1 Answer 1

-1

After studying this issue some more, I believe the solution is to first run the xcopy command I posted, and then to run the following command:

echo %ERRORLEVEL%

I believe the above command would output the error level generated by xcopy. An output of zero from the echo command would mean that there were no errors in running xcopy, and the copy was successful.

Since my xcopy command includes the attributes, "/s /e /v", all subdirectories and their contents are copied, and copies are verified to be identical to originals.

I found out about the command, "echo %ERRORLEVEL%", from the following source:

https://www.computerhope.com/jargon/e/erroleve.htm#testing-errorlevel

I deleted a recent backup from a flashdrive, I created a new backup with the xcopy command I described, and I ran the echo command. The echo command returned the value of zero, which I believe means that there were no errors in making the copy. So, I believe the copy was successful.

@SenorCMasMas: I tried your suggestion of using robocopy. However, the robocopy command transferred files from directories I could only see by typing, "dir /a". I believe these must have been system and hidden files. Robocopy got stuck trying to transfer a certain file from a hidden directory, and I aborted the process with "Ctrl-C". I believe administrator privileges probably were required for transferring the file. However, I did not try running the command prompt as an administrator, because I only want to back up my data, and I do not want to transfer system files and hidden files. I understand that robocopy can exclude the transfer of certain types of files when used with the parameter, "/xa:". I tried using this parameter to exclude system files and hidden files, but robocopy still would transfer files from hidden directories, and then would get stuck on one such file. I tried "/xa: s" to exclude system files, "/xa: h" to exclude hidden files, "/xa: sh", and "/xa: s /xa: h". The same problem came up every time.

I did some reading on robocopy, and I understand the primary advantage of the command is that it allows one to transfer directories and files without altering ones which had been transferred earlier. I am trying to create a backup for the first time. So, I do not see why I would need to use robocopy. I believe the xcopy command would be fine for my purposes.

@JW0914: You said that both xcopy and robocopy are inefficient, and there is no guarantee of data integrity. Not much data are saved on my computer right now, and xcopy did not take an unreasonable amount of time. So, I do not think I need to worry about efficiency. Since I used the "/v"-parameter, xcopy verified that the copies were identical to the originals. Since my "echo %ERRORLEVEL%" command output no error messages, I believe there were no errors in copying my data. So, I do not believe there should be any problem with data integrity.

You said that one should not use Linux to back up Windows. I am not trying to use Linux to back up Windows. I have experience with Linux, and I prefer that operating system. I should have installed Linux as soon as I got my computer, but I did not. That is why I have data in my Windows system. I now want to install Linux, but I first need to make sure my data are safely backed up.

Thank you to both SenorCMasMas and JW0914. I appreciate your input. I would appreciate any additional input you might have to offer, as well as input from others.

12
  • 2
    xcopy or robocooy simply aren't used to backup files (there's literally no use case where this is done) because Microsoft created the WIM file format for that very purpose. Can a bicycle be used for a daily 30 mile commute to work instead of a car, absolutely, it'll get the job done... just not very efficiently. I explain how to backup to WIMs here, or simply Dism /Capture-Image /?, and when wanting to take another backup, Dism /Append-Image /?. This answer is simply not the best way to go about this.
    – JW0914
    Jun 1, 2022 at 4:25
  • Thank you for the information. I will study this. Jun 1, 2022 at 4:30
  • (Cont'd...) The reasons why xcopy/robocopy aren't used to backup files: (1) Parity: while xcopy /v verifies a copied file is identical to the source, this isn't parity. WIMs contain a hash of every file contained within them and their data is impossible to corrupt provided /CheckIntegrity /Verify are always used; (2) Efficiency: xcopy/robocopy have no compression, making it storage inefficient for backups, whereas WIMs utilize the same unchanged copy of a file from previous images (hash verified). File History is another backup method, but nothing comes close to WIMs
    – JW0914
    Jun 1, 2022 at 4:43
  • Once again, thank you. Jun 1, 2022 at 4:54
  • I realized the second comment could come across as berating, which wasn't my intention - I had started writing it after I posted the first comment because I prefer providing an in-depth reason when I down vote, however I got distracted with something else while writing it so it wasn't posted immediately following the first.
    – JW0914
    Jun 1, 2022 at 13:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .