How can I use rsync to backup personal files to an external hard drive or network drive without having...











up vote
0
down vote

favorite












Background



What is the "correct" method to use rsync to backup data? The reason why I ask for the "correct" method is because my past experience of using rsync has resulted in permissions, file/folder mask, and timestamp related issues. Therefore, this question seeks to understand how can I use rsync to backup data without running into any permission, file/folder mask, or timestamp related issues, primarily when rsync is being used on a Windows system.



Another motivation for this question is to ensure that I don't into my previous issue where I was unable to access any files on my external drive which was backed up with rsync via cygwin. This was a nightmare because I had actually lost data on my main PC and was trying to restore it from the backup.



Below are similar issues I have ran into when using rysnc:




  • Unable to access any files on external drive that was backed up using rsync Rsync and Cygwin based backup on Windows gives permission denied errors

  • Unable to preserve timestamp https://unix.stackexchange.com/questions/61586/how-to-tell-rsync-to-preserve-time-stamp-on-files-when-source-tree-has-a-mounted

  • rsync - mkstemp failed issue https://stackoverflow.com/questions/11039559/rsync-mkstemp-failed-permission-denied-13


My understanding of rsync usage is intermediate and I have referred to the guides listed below. However, my biggest confusion of rsync usage comes from permissions, file/folder masking, Posix, etc.





  • The Non-Beginner’s Guide to Syncing Data with Rsync

  • Rsync man page


Requirements/Assumptions




  • I want to use rsync in the context of "backup" and NOT in the conext of "sync". Often other users asking questions related to rsync may be interested in "syncing" data to ensure they have a working copy of files on another PC in sync. However, my intention is not for "syncing" but simply "backing up", such that if anything happens to my PC, I can get a last backup copy and restore it.

  • The original files that need to be backed up could exist on any operating system (ex: Windows, Ubuntu, MacOS), but primarily on Windows.

  • On Windows, rsync is used using Windows Subsystem for Linux (WSL) and NOT through cygwin

  • The destination for the backup could be an external drive formatted as NTFS, FAT32, or exFAT or it can be a network drive (ex: Samba share).

  • This is not required, but destination could be connected to using SSH


My current method & issues



I am using rsync through Windows Subsystem for Linux (WSL) on Windows 10. Below are example example issues I have run into:



Example 1: Not working



rsync -avhP --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method results in files NOT being transferred and errors like below:



rsync: chgrp "/mnt/my_usb_mount/ProjectA/src" failed: Operation not permitted (1)


and



rsync: mkstemp "/mnt/my_usb_mount/ProjectA/src/.mydata.json.6cfTCf" failed: Operation not permitted (1)


Example 2: Partially working



rsync -avhP --no-p --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


or



rsync -avhP --no-p --chmod=ugo=rwX --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method of using rysnc results in files being transferred but the timestamp (created, modified, accessed) are all set to the time of the transfer. If I run the rsync command again, all the files will be detected as modified and get re-transferred because of the incorrect timestamp. In addition I get errors like below:



rsync: chgrp "/mnt/my_usb_mount/ProjectA/src" failed: Operation not permitted (1)


Example 3: Correctly working.



sudo rsync -avhP --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method work perfectly, however, I don't understand why I have to use sudo? Is it because I am using rsync on Windows through WSL? Would I have to use sudo if I were backing up files from a Linux PC (ex: Ubuntu)?



Although example 3 is a working solution, I still have many questions:




  • How do I know when sudo is required?

  • When do I use --no-p or --chmod=ugo=rwX

  • What if I don't have permissions to use sudo?

  • Will it work if I were backing up files to a network drive?

  • What if I am using SSH?

  • When using rsync from Windows through WSL, will I ever run into weird permission or file/folder mask issues as I previously have?










share|improve this question
























  • You need to use "sudo" because you are not root, and backing up files created with users other then yourself, including correct metadata requires root access. SSH won't directly help you, although rsync can (and often does) run over ssh. You would typically use sudo if backing up files you do not own in Linux.
    – davidgo
    Dec 4 at 8:29










  • The --chmod=ugo=rwX would probably be required when your filesystem does not support Posix permissions, or you have read permissions but not the appropriate permissions for a file. If you don't have permission to use sudo, you get it or know you will loose some functionality for files you do not own. If you back up on a network drive then the permissions are limited by what the network drive supports. You can use tar archives if you want to preserve perms - but you may want to back up /etc/passwd as well which holds user mappings.
    – davidgo
    Dec 4 at 8:32















up vote
0
down vote

favorite












Background



What is the "correct" method to use rsync to backup data? The reason why I ask for the "correct" method is because my past experience of using rsync has resulted in permissions, file/folder mask, and timestamp related issues. Therefore, this question seeks to understand how can I use rsync to backup data without running into any permission, file/folder mask, or timestamp related issues, primarily when rsync is being used on a Windows system.



Another motivation for this question is to ensure that I don't into my previous issue where I was unable to access any files on my external drive which was backed up with rsync via cygwin. This was a nightmare because I had actually lost data on my main PC and was trying to restore it from the backup.



Below are similar issues I have ran into when using rysnc:




  • Unable to access any files on external drive that was backed up using rsync Rsync and Cygwin based backup on Windows gives permission denied errors

  • Unable to preserve timestamp https://unix.stackexchange.com/questions/61586/how-to-tell-rsync-to-preserve-time-stamp-on-files-when-source-tree-has-a-mounted

  • rsync - mkstemp failed issue https://stackoverflow.com/questions/11039559/rsync-mkstemp-failed-permission-denied-13


My understanding of rsync usage is intermediate and I have referred to the guides listed below. However, my biggest confusion of rsync usage comes from permissions, file/folder masking, Posix, etc.





  • The Non-Beginner’s Guide to Syncing Data with Rsync

  • Rsync man page


Requirements/Assumptions




  • I want to use rsync in the context of "backup" and NOT in the conext of "sync". Often other users asking questions related to rsync may be interested in "syncing" data to ensure they have a working copy of files on another PC in sync. However, my intention is not for "syncing" but simply "backing up", such that if anything happens to my PC, I can get a last backup copy and restore it.

  • The original files that need to be backed up could exist on any operating system (ex: Windows, Ubuntu, MacOS), but primarily on Windows.

  • On Windows, rsync is used using Windows Subsystem for Linux (WSL) and NOT through cygwin

  • The destination for the backup could be an external drive formatted as NTFS, FAT32, or exFAT or it can be a network drive (ex: Samba share).

  • This is not required, but destination could be connected to using SSH


My current method & issues



I am using rsync through Windows Subsystem for Linux (WSL) on Windows 10. Below are example example issues I have run into:



Example 1: Not working



rsync -avhP --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method results in files NOT being transferred and errors like below:



rsync: chgrp "/mnt/my_usb_mount/ProjectA/src" failed: Operation not permitted (1)


and



rsync: mkstemp "/mnt/my_usb_mount/ProjectA/src/.mydata.json.6cfTCf" failed: Operation not permitted (1)


Example 2: Partially working



rsync -avhP --no-p --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


or



rsync -avhP --no-p --chmod=ugo=rwX --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method of using rysnc results in files being transferred but the timestamp (created, modified, accessed) are all set to the time of the transfer. If I run the rsync command again, all the files will be detected as modified and get re-transferred because of the incorrect timestamp. In addition I get errors like below:



rsync: chgrp "/mnt/my_usb_mount/ProjectA/src" failed: Operation not permitted (1)


Example 3: Correctly working.



sudo rsync -avhP --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method work perfectly, however, I don't understand why I have to use sudo? Is it because I am using rsync on Windows through WSL? Would I have to use sudo if I were backing up files from a Linux PC (ex: Ubuntu)?



Although example 3 is a working solution, I still have many questions:




  • How do I know when sudo is required?

  • When do I use --no-p or --chmod=ugo=rwX

  • What if I don't have permissions to use sudo?

  • Will it work if I were backing up files to a network drive?

  • What if I am using SSH?

  • When using rsync from Windows through WSL, will I ever run into weird permission or file/folder mask issues as I previously have?










share|improve this question
























  • You need to use "sudo" because you are not root, and backing up files created with users other then yourself, including correct metadata requires root access. SSH won't directly help you, although rsync can (and often does) run over ssh. You would typically use sudo if backing up files you do not own in Linux.
    – davidgo
    Dec 4 at 8:29










  • The --chmod=ugo=rwX would probably be required when your filesystem does not support Posix permissions, or you have read permissions but not the appropriate permissions for a file. If you don't have permission to use sudo, you get it or know you will loose some functionality for files you do not own. If you back up on a network drive then the permissions are limited by what the network drive supports. You can use tar archives if you want to preserve perms - but you may want to back up /etc/passwd as well which holds user mappings.
    – davidgo
    Dec 4 at 8:32













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Background



What is the "correct" method to use rsync to backup data? The reason why I ask for the "correct" method is because my past experience of using rsync has resulted in permissions, file/folder mask, and timestamp related issues. Therefore, this question seeks to understand how can I use rsync to backup data without running into any permission, file/folder mask, or timestamp related issues, primarily when rsync is being used on a Windows system.



Another motivation for this question is to ensure that I don't into my previous issue where I was unable to access any files on my external drive which was backed up with rsync via cygwin. This was a nightmare because I had actually lost data on my main PC and was trying to restore it from the backup.



Below are similar issues I have ran into when using rysnc:




  • Unable to access any files on external drive that was backed up using rsync Rsync and Cygwin based backup on Windows gives permission denied errors

  • Unable to preserve timestamp https://unix.stackexchange.com/questions/61586/how-to-tell-rsync-to-preserve-time-stamp-on-files-when-source-tree-has-a-mounted

  • rsync - mkstemp failed issue https://stackoverflow.com/questions/11039559/rsync-mkstemp-failed-permission-denied-13


My understanding of rsync usage is intermediate and I have referred to the guides listed below. However, my biggest confusion of rsync usage comes from permissions, file/folder masking, Posix, etc.





  • The Non-Beginner’s Guide to Syncing Data with Rsync

  • Rsync man page


Requirements/Assumptions




  • I want to use rsync in the context of "backup" and NOT in the conext of "sync". Often other users asking questions related to rsync may be interested in "syncing" data to ensure they have a working copy of files on another PC in sync. However, my intention is not for "syncing" but simply "backing up", such that if anything happens to my PC, I can get a last backup copy and restore it.

  • The original files that need to be backed up could exist on any operating system (ex: Windows, Ubuntu, MacOS), but primarily on Windows.

  • On Windows, rsync is used using Windows Subsystem for Linux (WSL) and NOT through cygwin

  • The destination for the backup could be an external drive formatted as NTFS, FAT32, or exFAT or it can be a network drive (ex: Samba share).

  • This is not required, but destination could be connected to using SSH


My current method & issues



I am using rsync through Windows Subsystem for Linux (WSL) on Windows 10. Below are example example issues I have run into:



Example 1: Not working



rsync -avhP --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method results in files NOT being transferred and errors like below:



rsync: chgrp "/mnt/my_usb_mount/ProjectA/src" failed: Operation not permitted (1)


and



rsync: mkstemp "/mnt/my_usb_mount/ProjectA/src/.mydata.json.6cfTCf" failed: Operation not permitted (1)


Example 2: Partially working



rsync -avhP --no-p --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


or



rsync -avhP --no-p --chmod=ugo=rwX --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method of using rysnc results in files being transferred but the timestamp (created, modified, accessed) are all set to the time of the transfer. If I run the rsync command again, all the files will be detected as modified and get re-transferred because of the incorrect timestamp. In addition I get errors like below:



rsync: chgrp "/mnt/my_usb_mount/ProjectA/src" failed: Operation not permitted (1)


Example 3: Correctly working.



sudo rsync -avhP --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method work perfectly, however, I don't understand why I have to use sudo? Is it because I am using rsync on Windows through WSL? Would I have to use sudo if I were backing up files from a Linux PC (ex: Ubuntu)?



Although example 3 is a working solution, I still have many questions:




  • How do I know when sudo is required?

  • When do I use --no-p or --chmod=ugo=rwX

  • What if I don't have permissions to use sudo?

  • Will it work if I were backing up files to a network drive?

  • What if I am using SSH?

  • When using rsync from Windows through WSL, will I ever run into weird permission or file/folder mask issues as I previously have?










share|improve this question















Background



What is the "correct" method to use rsync to backup data? The reason why I ask for the "correct" method is because my past experience of using rsync has resulted in permissions, file/folder mask, and timestamp related issues. Therefore, this question seeks to understand how can I use rsync to backup data without running into any permission, file/folder mask, or timestamp related issues, primarily when rsync is being used on a Windows system.



Another motivation for this question is to ensure that I don't into my previous issue where I was unable to access any files on my external drive which was backed up with rsync via cygwin. This was a nightmare because I had actually lost data on my main PC and was trying to restore it from the backup.



Below are similar issues I have ran into when using rysnc:




  • Unable to access any files on external drive that was backed up using rsync Rsync and Cygwin based backup on Windows gives permission denied errors

  • Unable to preserve timestamp https://unix.stackexchange.com/questions/61586/how-to-tell-rsync-to-preserve-time-stamp-on-files-when-source-tree-has-a-mounted

  • rsync - mkstemp failed issue https://stackoverflow.com/questions/11039559/rsync-mkstemp-failed-permission-denied-13


My understanding of rsync usage is intermediate and I have referred to the guides listed below. However, my biggest confusion of rsync usage comes from permissions, file/folder masking, Posix, etc.





  • The Non-Beginner’s Guide to Syncing Data with Rsync

  • Rsync man page


Requirements/Assumptions




  • I want to use rsync in the context of "backup" and NOT in the conext of "sync". Often other users asking questions related to rsync may be interested in "syncing" data to ensure they have a working copy of files on another PC in sync. However, my intention is not for "syncing" but simply "backing up", such that if anything happens to my PC, I can get a last backup copy and restore it.

  • The original files that need to be backed up could exist on any operating system (ex: Windows, Ubuntu, MacOS), but primarily on Windows.

  • On Windows, rsync is used using Windows Subsystem for Linux (WSL) and NOT through cygwin

  • The destination for the backup could be an external drive formatted as NTFS, FAT32, or exFAT or it can be a network drive (ex: Samba share).

  • This is not required, but destination could be connected to using SSH


My current method & issues



I am using rsync through Windows Subsystem for Linux (WSL) on Windows 10. Below are example example issues I have run into:



Example 1: Not working



rsync -avhP --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method results in files NOT being transferred and errors like below:



rsync: chgrp "/mnt/my_usb_mount/ProjectA/src" failed: Operation not permitted (1)


and



rsync: mkstemp "/mnt/my_usb_mount/ProjectA/src/.mydata.json.6cfTCf" failed: Operation not permitted (1)


Example 2: Partially working



rsync -avhP --no-p --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


or



rsync -avhP --no-p --chmod=ugo=rwX --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method of using rysnc results in files being transferred but the timestamp (created, modified, accessed) are all set to the time of the transfer. If I run the rsync command again, all the files will be detected as modified and get re-transferred because of the incorrect timestamp. In addition I get errors like below:



rsync: chgrp "/mnt/my_usb_mount/ProjectA/src" failed: Operation not permitted (1)


Example 3: Correctly working.



sudo rsync -avhP --delete /mnt/c/Users/MyUsername/ProjectA /mnt/my_usb_mount/Backup


This method work perfectly, however, I don't understand why I have to use sudo? Is it because I am using rsync on Windows through WSL? Would I have to use sudo if I were backing up files from a Linux PC (ex: Ubuntu)?



Although example 3 is a working solution, I still have many questions:




  • How do I know when sudo is required?

  • When do I use --no-p or --chmod=ugo=rwX

  • What if I don't have permissions to use sudo?

  • Will it work if I were backing up files to a network drive?

  • What if I am using SSH?

  • When using rsync from Windows through WSL, will I ever run into weird permission or file/folder mask issues as I previously have?







linux windows backup permissions rsync






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 5 at 5:26

























asked Dec 4 at 7:29









Zythyr

16618




16618












  • You need to use "sudo" because you are not root, and backing up files created with users other then yourself, including correct metadata requires root access. SSH won't directly help you, although rsync can (and often does) run over ssh. You would typically use sudo if backing up files you do not own in Linux.
    – davidgo
    Dec 4 at 8:29










  • The --chmod=ugo=rwX would probably be required when your filesystem does not support Posix permissions, or you have read permissions but not the appropriate permissions for a file. If you don't have permission to use sudo, you get it or know you will loose some functionality for files you do not own. If you back up on a network drive then the permissions are limited by what the network drive supports. You can use tar archives if you want to preserve perms - but you may want to back up /etc/passwd as well which holds user mappings.
    – davidgo
    Dec 4 at 8:32


















  • You need to use "sudo" because you are not root, and backing up files created with users other then yourself, including correct metadata requires root access. SSH won't directly help you, although rsync can (and often does) run over ssh. You would typically use sudo if backing up files you do not own in Linux.
    – davidgo
    Dec 4 at 8:29










  • The --chmod=ugo=rwX would probably be required when your filesystem does not support Posix permissions, or you have read permissions but not the appropriate permissions for a file. If you don't have permission to use sudo, you get it or know you will loose some functionality for files you do not own. If you back up on a network drive then the permissions are limited by what the network drive supports. You can use tar archives if you want to preserve perms - but you may want to back up /etc/passwd as well which holds user mappings.
    – davidgo
    Dec 4 at 8:32
















You need to use "sudo" because you are not root, and backing up files created with users other then yourself, including correct metadata requires root access. SSH won't directly help you, although rsync can (and often does) run over ssh. You would typically use sudo if backing up files you do not own in Linux.
– davidgo
Dec 4 at 8:29




You need to use "sudo" because you are not root, and backing up files created with users other then yourself, including correct metadata requires root access. SSH won't directly help you, although rsync can (and often does) run over ssh. You would typically use sudo if backing up files you do not own in Linux.
– davidgo
Dec 4 at 8:29












The --chmod=ugo=rwX would probably be required when your filesystem does not support Posix permissions, or you have read permissions but not the appropriate permissions for a file. If you don't have permission to use sudo, you get it or know you will loose some functionality for files you do not own. If you back up on a network drive then the permissions are limited by what the network drive supports. You can use tar archives if you want to preserve perms - but you may want to back up /etc/passwd as well which holds user mappings.
– davidgo
Dec 4 at 8:32




The --chmod=ugo=rwX would probably be required when your filesystem does not support Posix permissions, or you have read permissions but not the appropriate permissions for a file. If you don't have permission to use sudo, you get it or know you will loose some functionality for files you do not own. If you back up on a network drive then the permissions are limited by what the network drive supports. You can use tar archives if you want to preserve perms - but you may want to back up /etc/passwd as well which holds user mappings.
– davidgo
Dec 4 at 8:32










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Ntfs and fat don't care about linux permission, you must make you're backup on a partition ext4



or make a backup and compress it into tar.gz and then decompress it on a linux system file and restore it






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1380612%2fhow-can-i-use-rsync-to-backup-personal-files-to-an-external-hard-drive-or-networ%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Ntfs and fat don't care about linux permission, you must make you're backup on a partition ext4



    or make a backup and compress it into tar.gz and then decompress it on a linux system file and restore it






    share|improve this answer

























      up vote
      0
      down vote













      Ntfs and fat don't care about linux permission, you must make you're backup on a partition ext4



      or make a backup and compress it into tar.gz and then decompress it on a linux system file and restore it






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Ntfs and fat don't care about linux permission, you must make you're backup on a partition ext4



        or make a backup and compress it into tar.gz and then decompress it on a linux system file and restore it






        share|improve this answer












        Ntfs and fat don't care about linux permission, you must make you're backup on a partition ext4



        or make a backup and compress it into tar.gz and then decompress it on a linux system file and restore it







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 4 at 9:34









        lejurassien

        185




        185






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1380612%2fhow-can-i-use-rsync-to-backup-personal-files-to-an-external-hard-drive-or-networ%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

            Eduardo VII do Reino Unido