LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-26-2021, 12:40 PM   #1
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Rep: Reputation: 56
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
 
Old 04-26-2021, 02:29 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,102
Blog Entries: 6

Rep: Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822
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.
 
1 members found this post helpful.
Old 04-26-2021, 02:33 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,876
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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.
 
1 members found this post helpful.
Old 04-26-2021, 02:47 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,937

Rep: Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619
"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.
 
1 members found this post helpful.
Old 04-26-2021, 04:07 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,553

Rep: Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946
Quote:
Originally Posted by ddenial View Post
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).
 
1 members found this post helpful.
Old 04-26-2021, 04:20 PM   #6
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by TB0ne View Post
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.
 
Old 04-26-2021, 05:04 PM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,553

Rep: Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946
Quote:
Originally Posted by ddenial View Post
Damn! It's been 5 years since I took my last backup then. I don't even remember.
...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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Copy files to a usb stick and automatically encrypt or encrypt files/folders and copy them to usb bmxakias Programming 8 03-14-2020 06:44 PM
Copy and verify a directory in Linux jismagic Linux - Newbie 4 07-29-2014 10:24 AM
Want to change how pasted files are named "(copy)," "(another copy)," "(3rd copy)" L a r r y Linux - Desktop 3 08-24-2013 03:39 PM
Does Linux verify copy and save ? mistofeles Linux - Newbie 4 01-31-2012 06:33 AM
openssl ssl error code 14090086 verify the CA cert is ok / certificate verify failed acummings Slackware 14 02-27-2009 01:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration