How to copy a directory from one hard drive to another with every single file?

69,739

Solution 1

I would use rsync for this so that if there is an error (or you need to stop copying) partway through you can easily resume later, without having to recopy everything.

rsync -av /media/sdc1/Pictures/ /media/sdb1/Pictures/

Solution 2

cp -r /media/sdc1/Pictures/* /media/sdb1/Pictures/some_dir

  • The -r is recursive, read the man page...
  • With /media/sdc1/Pictures/* the asterisk is to copy all the contents of /media/sdc1/Pictures/, but not the parent directory itself.
  • The some_dir of /media/sdb1/Pictures/some_dir is where you want to put it.

Solution 3

If you need an exact image, use the command dd if=(path) of=(path)

Share:
69,739

Related videos on Youtube

wardr
Author by

wardr

I am a grad student single father with 2 daughters, 1 I am raising myself and 1 that has been kidnapped from me. We currently live in Northern California.

Updated on September 18, 2022

Comments

  • wardr
    wardr almost 2 years

    I have a folder I just luckily recovered sitting on:

    /media/sdc1/Pictures
    

    with a BUNCH of subdirectories and files that I need.

    I want to copy these to a folder on:

    /media/sdb1/Pictures
    

    What command do I have to use in the terminal to make sure this happens? I know there is the cp command. But is that the best choice? And if so what options should I use to ensure I get every single directory and file?

  • geirha
    geirha about 11 years
    I'd remove the * since it will omit dotfiles at the first level. It may also cause it to exceed the ARG_MAX limit.
  • amc
    amc about 11 years
    @geirha good point. edited.
  • MikeSchem
    MikeSchem about 7 years
    Beware, this command could completely kill you computer if used incorrectly
  • farinspace
    farinspace about 6 years
    will this copy dotfiles and dotdirs as well?
  • mook765
    mook765 almost 6 years
    You can't copy directories with dd!
  • Pithikos
    Pithikos about 4 years
    And to resume I need to use the same command again?
  • amc
    amc about 4 years
    Yes, rerunning the command will reassess what’s changed and resume the transfer, effectively picking up where it left off previously