How to back up your files using the Command prompt

Reading time icon 4 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team. Read more

Regularly backing up your Windows files is as essential as having a routine Windows update. This is because a backup not only protects you from random data corruption, which can creep on your PC for a myriad of reasons, but it also keeps a check on the loss of data caused by human errors, malware attacks, and so on.

Weโ€™ve previously covered how to back up your files using the System Restore, File History, etc. But thatโ€™s not all. Yet another, more straightforward method will do the job just as well; weโ€™re, of course, talking about the Command prompt. โ€จโ€จโ€จCommand prompt offers you a slew of commands to ehlp you create a backup for your files.

Letโ€™s go over all of them one by one.

How can I back up files using Command Prompt?

1. Robocopy

The Robocopy command is a handy Cmd command that can copy any of your Windows files with ease. โ€จโ€จWith Robocopy you can copy all the files or subdirectories from the source folder to the destination folder, including empty directories.

To backup your files using the Robocopy command, run the following snippet in Command prompt and hit Enter:

robocopy "source folder path" "destination folder path"/e /mir /r:1 /w:1 /np /log: "log file path"

Here, replace the โ€œsource folder pathโ€ with the path of source folder in realtime; similarly for โ€œdestination folder path.โ€ The /mir option will then mirror the source folder to the destination folder; this means the destination folder will also delete any deleted files from sources.

Also, the /r and /w parameters will specify the number of retries and wait time in case of any errors. At the same time, the /np and /log parameters specifies the progress of the backup and maintain a log file of the backup, respectively.

For example, to copy a file โ€˜file1โ€™ from the Downloads folder in D: drive to E: drive, the command will be something like this:

โ€จrobocopy D:\Downloads\file1 E:\ /MIR

2. XCOPY

Yet another powerful tool offered by Command prompt, the XCOPY command copies your files from one location to another. This command is handy in copying all files and subdirectories from the source folder to the destination folder, including any files and empty directories.

To run the XCOPY command, use the following format:

xcopy /s /e /h /i /y "source folder path" "destination folder path"

Again, for example, if you want to backup an entire folder from one place, letโ€™s say, the Downloads folder in C: drive, to E: drive, youโ€™ll run a command that will look something like this:

xcopy C:\Users\shaantminhas\Downloads E:\ /s /v

The parameters /s and /v are useful for copying directories and subdirectories and verifying each downloaded file respectively.

3. Wbadmin

Want to back up your operating system files to protect them from random corruptions and errors? โ€จโ€จThe Wbadmin will come to your rescue here, letting you back up and quickly restore your operating systems, volume, files, or application.

Hereโ€™s how to create a backup with Wbadmin in Command prompt:

wbadmin start backup -backupTarget:<BackupDrive>: -allCritical -systemState -quiet

Type the above command in Cmd and hit Enter.

From above, replace the โ€œBackupDriveโ€ with the drive letter or network location where youโ€™d like to store the backup on your PC.โ€จโ€จโ€จ You can back up a specific file or folder with Wbadmin as well. For example, to create a backup of your drive D: in your drive F:, type in the following command and hit Enter:

wbAdmin start backup -backupTarget:D: -include:F: -allCritical -quiet

Additonally, to set a backup for your PC at a specific time, type in the following commands:

wbadmin enable backup -addTarget:<BackupDrive>: -schedule:00:00 -quiet

Here, replace โ€œBackupDriveโ€ with the drive letters or network letters where youโ€™d like to store your data, and โ€œ00:00โ€ with the time you want to perform this backup.

You can explore many other combinations like this, with the help of different parameters.

To learn more about these commands, we have a great copy vs xcopy vs robocopy guide that should help you.

Backing up your files using the Command prompt

Keeping a regular backup of your Windows files is as essential as getting regular, timely updates for your PC. Following some of the above commands, you can back up your files using the Command prompt for good in no time as well.

User forum

0 messages