text
stringlengths
0
1.49k
`rsync` does really interesting things. For example, when you try to copy a file to a remote server, then on the local site they have some process that opens the files, starts reading and sending to the remote site. If this is cancelled for some reason - for example, you cancel the program locally or your internet conn...
This is the easy part, but what happens when the file on the remote side was modified and you would like to make it pristine again and copy the original file over to the remote side again? You can just delete the remote file and start transferring again, but that's not very efficient. `rsync` cuts the file into differe...
The algorithm that it uses is called a _rolling hash sum_. It starts by reading the file and taking all the subsets of 32 bytes from the file, and for each of these 32 bytes it computes a hash. When this hash has some property, for example the lower bits are set to zero, then it says "Oh, I've found a block boundary!",...
So you could have also kept the file into 1 kilobyte pieces, but then the problem is you cannot detect when one byte has been inserted at the beginning, because all your blob boundaries are wrong. And when you have these dynamically-sized blobs, then you can detect "Oh, there has been a byte inserted; the first blob is...
The problem with the algorithm that `rsync' does is that it is targeted at really small blobs, for example 100 bytes or 5,000 bytes, and in a backup program we don't deal so much with inter-file duplication, but with intra-file duplication. We have some files that are not exactly the same, but mostly the same. So it's ...
Restic at the moment is configured to try to have one megabyte of data as one blob, and this was just not possible with the algorithm that `rsync` uses. So I looked at an algorithm called _Rabin fingerprinting_. It's a really old idea by a mathematician called Rabin from the '80s, and I read the original paper and it w...
**Ashley McNamara:** Wow...
**Alexander Neumann:** It turns out that the Go version is really fast already. On my laptop it can do 150 megabytes/second/core, something like that, so that's not an issue to just run it on all the data. And this is just the fingerprinting calculation, which yields blob boundaries for files. At the moment, Restic sta...
What it does is it uses a window of 64 bytes, so it calculates a hash of the first byte to the 64th byte, then the second byte to the 65th byte, third byte to the 66th byte and so on. And whenever the hash has a certain property that enough bits are set to zero, then there's a blob boundary.
When Go 1.6 was released, I think this was the first release of Go that really yielded another speed increment in the chunker just by building it with the newer version of Go, and the speed increments in recent versions are impressive. For example, I think in 1.7 it was that I recompiled the chunker and I gained like 1...
**Brian Ketelsen:** Yay, Go!
**Alexander Neumann:** This was really great. So when Restic then kept the file into these blobs, it will compute a SHA-2 hash over the content of the blob and then have a look-up table and see "Is this blob already known?" If not, the blob is saved to the repository. These blobs are bundled into pack files and only th...
Basically, the repository for Restic just stores metadata in JSON and the blobs themselves, that's it. And they're encrypted, and so on.
In the [Restic blog](https://restic.net/blog/) we have an article about digging a bit into the data structures that are there, and you can also use the Restic command cat (`restic cat`) to print out the metadata JSON things so you can inspect them and write small scripts to have a look around.
**Brian Ketelsen:** Oh, I haven't tried that yet. Now I'm gonna try that.
**Alexander Neumann:** Yeah, you should. It's really easy. I will insert the blog entry URL later in the show notes.
**Ashley McNamara:** This is so cool!
**Alexander Neumann:** Thank you.
**Brian Ketelsen:** It really is. I love how you can do snapshots and you can just list the snapshots - "Show me all the snapshots that I have over time." Of course, mine are hourly, so I've got a lot of snapshots, but they don't take up a ton of space because of the deduplication. It's an awesome thing.
**Alexander Neumann:** Yeah, if you have a new snapshot and you have changed the file and the file has one megabyte of data changed, then your snapshots should not take much more than this one megabyte of changed data, and that's it.
Have you tried the _Fuse Mount_ yet?
**Brian Ketelsen:** I have not tried the _Fuse Mount_ yet.
**Alexander Neumann:** Oh, you should.
**Brian Ketelsen:** It's kind of like having ZFS, but without having to fight with ZFS.
**Alexander Neumann:** You can tell Restic to present all the snapshots in this directory via Fuse, and then you can browse around in your snapshots, and data is only fetched on the demand, so that you can have like a thousand snapshots stored in S3 somewhere and just browse around and have a look at what are the times...
**Brian Ketelsen:** Shut the front door...! That's awesome! Alright, that's it. I'm gonna spend the rest of this show playing around with the Restic command line. You guys have a nice show! \[laughter\]
**Erik St. Martin:** I suppose I should really set a backup for my works...
**Alexander Neumann:** Yeah, you should!
**Ashley McNamara:** Yeah, I also need to do that...
**Erik St. Martin:** It's on my to-do list, where it's been for a couple of years.
**Ashley McNamara:** Isn't that on everyone's to-do list though? And for the same reason...
**Erik St. Martin:** I feel like right about the time I get around to setting it up properly is about the time that I pave my machine, and then it goes back on the list. \[laughter\]
**Ashley McNamara:** Yes.
**Alexander Neumann:** I have set up backups to several locations...
**Brian Ketelsen:** And it's really, REALLY easy with Restic... I'm just saying.
**Ashley McNamara:** I used to backup religiously, and I would backup in three locations, because it's not IF something fails, it's WHEN it will fail, and I'm terrible at it now. I don't know what happened. I haven't had anything catastrophic enough happen, I think.
**Alexander Neumann:** The interesting thing is that there are a lot of statistics around when SSD's fail or when hard disks fail, and personally I haven't seen a hard disk fail that was just one byte changed, or something like that... So this is very abstract for me, but recently a user opened an issue and said (I thi...
**Brian Ketelsen:** Nice...!
**Alexander Neumann:** This was really interesting, because it was the first time I saw such a silent failure in the real world.
**Brian Ketelsen:** That's awesome! There's nothing better -- how do you... Without using mocks or something like that it's almost impossible to simulate that occurrence, so having a real world disk failure proof that your software is correct is kind of awesome.
**Alexander Neumann:** Yeah, this is something like the question earlier regarding support... I had two other instances where people created an issue and said "Oh, something is very strange here." One guy started using Restic and made a backup of this complete laptop, like 200 gigabytes, to S3, something like that. The...
Then he created an issue and at first it was like, "If you have mistyped your password, then your data is gone." There's a really good key derivation function that that's the password to \[unintelligible 00:29:11.16\] conversion (it's called Scrypt). It even uses a lot of memory to be hard against custom ASICs that can...
When I first read this issue when I came home from work and said "Oh, what did I do?! Why did I release software that let people backup their data into a cloud service, and so on?" But the resolution was really good, because he just logged into the S3 console and saw that it was the wrong directory and everything was f...
**Erik St. Martin:** That brings up a valid point, though... That is a little scary to hand stuff over to people and know that you are responsible for their data. I mean, it's open source, but still...
**Alexander Neumann:** I'm not really responsible in terms of a license, because it's a BSD license and it says "There is no warranty at all/At your own risk", and so on.
**Erik St. Martin:** But as the person,
**Alexander Neumann:** Yeah
**Erik St. Martin:** you feel guilty if something happened, you know...?
**Alexander Neumann:** Yeah, exactly.
**Erik St. Martin:** You may not be legally liable, but I think we all want to produce things that make people's lives better, so finding out that there was something catastrophic caused by something you wrote always hits people close to home.