0

I want to run rsync from within WSL and backup my windows copy. (Because the windows tool does not work. If you use it, check your backups! Anyway, so...) I am mounting my backup drive with sudo mount -t drvfs P: /mnt/p and then I use rsync to backup /mnt/c/Users/username/. Though certain directories are read protected and I get permission denied. Is there a way to give rsync (or WSL) the rights to read those files and directories on the windows system?

#!/bin/bash

NAME='Automated-Backup'
LOGSTDERR=/tmp/${NAME}.err
LOGSTDOUT=/tmp/${NAME}.log

sudo mount -t drvfs V: /mnt/v
sudo mount -t drvfs B: /mnt/b

source='/mnt/v/'
target='/mnt/b/Backup'

sudo rsync --delete \
      --exclude='*Trash*' \
      --exclude='$RECYCLE.BIN' \
      --exclude='System Volume Information' \
      -aAXzv \
      --progress \
      $source \
      $target 2>${LOGSTDERR} | tee $LOGSTDLOG

cat $LOGSTDERR
  • Why is this downvoted? – Sören Jul 23 '18 at 16:23
  • Right to downvote should be reserved to responsible users. – Sören Jul 23 '18 at 17:14
1

Here's my suggestion, but it is currently untested.

WSL runs with the same permissions as any other app, so to get full OS filesystem permissions, you'll need to run it as an admin. Find the exe or app for WSL that you use (or open a cmd prompt as admin) and try running bash from there.

Note that there may be good reasons for preventing those accesses, like those files being in use — so I'd also suggest creating a different user and running it from there.

  • Also sudo rsync seems to fix it! – Sören May 10 at 3:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.