How to copy directory and ignore errorsCompare directories but not content of filesMove directories despite...

Existence of a certain set of 0/1-sequences without the Axiom of Choice

Number of matrices with bounded products of rows and columns

Is there a utility / method to organize trad gear so that each piece is immediately accessible?

Are unaudited server logs admissible in a court of law?

Radix2 Fast Fourier Transform implemented in C++

How does the illumination of the sky from the sun compare to that of the moon?

Why don't modern jet engines use forced exhaust mixing?

What happened after the end of the Truman Show?

Why is su world executable?

Why can't I see 1861 / 1871 census entries on Freecen website when I can see them on Ancestry website?

Meaning of words заштырить and отштырить

Why does current not increase when batteries connected in parallel?

Rotate List by K places

Can the front glass be repaired of a broken lens?

What happens to thrust and drag in a straight and level flight?

Is it alright to say good afternoon Sirs and Madams in a panel interview?

How to detect a failed AES256 decryption programmatically?

Meaning and structure of headline "Hair it is: A List of ..."

Levenshtein Neighbours

Have made several mistakes during the course of my PhD. Can't help but feel resentment. Can I get some advice about how to move forward?

Are there any OR challenges that are similar to kaggle's competitions?

Which basis does the wavefunction collapse to?

Do banks' profitability really suffer under low interest rates

Polar contour plot in Mathematica?



How to copy directory and ignore errors


Compare directories but not content of filesMove directories despite of errorsMusic management software that sync playlists onto Android deviceHow can a filesystem be copied exactly as is?How does SELinux / SEAndroid prevent or allow pseudo terminal allocation?Use a Linux directory as a USB-OTG device to an Android phone?Can't show the content of /sdcard of my Android phone from sftp in Ubuntu's Nautilus or FileZillaAndroid Studio: Running application in emulator not workingLinux kernel error “No working init found"How to get the Samsung Galaxy S5 to work with MTP on Debian 9?Running scripts/commands from a host system in a chroot environment.Rsync a folder as root on a rooted android device






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I have a root Linux shell open on my Android device, and while using cp to copy a directory, I get an error. I think I know where the error is coming from, so that is not my question.



I want to find a command that will allow me to copy everything within this directory that it can, and not just quit upon encountering an error. This is an example of what happens right now:



root@flo:/ # cp -r -v /d/* /sdcard/test/
cp '/d/TRRS'
cp: xread: Invalid argument
1|root@flo:/ #


How should I go about this?










share|improve this question




















  • 1





    What does ls -l /d/TRRS say?

    – Kusalananda
    Jan 7 '17 at 21:19






  • 1





    You may think that error is secondary but cp -r is actually meant to do what you're asking. It does accept a force option (-f) but I don't think it would overcome a fatal error like you're getting.

    – Julie Pelletier
    Jan 7 '17 at 21:21











  • @Kusalananda ls -l /d/TRRS gives: -r--r--r-- root root 0 1969-12-31 19:00 TRRS

    – josh798
    Jan 7 '17 at 21:28













  • What do you get from ls -la /d/.?

    – Julie Pelletier
    Jan 7 '17 at 21:37











  • @JuliePelletier Here's what I get from ls -la /d/.. And just to reiterate, I'm pretty sure I know why it is failing, but I just need a command that can recover from this type of error.

    – josh798
    Jan 7 '17 at 22:16




















1















I have a root Linux shell open on my Android device, and while using cp to copy a directory, I get an error. I think I know where the error is coming from, so that is not my question.



I want to find a command that will allow me to copy everything within this directory that it can, and not just quit upon encountering an error. This is an example of what happens right now:



root@flo:/ # cp -r -v /d/* /sdcard/test/
cp '/d/TRRS'
cp: xread: Invalid argument
1|root@flo:/ #


How should I go about this?










share|improve this question




















  • 1





    What does ls -l /d/TRRS say?

    – Kusalananda
    Jan 7 '17 at 21:19






  • 1





    You may think that error is secondary but cp -r is actually meant to do what you're asking. It does accept a force option (-f) but I don't think it would overcome a fatal error like you're getting.

    – Julie Pelletier
    Jan 7 '17 at 21:21











  • @Kusalananda ls -l /d/TRRS gives: -r--r--r-- root root 0 1969-12-31 19:00 TRRS

    – josh798
    Jan 7 '17 at 21:28













  • What do you get from ls -la /d/.?

    – Julie Pelletier
    Jan 7 '17 at 21:37











  • @JuliePelletier Here's what I get from ls -la /d/.. And just to reiterate, I'm pretty sure I know why it is failing, but I just need a command that can recover from this type of error.

    – josh798
    Jan 7 '17 at 22:16
















1












1








1


1






I have a root Linux shell open on my Android device, and while using cp to copy a directory, I get an error. I think I know where the error is coming from, so that is not my question.



I want to find a command that will allow me to copy everything within this directory that it can, and not just quit upon encountering an error. This is an example of what happens right now:



root@flo:/ # cp -r -v /d/* /sdcard/test/
cp '/d/TRRS'
cp: xread: Invalid argument
1|root@flo:/ #


How should I go about this?










share|improve this question














I have a root Linux shell open on my Android device, and while using cp to copy a directory, I get an error. I think I know where the error is coming from, so that is not my question.



I want to find a command that will allow me to copy everything within this directory that it can, and not just quit upon encountering an error. This is an example of what happens right now:



root@flo:/ # cp -r -v /d/* /sdcard/test/
cp '/d/TRRS'
cp: xread: Invalid argument
1|root@flo:/ #


How should I go about this?







cp android






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 7 '17 at 21:14









josh798josh798

61 bronze badge




61 bronze badge











  • 1





    What does ls -l /d/TRRS say?

    – Kusalananda
    Jan 7 '17 at 21:19






  • 1





    You may think that error is secondary but cp -r is actually meant to do what you're asking. It does accept a force option (-f) but I don't think it would overcome a fatal error like you're getting.

    – Julie Pelletier
    Jan 7 '17 at 21:21











  • @Kusalananda ls -l /d/TRRS gives: -r--r--r-- root root 0 1969-12-31 19:00 TRRS

    – josh798
    Jan 7 '17 at 21:28













  • What do you get from ls -la /d/.?

    – Julie Pelletier
    Jan 7 '17 at 21:37











  • @JuliePelletier Here's what I get from ls -la /d/.. And just to reiterate, I'm pretty sure I know why it is failing, but I just need a command that can recover from this type of error.

    – josh798
    Jan 7 '17 at 22:16
















  • 1





    What does ls -l /d/TRRS say?

    – Kusalananda
    Jan 7 '17 at 21:19






  • 1





    You may think that error is secondary but cp -r is actually meant to do what you're asking. It does accept a force option (-f) but I don't think it would overcome a fatal error like you're getting.

    – Julie Pelletier
    Jan 7 '17 at 21:21











  • @Kusalananda ls -l /d/TRRS gives: -r--r--r-- root root 0 1969-12-31 19:00 TRRS

    – josh798
    Jan 7 '17 at 21:28













  • What do you get from ls -la /d/.?

    – Julie Pelletier
    Jan 7 '17 at 21:37











  • @JuliePelletier Here's what I get from ls -la /d/.. And just to reiterate, I'm pretty sure I know why it is failing, but I just need a command that can recover from this type of error.

    – josh798
    Jan 7 '17 at 22:16










1




1





What does ls -l /d/TRRS say?

– Kusalananda
Jan 7 '17 at 21:19





What does ls -l /d/TRRS say?

– Kusalananda
Jan 7 '17 at 21:19




1




1





You may think that error is secondary but cp -r is actually meant to do what you're asking. It does accept a force option (-f) but I don't think it would overcome a fatal error like you're getting.

– Julie Pelletier
Jan 7 '17 at 21:21





You may think that error is secondary but cp -r is actually meant to do what you're asking. It does accept a force option (-f) but I don't think it would overcome a fatal error like you're getting.

– Julie Pelletier
Jan 7 '17 at 21:21













@Kusalananda ls -l /d/TRRS gives: -r--r--r-- root root 0 1969-12-31 19:00 TRRS

– josh798
Jan 7 '17 at 21:28







@Kusalananda ls -l /d/TRRS gives: -r--r--r-- root root 0 1969-12-31 19:00 TRRS

– josh798
Jan 7 '17 at 21:28















What do you get from ls -la /d/.?

– Julie Pelletier
Jan 7 '17 at 21:37





What do you get from ls -la /d/.?

– Julie Pelletier
Jan 7 '17 at 21:37













@JuliePelletier Here's what I get from ls -la /d/.. And just to reiterate, I'm pretty sure I know why it is failing, but I just need a command that can recover from this type of error.

– josh798
Jan 7 '17 at 22:16







@JuliePelletier Here's what I get from ls -la /d/.. And just to reiterate, I'm pretty sure I know why it is failing, but I just need a command that can recover from this type of error.

– josh798
Jan 7 '17 at 22:16












1 Answer
1






active

oldest

votes


















0














I had a similar problem where I needed to copy files from one directory to another and continue on errors. The idea was to copy as much as possible with the help of an operating system (in my case Debian) tool and then handle possible errors manually.



I used the hint Julie Pelletier provided in her comment to use rsync. Also I used this answer as template as I wanted to be able to analyze the copy operations which fail.



In summary the solution for your case could be



rsync --archive --itemize-changes --delete /d/ /sdcard/test/


Explanation: rsync copies the contents of your source path (/d/) to your target path (/sdcard/test/). In case the contents already exist in your target directory only the differences will be written (delta-transfer). This allows to abort and continue the process at any time. Failures will be reported without stopping the overall copy operation. rsync per default only performs a "quick check" using file size and last modified time. More criteria can be set (see below).





  • --archive specifies a set of file and directory attributes to be checked for differences


  • --itemize-changes instructs to print a summary for each file. This is very helpful to understand why a file is considered to be different by rsync. This helped me to understand failures of the copy operation. The message is rather cryptic, check the man page to understand it better.


  • --delete specifies to delete files at the target location which do not exists in your source location.


In my specific case I used a modified set of comparison criteria as I copied from one file system to another. Maybe this is helpful in your case as well:



rsync --recursive --links --safe-links --times --group --owner --devices --specials --delete --human-readable --stats --verbose --itemize-changes --progress --modify-window=3 source/ target/


The most notable changes are:





  • --safe-links in order to copy only symbolic links within the copied tree

  • No --perms (was implied by --archive) as permissions were not correctly set on the target filesystem


  • --modify-window=NUM sets a tolerance for the last modification time as those were not correctly set on the target filesystem






share|improve this answer








New contributor



user5534993 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2funix.stackexchange.com%2fquestions%2f335657%2fhow-to-copy-directory-and-ignore-errors%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









    0














    I had a similar problem where I needed to copy files from one directory to another and continue on errors. The idea was to copy as much as possible with the help of an operating system (in my case Debian) tool and then handle possible errors manually.



    I used the hint Julie Pelletier provided in her comment to use rsync. Also I used this answer as template as I wanted to be able to analyze the copy operations which fail.



    In summary the solution for your case could be



    rsync --archive --itemize-changes --delete /d/ /sdcard/test/


    Explanation: rsync copies the contents of your source path (/d/) to your target path (/sdcard/test/). In case the contents already exist in your target directory only the differences will be written (delta-transfer). This allows to abort and continue the process at any time. Failures will be reported without stopping the overall copy operation. rsync per default only performs a "quick check" using file size and last modified time. More criteria can be set (see below).





    • --archive specifies a set of file and directory attributes to be checked for differences


    • --itemize-changes instructs to print a summary for each file. This is very helpful to understand why a file is considered to be different by rsync. This helped me to understand failures of the copy operation. The message is rather cryptic, check the man page to understand it better.


    • --delete specifies to delete files at the target location which do not exists in your source location.


    In my specific case I used a modified set of comparison criteria as I copied from one file system to another. Maybe this is helpful in your case as well:



    rsync --recursive --links --safe-links --times --group --owner --devices --specials --delete --human-readable --stats --verbose --itemize-changes --progress --modify-window=3 source/ target/


    The most notable changes are:





    • --safe-links in order to copy only symbolic links within the copied tree

    • No --perms (was implied by --archive) as permissions were not correctly set on the target filesystem


    • --modify-window=NUM sets a tolerance for the last modification time as those were not correctly set on the target filesystem






    share|improve this answer








    New contributor



    user5534993 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.


























      0














      I had a similar problem where I needed to copy files from one directory to another and continue on errors. The idea was to copy as much as possible with the help of an operating system (in my case Debian) tool and then handle possible errors manually.



      I used the hint Julie Pelletier provided in her comment to use rsync. Also I used this answer as template as I wanted to be able to analyze the copy operations which fail.



      In summary the solution for your case could be



      rsync --archive --itemize-changes --delete /d/ /sdcard/test/


      Explanation: rsync copies the contents of your source path (/d/) to your target path (/sdcard/test/). In case the contents already exist in your target directory only the differences will be written (delta-transfer). This allows to abort and continue the process at any time. Failures will be reported without stopping the overall copy operation. rsync per default only performs a "quick check" using file size and last modified time. More criteria can be set (see below).





      • --archive specifies a set of file and directory attributes to be checked for differences


      • --itemize-changes instructs to print a summary for each file. This is very helpful to understand why a file is considered to be different by rsync. This helped me to understand failures of the copy operation. The message is rather cryptic, check the man page to understand it better.


      • --delete specifies to delete files at the target location which do not exists in your source location.


      In my specific case I used a modified set of comparison criteria as I copied from one file system to another. Maybe this is helpful in your case as well:



      rsync --recursive --links --safe-links --times --group --owner --devices --specials --delete --human-readable --stats --verbose --itemize-changes --progress --modify-window=3 source/ target/


      The most notable changes are:





      • --safe-links in order to copy only symbolic links within the copied tree

      • No --perms (was implied by --archive) as permissions were not correctly set on the target filesystem


      • --modify-window=NUM sets a tolerance for the last modification time as those were not correctly set on the target filesystem






      share|improve this answer








      New contributor



      user5534993 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























        0












        0








        0







        I had a similar problem where I needed to copy files from one directory to another and continue on errors. The idea was to copy as much as possible with the help of an operating system (in my case Debian) tool and then handle possible errors manually.



        I used the hint Julie Pelletier provided in her comment to use rsync. Also I used this answer as template as I wanted to be able to analyze the copy operations which fail.



        In summary the solution for your case could be



        rsync --archive --itemize-changes --delete /d/ /sdcard/test/


        Explanation: rsync copies the contents of your source path (/d/) to your target path (/sdcard/test/). In case the contents already exist in your target directory only the differences will be written (delta-transfer). This allows to abort and continue the process at any time. Failures will be reported without stopping the overall copy operation. rsync per default only performs a "quick check" using file size and last modified time. More criteria can be set (see below).





        • --archive specifies a set of file and directory attributes to be checked for differences


        • --itemize-changes instructs to print a summary for each file. This is very helpful to understand why a file is considered to be different by rsync. This helped me to understand failures of the copy operation. The message is rather cryptic, check the man page to understand it better.


        • --delete specifies to delete files at the target location which do not exists in your source location.


        In my specific case I used a modified set of comparison criteria as I copied from one file system to another. Maybe this is helpful in your case as well:



        rsync --recursive --links --safe-links --times --group --owner --devices --specials --delete --human-readable --stats --verbose --itemize-changes --progress --modify-window=3 source/ target/


        The most notable changes are:





        • --safe-links in order to copy only symbolic links within the copied tree

        • No --perms (was implied by --archive) as permissions were not correctly set on the target filesystem


        • --modify-window=NUM sets a tolerance for the last modification time as those were not correctly set on the target filesystem






        share|improve this answer








        New contributor



        user5534993 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        I had a similar problem where I needed to copy files from one directory to another and continue on errors. The idea was to copy as much as possible with the help of an operating system (in my case Debian) tool and then handle possible errors manually.



        I used the hint Julie Pelletier provided in her comment to use rsync. Also I used this answer as template as I wanted to be able to analyze the copy operations which fail.



        In summary the solution for your case could be



        rsync --archive --itemize-changes --delete /d/ /sdcard/test/


        Explanation: rsync copies the contents of your source path (/d/) to your target path (/sdcard/test/). In case the contents already exist in your target directory only the differences will be written (delta-transfer). This allows to abort and continue the process at any time. Failures will be reported without stopping the overall copy operation. rsync per default only performs a "quick check" using file size and last modified time. More criteria can be set (see below).





        • --archive specifies a set of file and directory attributes to be checked for differences


        • --itemize-changes instructs to print a summary for each file. This is very helpful to understand why a file is considered to be different by rsync. This helped me to understand failures of the copy operation. The message is rather cryptic, check the man page to understand it better.


        • --delete specifies to delete files at the target location which do not exists in your source location.


        In my specific case I used a modified set of comparison criteria as I copied from one file system to another. Maybe this is helpful in your case as well:



        rsync --recursive --links --safe-links --times --group --owner --devices --specials --delete --human-readable --stats --verbose --itemize-changes --progress --modify-window=3 source/ target/


        The most notable changes are:





        • --safe-links in order to copy only symbolic links within the copied tree

        • No --perms (was implied by --archive) as permissions were not correctly set on the target filesystem


        • --modify-window=NUM sets a tolerance for the last modification time as those were not correctly set on the target filesystem







        share|improve this answer








        New contributor



        user5534993 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        share|improve this answer



        share|improve this answer






        New contributor



        user5534993 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        answered 2 days ago









        user5534993user5534993

        1




        1




        New contributor



        user5534993 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




        New contributor




        user5534993 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.



































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%2funix.stackexchange.com%2fquestions%2f335657%2fhow-to-copy-directory-and-ignore-errors%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

            Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

            The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

            Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...