LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Copy files to USB drive. How to verify? (https://www.linuxquestions.org/questions/linux-newbie-8/copy-files-to-usb-drive-how-to-verify-4175694312/)

ddenial 04-26-2021 12:40 PM

Copy files to USB drive. How to verify?
 
Hello All

I'm backing up my data into a USB external hard disk in the gnome terminal. After the command finished the job, I entered the 'sync' command several times.

How do I make sure all the files I copied using the cp command have been completely copied to USB drive and that they are not in cache/buffer?

Thanks

teckk 04-26-2021 02:29 PM

Couple of examples.

You could check the 2 dirs for difference.
Code:

a="cow dog cat frog bear moose chicken rat pig"
b="cow dog frog bear moose chicken rat pig"

diff <(echo "$b") <(echo "$a")
1c1
< cow dog frog bear moose chicken rat pig
---
> cow dog cat frog bear moose chicken rat pig

Or check them for matches.
Code:

a="
one
two
three
four
five
"

b="
one
three
four
five
six
"

comm --nocheck-order -13 <(echo "$b") <(echo "$a")
two
three
four
five

See:
man comm
man diff

I watch a system monitor whenever I copy many files to an external drive. When It's done writing to the external, it's done. If cp errors on something, it will tell you.

rtmistler 04-26-2021 02:33 PM

Use the umount command to un-mount the USB. That will force any unresolved file handles to be resolved.

You do not need to issue sync, it helps, but the umount action will perform any actions similar to a sync call. Issuing it multiple times is no improvement though.

jefro 04-26-2021 02:47 PM

"Like many core Linux commands, if the cp command is successful, by default, no output is displayed. To view output when files are copied, use the -v (verbose) option.
"

https://www.computerhope.com/unix/uc...is%20destroyed.

However unlike the dos -verify this only reports that it copied. It doesn't go back and compare the two files.

So, cp may be the wrong program to use in your case.

TB0ne 04-26-2021 04:07 PM

Quote:

Originally Posted by ddenial (Post 6245174)
Hello All
I'm backing up my data into a USB external hard disk in the gnome terminal. After the command finished the job, I entered the 'sync' command several times.

How do I make sure all the files I copied using the cp command have been completely copied to USB drive and that they are not in cache/buffer?
Thanks

Same as you were told the last time you asked:
https://www.linuxquestions.org/quest...ia-4175683939/

After five years of Linux use, it's an odd question to ask (twice).

ddenial 04-26-2021 04:20 PM

Quote:

Originally Posted by TB0ne (Post 6245243)
Same as you were told the last time you asked:
https://www.linuxquestions.org/quest...ia-4175683939/

After five years of Linux use, it's an odd question to ask (twice).

Damn! It's been 5 years since I took my last backup then. I don't even remember. :scratch:

TB0ne 04-26-2021 05:04 PM

Quote:

Originally Posted by ddenial (Post 6245246)
Damn! It's been 5 years since I took my last backup then. I don't even remember. :scratch:

...except the last time you asked was October of last year; six months ago. You've been here five years, and ostensibly using Linux that long.


All times are GMT -5. The time now is 02:48 AM.