Find the answer to your Linux question:
Results 1 to 2 of 2
Hey everyone, I have a harddrive that's failing. I can only access the command line and I need to backup everything to my USB hard drive. Problem is some files ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2007
    Posts
    2

    Terminal command to copy files and skip bad/corrupt ones?


    Hey everyone,

    I have a harddrive that's failing. I can only access the command line and I need to backup everything to my USB hard drive. Problem is some files are corrupt, so I'm doing cp - R /source /destination but as soon as it hits a bad file, it says file not found, or some sort of error and stops. Is there any way at all that I can tell it to copy a folder and all it's sub folders, and if it hits a bad file, just keep on going and skip it? Would make it so much easier.. thanks!

  2. #2
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790
    you could maybe use some sort of bash script and traverse the file structure in /source and copy all files to /destination.

    If you dont need the same structure, then something like:
    Code:
    find /source -type f -iname '*' -exec cp {} /destination \;
    should do.

    Otherwise, you could run some sort of find that will return the directory structure, and then do a similar find to above, but only on that subdirectory, and cp the files.
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •