-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Restic check on local repository writes the same amount of data as the repository size to OS drive, reducing lifetime of SSD #3375
Description
Output of restic version
restic 0.12.0 compiled with go1.15.8 on linux/arm
How did you run restic exactly?
export RESTIC_REPOSITORY=.
export RESTIC_PASSWORD=<SECRET_PW>
cd /home/pi/extern/restic
/home/pi/restic check --read-data --no-cache
Output:
~/extern/restic $ /home/pi/restic check --read-data --no-cache
repository xxxxxxx opened successfully, password is correct
create exclusive lock for repository
load indexes
check all packs
check snapshots, trees and blobs
read all data% 16 / 16 snapshots
[1:19] 100.00% 16 / 16 snapshots
[3:39:52] 5.90% 20405 / 346096 packs
What backend/server/service did you use to store the repository?
a 3.5" external USB HDD with EXT4 filesystem mounted to /home/pi/extern
Expected behavior
restic reads all data from local repository and checking them without writing a copy to temp folder
Actual behavior
Restic copies all data stored on directly attached harddrive to temp directory.
lsof | grep restic lists a lot of these entrys
restic 2810 pi 6u REG 179,2 4386561 5494 /tmp/restic-temp-421096629 (deleted)
restic 2810 pi 8u REG 179,2 6581784 11442 /tmp/restic-temp-657619758 (deleted)
restic 2810 pi 9u REG 179,2 4294885 1945 /tmp/restic-temp-362046705 (deleted)
restic 2810 pi 10u REG 179,2 5544330 10340 /tmp/restic-temp-922992203 (deleted)
This is just an excerpt. List is really long.
Steps to reproduce the behavior
Check a local restic repostory with restic check command (on a Raspberry PI3).
On an idle system you can check the caused writeload of restic via cat /sys/fs/ext4/mmcblk0p2/lifetime_write_kbytes replace mmcblk0p2 with where your root partition "/" is mounted.
After checking 1000 packs I had about 5 GB more lifetime writes
restic/data/00 $ ls -lh | head
total 6,8G
restic/data/00 $ ls -lh | wc -l
1381
So average size of one pack is 4,92 MB. Reading 1000 of this giving about 5 GB more written data.
Do you have any idea what may have caused this?
Restic treats it as remote repository where it has to download the data from before it can do useful stuff with it.
I think this behaviour probably will also occur when restoring data.
Probably it is because used system is too slow so that temp files get written do disk before restic deletes them again.
Do you have an idea how to solve the issue?
Current workaround is
sudo mkdir /run/restic
sudo chown pi:pi /run/restic
export TMPDIR=/run/restic
I know that restic needs a temp directory when backing up before uploading. It was just very unexpected that restic copies whole local repository when doing a check. So far I've done this several times, meaning a few TB were written on the SD card, so I should now replace it and buy a new one.
Due to the kind restic works it may be a lot of work to change behaviour for local repositories not to copy the file data. Perhaps this only occurs because I do this on a raspberry PI 3B which is so slow that pack files got written to disk before they were deleted again.
So just a simple warning when executing check that this operation may cause write of the whole repository to local disk and one should consider using export TMPDIR with tempdir on a ramdisk.
Did restic help you today? Did it make you happy in any way?
Restic is a really great program. I really like it very much and I'm looking very forward to when it is possible to increase filesize of packfiles via commandline, see #2750
I backup now all my machines with restic, even raspberry PIs complete OS and made a full restore procedure which I can share I someone is interested.
I really like restic. It is the best backup program of all those I've tried (Duplicati, Hardlinkbackup, Windows integrated Backup, using Winrar, robocopy, synchthing used as backup software).