I want to back-up all files from my laptop partitions to external HDD.

I ran, for example

cp -a /med*/ravb*/*00   /med*/ravb*/M*L*/7.3GB_CP && echo "7.3GB BACKED UP PROPERLY" || echo "7.3GB FAILED TO BACK UP"

The issue is that dot files are also getting included which I don't want. What should I do so as to ignore all dot files for backing up.

1 Answer 1


Why not use rsync instead? It's made for the job!

rsync -uan --progress --exclude=".*" <source> <destination>

The above will list all the files to be archived without actually copying anything. Check that the list is correct, then run it again with the n option removed in order to copy the files (you could also remove the --progress for a quieter experience).

To expand, the options above are:-

u - 'update' - only copy newer files.

a - 'archive'

n - 'dry-run` - don't copy, just list what it would do.

--progress - show progress of copy

--exclude=".*" - exclude files that begin with a dot

  • Looks great! Yes this is what I wanted. I will run it & update you.
    – Ravi
    Jun 23, 2014 at 13:12
  • Yesterday I backed up all the partitions from laptop to my external HDD using rsync. It's a superb backup tool. Yes you are right, it's made for the job!!! Till now I've used tar, cpio & cp for backup. But this command rsync is the best. The task that seemed to be a bit complex, rsync made it very very easy & comfortable. Really a great versatile command. Had I used tar, then for viewing any backup file, I would have to open with tar archive application (which doesn't give a good interface to view) or I would have to recover from the archive. But with rsync no such issue.
    – Ravi
    Jun 25, 2014 at 10:10
  • One may possibly want to add --include='*/' before the exclusion, to include any directory. Otherwise this would skip hidden directories.
    – Kusalananda
    Feb 11, 2021 at 8:24

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.