Approve the Cookies
This website uses cookies to improve your user experience. By using this site, you agree to our use of cookies and our Privacy Policy.
OK
Forums  •   • New posts  •   • RTAT  •   • 'Best of'  •   • Gallery  •   • Gear
Guest
Forums  •   • New posts  •   • RTAT  •   • 'Best of'  •   • Gallery  •   • Gear
Register to forums    Log in

 
FORUMS General Gear Talk Computers 
Thread started 24 Apr 2022 (Sunday) 22:01
Search threadPrev/next
sponsored links (only for non-logged)

Linux guru wanted

 
RodS57
Goldmember
1,463 posts
Gallery: 185 photos
Likes: 1740
Joined Jun 2014
Location: Eastern Canada
     
Apr 24, 2022 22:01 |  #1

Story line:

March 4th I powered up my laptop only to get a "no operating system found" message or something to that effect. Removed the drive and via a USB adapter hooked it up to another computer. Nothing. The drive did not exist.

My back-ups are such that I may have lost a few emails, nothing more. Most of the recovery data is on an exfat formatted external drive which means I lost time stamps etc. Everyone using the dos file system has experienced this short coming. My solution was two new hard drives formatted Linux ext4 for my back-up drives. Rebuild is pretty much complete.

My question: I'm using the cp command for the back-up process. Explicitly cp -R -T -u ~/source /path//destination
Do I need the -p switch.

Assuming source is a directory what is the difference between
cp -R -T -u ~/source /path//destination (label 1)
and
cp -R -T -u ~/source /path//destination/ (label 2) note the trailing /

From my experience (label 1) copies the files from directory source into directory destination while
(Label 2) copies the directory so you end up with destination/source

Can anyone confirm this.

Thanks
Rod


>>> Pictures? What pictures? <<<<

  
  LOG IN TO REPLY
drsilver
Goldmember
Avatar
2,645 posts
Gallery: 904 photos
Best ofs: 4
Likes: 10574
Joined Mar 2010
Location: North Bend, WA
     
Apr 25, 2022 09:45 |  #2

The trailing slash in a directory path doesn't matter. Linux is smart enough to know when a file is a directory or a regular file.

I think your problem is with the -T option. In 30 years of banging on Unix command lines, I've never used that option. I had to look it up.

From the man page for cp:
-T, --no-target-directory
treat DEST as a normal file

So it's the -T that's unpacking your directory and putting its contents in the new directory. Without the -T, you copy the whole directory and its contents into the DEST directory.

BTW, the -p option copies the file permissions and properties (date stamp and ownership, specifically) along with file itself. Without the -p option, the copied files appear as new files that belong to you with a new date stamp, regardless of when or by whom the original file was created.


Flickr (external link) : Instagram (web)] (external link)

  
  LOG IN TO REPLY
RodS57
THREAD ­ STARTER
Goldmember
1,463 posts
Gallery: 185 photos
Likes: 1740
Joined Jun 2014
Location: Eastern Canada
     
Apr 25, 2022 11:10 as a reply to  @ drsilver's post |  #3

Thanks. That explains one mystery. Through trial and error I've managed to add/remove the trailing / to get things to go where I want them to go. Still, I am concerned about the missing -p and what using it means for the -u option. Right now spot checks on files tell me the script works as intended. I am worried that adding the -p will break it.

For me, I have to decide if the time stamps are that important. My last back-up with accurate file time stamp data is February 6, 2022. Correcting time stamps. It can be done.

Of course, Murphy's Law kicked in. I had ordered/received two, what was described as external hard drives off Amazon. They turned out to be a memory chip with a fake file system. I was waiting for real drives to arrive when the crash occurred. Oh well.

Rod


>>> Pictures? What pictures? <<<<

  
  LOG IN TO REPLY
drsilver
Goldmember
Avatar
2,645 posts
Gallery: 904 photos
Best ofs: 4
Likes: 10574
Joined Mar 2010
Location: North Bend, WA
     
Apr 25, 2022 14:39 |  #4

Without seeing your code, I don't know if starting to use the -p option would mess up the results from the -u option, but a quick mental exercise makes me believe you'd probably be OK.

From the man page:
-u, --update
copy only when the SOURCE file is newer than the destination file or when the destination file is missing


The original file, from your card, will always be as old or older than any other copy of that file. I'm thinking -u should never find files older than ones already present in your backup set.

As always, keep a copy of your last good script, and test, test, test.


Flickr (external link) : Instagram (web)] (external link)

  
  LOG IN TO REPLY
RodS57
THREAD ­ STARTER
Goldmember
1,463 posts
Gallery: 185 photos
Likes: 1740
Joined Jun 2014
Location: Eastern Canada
     
Apr 25, 2022 16:09 |  #5

drsilver wrote in post #19371018 (external link)
Without seeing your code, I don't know if starting to use the -p option would mess up the results from the -u option, but a quick mental exercise makes me believe you'd probably be OK.

From the man page:
-u, --update
copy only when the SOURCE file is newer than the destination file or when the destination file is missing


The original file, from your card, will always be as old or older than any other copy of that file. I'm thinking -u should never find files older than ones already present in your backup set.

As always, keep a copy of your last good script, and test, test, test.

The code is as above, copied here again cp -R -T -u ~/source /path/destination

My brother found the code on the net somewhere and sent it to me. I checked the man page, ran it with my then working computer every week for a few months and here we are.
There were no big question marks until my HD crashed and the need became real.

Thanks for the insights.

Rod


>>> Pictures? What pictures? <<<<

  
  LOG IN TO REPLY
RodS57
THREAD ­ STARTER
Goldmember
1,463 posts
Gallery: 185 photos
Likes: 1740
Joined Jun 2014
Location: Eastern Canada
     
May 16, 2022 19:49 |  #6

I guess to sort of close out this thread, I added the -p switch to the cp command and nothing blew up. Things appear to function as before per some spot checks after running the command.

Thank you drsilver for your assistance.

Rod


>>> Pictures? What pictures? <<<<

  
  LOG IN TO REPLY
sponsored links (only for non-logged)

1,002 views & 2 likes for this thread, 2 members have posted to it.
Linux guru wanted
FORUMS General Gear Talk Computers 
AAA
x 1600
y 1600

Jump to forum...   •  Rules   •  Forums   •  New posts   •  RTAT   •  'Best of'   •  Gallery   •  Gear   •  Reviews   •  Member list   •  Polls   •  Image rules   •  Search   •  Password reset   •  Home

Not a member yet?
Register to forums
Registered members may log in to forums and access all the features: full search, image upload, follow forums, own gear list and ratings, likes, more forums, private messaging, thread follow, notifications, own gallery, all settings, view hosted photos, own reviews, see more and do more... and all is free. Don't be a stranger - register now and start posting!


COOKIES DISCLAIMER: This website uses cookies to improve your user experience. By using this site, you agree to our use of cookies and to our privacy policy.
Privacy policy and cookie usage info.


POWERED BY AMASS forum software 2.58forum software
version 2.58 /
code and design
by Pekka Saarinen ©
for photography-on-the.net

Latest registered member is semonsters
1458 guests, 129 members online
Simultaneous users record so far is 15,144, that happened on Nov 22, 2018

Photography-on-the.net Digital Photography Forums is the website for photographers and all who love great photos, camera and post processing techniques, gear talk, discussion and sharing. Professionals, hobbyists, newbies and those who don't even own a camera -- all are welcome regardless of skill, favourite brand, gear, gender or age. Registering and usage is free.