145 lines
12 KiB
Plaintext
145 lines
12 KiB
Plaintext
|
|
Episode: 4373
|
||
|
|
Title: HPR4373: Rsync with stdin as source
|
||
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr4373/hpr4373.mp3
|
||
|
|
Transcribed: 2025-10-25 23:51:39
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
This is Hacker Public Radio Episode 4373 for Wednesday 7 May 2025.
|
||
|
|
Today's show is entitled R-Sync with SD-Dennis Source.
|
||
|
|
It is part of the series' bash scripting.
|
||
|
|
It is hosted by OXO and is about 20 minutes long.
|
||
|
|
It carries an explicit flag.
|
||
|
|
The summary is, use find pipettes the results into R-Sync to make a copy.
|
||
|
|
Hello and welcome to my second episode here on Hacker Public Radio.
|
||
|
|
My name is OXO and today I want to talk a little bit about R-Sync.
|
||
|
|
I hope my recording will be fine right now because I struggled a lot with FFNPEG, a record
|
||
|
|
and PWREC, I don't know, I used a lot of tools, but now I came to a record and my tests
|
||
|
|
were fine, but sometimes with the other tools, a lot of times I had a chipmunk voice.
|
||
|
|
Normally my voice is not that low, but this was a very high pitch, so it was crazy.
|
||
|
|
But now I do recording with a record and my options are SD-D Fold, dash FCD, dash R 44100,
|
||
|
|
dash T-Wuff, for a wavefile, and I have my dash dash view meter and it shows two channels
|
||
|
|
because I want to have feedback and I used FFNPEG and that gives, I don't know, it opens
|
||
|
|
a new screen and it's a graphical screen and it shows like a three-dimensional screen
|
||
|
|
thing with audio feedback, I don't know, but now I have two bars, left and right bar
|
||
|
|
and which is two channels, serial recording. And this is working fine, hopefully.
|
||
|
|
Now I'm continuing talking a little bit about R-Sync and the ideas I have about that.
|
||
|
|
I have two laptops right now because I have finished Hojime, my Arch Linux installer
|
||
|
|
script, so on my secondary laptop I have rounded Hojime script, of course, the offline install
|
||
|
|
and it was fine, but now I updated, upgraded my packages on my main machine and now I want
|
||
|
|
to copy these packages to a device in order to upgrade my other machine as well.
|
||
|
|
And then you think, why not via the internet? Well, I have a limited bandwidth, so I don't
|
||
|
|
want to use two times the internet for upgrading my packages because I have already these
|
||
|
|
packages and I only have to make a backup of them and then put them on the device and
|
||
|
|
which I need anyhow that device, because if I want to have a R-GMA offline backup, then
|
||
|
|
also I need that offline package repository. So anyhow, what I want to do is after a upgrade
|
||
|
|
of my Arch repository, Pac-Man repository, so there are some packages in my repository that
|
||
|
|
are updated, not all of them, but the way I do it now is copying all of them in that
|
||
|
|
takes a lot of time. So I want to write a script or I think it will be a one-liner, basically.
|
||
|
|
That search for the only packages that are updated, upgraded, so the newest ones, basically.
|
||
|
|
And then copy or arcing them to the destination location. And I read about arcing lately that
|
||
|
|
you can use arcing in a pipe construction, so then it receives a stream from standard
|
||
|
|
in and can redirect that stream or the data to the destination location. So what I want to
|
||
|
|
do now is create a one-liner with a find, because find can find the files that are changed
|
||
|
|
within the last 10 minutes or 15 minutes when I did the update or the upgrade for my Pac-Man
|
||
|
|
as why you. And find can then select those files and only those files have to be arcing
|
||
|
|
to the destination location. So that is what I am going to build. I stopped recording
|
||
|
|
now, make my solution, which will hopefully be a one-liner. So that is what I am going to build.
|
||
|
|
I stopped recording now, make my solution, which will hopefully be a one-liner. I think
|
||
|
|
we will manage that. And then I will come back to you when I have the solution.
|
||
|
|
So the solution is ready. Let's go to the test directory, cache test.
|
||
|
|
And then see what my files are in this directory. I have some files from two days ago.
|
||
|
|
And yesterday I have some files from yesterday and today. I have found my find command,
|
||
|
|
which is find and a dash. This is an edit message afterwards. I realized that I mentioned
|
||
|
|
the dash but meant a dot, a full stop. So I will paste dot, the word dot over the full
|
||
|
|
t dashes so you know and help back to the show. You will find the stuff in the current directory.
|
||
|
|
You can also put another directory location instead of a dot. And then let's see what I had.
|
||
|
|
Then we have find dot dash or hyphen type. I mostly call hyphen a dash. So please forget
|
||
|
|
that. I'm not a native speaker. That's also, by the way, I don't know if I mentioned that in
|
||
|
|
introduction, but I also do these podcasts or these audio recordings to learn better,
|
||
|
|
to talk better English because I think it's not that good. But anyhow, dash type F,
|
||
|
|
which I find all the files in the current directory. And the next one is interesting.
|
||
|
|
M.I.N, which is Mike Mike in the year November. And then minus 15 will be 15 minutes before.
|
||
|
|
So files that are not older than 15 minutes that are not older than 50 minutes indeed will be
|
||
|
|
fine found in this manner. And if I press enter, then I get no files back, which is of course logical
|
||
|
|
because it's almost 14, 17, three hours, more than three hours ago. So we put 200 in there.
|
||
|
|
200 minutes. Then I can yes, exactly get one file back, which is test dot,
|
||
|
|
which is test dot worth previous test recording. And if I increase a little bit because there
|
||
|
|
is there are three files from today, 1410, 1416 and 1436. And now I've hit the 1436.
|
||
|
|
So if I add 16 minutes, I should catch them all if I make two 16 from the value M.
|
||
|
|
And by the way, minus 216. Indeed, I get all the three files from today.
|
||
|
|
So that is the find command. But what makes it interesting and what I've learned today is that
|
||
|
|
find has a dash print zero. And it is one word, dash print zero. And if I enter now,
|
||
|
|
now I get a string of these three files. Let's see if it's through these three files.
|
||
|
|
It's a little bit weird. I get two files now. Oh, yeah, of course, times going time is not
|
||
|
|
standing still. So I've lost my oldest file already because I watched just on the edge.
|
||
|
|
So let's make the 216. Let's make it 220. So we have four minutes to finish this recording.
|
||
|
|
And now I got the three files back. But what the manual says, if I enter man find,
|
||
|
|
and I search for print zero. And then I do a next. And then I see print zero true,
|
||
|
|
print the full file name on the standard output followed by a null character,
|
||
|
|
instead of the new line character that print uses.
|
||
|
|
Which is interesting because the output, as I can see it in the command line is no showing no zero at all,
|
||
|
|
or no null at all. So I don't know how it works, but at least this is how it has to be.
|
||
|
|
I was expecting a zero or whatever, but it's maybe dumb of me. I don't know.
|
||
|
|
But anyhow, we need this print zero because now we can pipe to arsink.
|
||
|
|
So I have a pipe character, which is a vertical bar. And then I enter arsink.
|
||
|
|
And arsink can receive these print zero string, basically the standard in stream from arsure in the standard.
|
||
|
|
Oh, sorry, the standard out stream from find will become the standard in stream of arsink.
|
||
|
|
And I always do my arsink with a command with a command flags a a x v.
|
||
|
|
And that is a lowercase a uppercase a uppercase x and a lowercase v from verbose.
|
||
|
|
Okay, let's open another screen and a manual for arsink and g and c arsink.
|
||
|
|
The a is for the a is from archive dash a is, let's see, got a lot of dash a but not the explanation to scroll down here.
|
||
|
|
dash a is dash dash archive and archive mode is the same as dash R L P T G O capital D.
|
||
|
|
And no dash a no capital dash a no dash capital A no dash capital X no dash capital U no dash capital N and no dash capital H.
|
||
|
|
So there you go. Only the a that is so there's this archive and then the capital a capital A.
|
||
|
|
Let's search for capital a and that means the long flag for that is the dash dash a c l s which means preserve a c l s.
|
||
|
|
Okay, I don't know what that is exactly a c l s. Is it okay.
|
||
|
|
I'm not sure here they say about what is not a c l s here.
|
||
|
|
This option causes arsink to update the destination a c l s to be the same as the source a c l s.
|
||
|
|
And I still don't know what a c l s is. Is it account?
|
||
|
|
I think it has something to do with permissions.
|
||
|
|
The option also implies dash dash firms probably permissions stuff.
|
||
|
|
So it keeps the same permissions. I don't know the abbreviation of a c l s anymore.
|
||
|
|
Never mind, but that is the dash capital a and then the dash capital X.
|
||
|
|
I'm search for dash capital X here, which means a long flag for that is dash dash X a t t r s x etters.
|
||
|
|
And that means the option causes arsink to update the destination extended attributes to be the same as the source one.
|
||
|
|
So I presume the dash capital a is the permissions and the dash capital uppercase X is the attributes.
|
||
|
|
And then we have the fee for both. And then I have the dash dash info.
|
||
|
|
You can see these commands also in my catalog again info equals progress.
|
||
|
|
And progress to that is and some common stats.
|
||
|
|
Now colon comma sorry, that's my English. So what I have now is the pipe symbol arsink dash lowercase a uppercase a uppercase X and lowercase V a X V.
|
||
|
|
Dash dash info equals progress to comma stats.
|
||
|
|
And then dash dash progress. So it's it shows what it does.
|
||
|
|
And then the interesting part again that I learned of today is dash dash from zero.
|
||
|
|
So basically this print dash print zero from the find command and is from zero.
|
||
|
|
I see them connected. So find command has been told with print zero from put it with this no delimiter.
|
||
|
|
And arsink has been told with dash dash from zero you receive a no zero no delimiter.
|
||
|
|
And then the next interesting part that I didn't know about arsink and it's very very cool.
|
||
|
|
I think files so dash dash files dash from and then a space dash again.
|
||
|
|
So which is telling arsink okay you receive a no delimiter character from standard in.
|
||
|
|
It's similar as many command line tools using a dash to designate standard in stream.
|
||
|
|
And then a dash for the current directory as a source and then a dst for a destination directory and if I press enter right now.
|
||
|
|
Then I have the following feedback from arsink building the file list and then three files to consider.
|
||
|
|
And then I get very neatly like arsink does the three files that it is going to send over.
|
||
|
|
And then I'm going to CD into my dst directory and I indeed see these files back again.
|
||
|
|
Oh no it's there are two files. I'm sorry I see two files there and also two files in the arsink feedback log basically.
|
||
|
|
So I also two files in the arsink feedback.
|
||
|
|
So I have to raise my m in the amount of minutes again.
|
||
|
|
Let's make it to 30 and replace and then enter.
|
||
|
|
And now I have three files and it even says seven files to consider which is interesting.
|
||
|
|
What does it do there? Probably it will take into account both the destination and the source directories.
|
||
|
|
Not exactly what it does but anyhow if I go to the CD to the dst directory then indeed I have these three files now there.
|
||
|
|
So that is what I wanted to tell you about arsink.
|
||
|
|
I didn't know this capability of arsinks that it can take data from standard out or from for arsinks standard in and from standard out from from another tool.
|
||
|
|
And combined with a fine tool or even fd maybe it makes it a very powerful combination I think to form backup your stuff.
|
||
|
|
I'm going to use this construction for my package repository to update my package repository after I have upgraded via the internet.
|
||
|
|
So I will post this command also in the show notes and you can see it also in my codeberg repository which again I have to check if I'm telling the truth codeberg.org slash OXO that is.
|
||
|
|
Which will bring you to my repository page if you go to note the repository note and then you the third directory from above is catalog.
|
||
|
|
If you go to catalog and then you go to source or even list probably yeah list is no sorry not list go to source and then go to sh and then you get a list of all the show commands that I have cataloged basically and you can find the arsink command there as well.
|
||
|
|
If you search for it then you see that I already I'm not ready already uploaded that I think but I will be that shortly so when at the point in time that this podcast will be uploaded it will be certainly there.
|
||
|
|
So thank you so much for your attention I see you soon in the next episode goodbye.
|
||
|
|
You have been listening to Hacker Public Radio at Hacker Public Radio does work today show was contributed by a HBR listener like yourself.
|
||
|
|
If you ever thought of recording podcast and click on our contribute link to find out how easy it leads.
|
||
|
|
Hosting for HBR has been kindly provided by an onsthost.com, the internet archive and arsinks.net.
|
||
|
|
On this otherwise stated today's show is released under Creative Commons Attribution 4.0 International License.
|