this post was submitted on 14 Aug 2026
5 points (100.0% liked)

Linux Questions

4113 readers
20 users here now

Linux questions Rules (in addition of the Lemmy.zip rules)

Tips for giving and receiving help

Any rule violations will result in disciplinary actions

founded 3 years ago
MODERATORS
 

Hey all!

Let me go stratight to the point:

I have an audio player in which I want to clone my ~/Music directory when I connect it to my computer. The only relevant thing about it is that it's a barebones filesystem and I cannot run cool stuff like Syncthing on the player (otherwise this question would already have a solution). Right now, my solution is that I connect the player to the computer and manually copy file to and delete files in the player. As you may have guessed, this is an error prone process. In order to solve that, I want to run a single command that clones ~/Music (src) into /path/to/player/Music (dst).

My requirements are:

  • All new files in src MUST be copied into dst.
  • All files no longer present in src MUST be deleted from dst.
  • All files present in both src and dst that have more recent modifications in src MUST be copied and overwritten into dst.

As you can see, my player's filesystem is a strict replica of my main computer's. Now, I know I can write a Python script in an afternoon to do just that, but I want to know if there are any good tools first to do this. I searched the web in hope that rsync would help me here, but the only answers I can find are for buffier cp. It may be that I have a vocabulary problem and I'm not searching for the correct terms.

I'd love to read your ideas! A note about LLMs: I'm not interested at all in any comments about how llm-of-the-week coded this in a moment, I asked fake-chat and here's what it said or whatever. If you are not a human that can be bothered to write an answer, I won't be bothered to read it.

Thank you!

you are viewing a single comment's thread
view the rest of the comments
[–] Shadow@lemmy.ca 9 points 21 hours ago* (last edited 21 hours ago) (2 children)

Why not rsync? Off the top of my head: rsync -avp --delete src/* dst/

Stop googling and just read the rsync man page

[–] groctel@lemmy.world 5 points 21 hours ago (1 children)

Stop googling and just read the rsync man page

Fair enough, sometimes you get tunnel vision with a problem.

For what I see the command doing, thanks for the progress flag, it seems to be doing what I need. Reading the manual, it also looks like it's not copying files that have the same size and timestamp in the source and destination, which is also what I wanted, even though I didn't make it explicit. I'll have to take a look to making the command parallel, probably by running it on every subdirectory of ~Music at once.

Thank you for your help!

[–] lime@feddit.nu 3 points 20 hours ago

rsync is made for quickly backing up huge directories over whatever connection. believe me you won't need to script anything or parallelise it. just check the available flags.

[–] bjoern_tantau@swg-empire.de 2 points 21 hours ago (1 children)

You probably want an uppercase P.

rsync -avP --delete src/* dst/
[–] Shadow@lemmy.ca 4 points 21 hours ago (1 children)

Oops, I did actually mean -p but that's included in -a. Years of muscle memory doesn't go away. -P is a good one too though.

[–] bjoern_tantau@swg-empire.de 2 points 21 hours ago

I always remember alien vs Predator. And the Predator is uppercase because he's more intelligent. And sometimes alien vz Predator if I want compression.