Question Can I do a data backup from cmd ?

D

Deleted member 14196

Guest
I think you can do it with the robocopy command using the MIR switch, but I've never used it personally.

Probably other methods too.
Never recommend MIR to n003s. That is expert level only.

if someone doesn’t understand it, it can unintentionally destroy tons of data really quickly. And I know this first hand because someone did it that our company and thank God we have back ups.
 
The one danger with robocopy's /MIR flag is that if the source doesn't have a file that and exists in the destination, it will be deleted in the destination. It literally mirrors the files and directories of the source to the destination.
Indeed, that is a problem for mirrored backup. It's also vulnerable to cryptovirus changing the contents of personal files, then after new backup schedule, the backup copy also become contaminated (assuming user doesn't insert backup drive on an already contaminated computer because then all is lost)

One solution for this: Versioning. I'd looked into this before, and sadly it's no way this can be achieved by native windows tools. As for now, I know ow two ways of solving this:
  • Windows: Use 3. party software. Haven't found a command line tool, but FreeFileSync can do versioning.
  • Linux: A combination or rsync with backup feature and a feature in the shell that can pass t.ex. current date as a variable.
A practical bash command for making a backup with versioning to a sd card may look something like this
$ rsync -abmrtv -L --delete-after --backup-dir='/media/username/media-id/versioning-files/'$(date +"%Y%m%d_%H%M") --log-file='/media/username/media-id/filer/rsync.log' '/home/username/Documents/' '/media/username/media-id/backup-folder/'