Skip to content

tarsnap can be tricked into skipping file using "touch -r" #542

@safinaskar

Description

@safinaskar

As well as I understand tarsnap takes into account file metadata when deciding whether to skip file. Unfortunately, this means that tarsnap can wrongly skip modified file if its metadata was changed in unusual way. I was able to change file metadata using touch -r and trick tarsnap into not making backing. Here is full log (b is file with randomly generated content):

user@comp:/tmp$ cp -a b c
user@comp:/tmp$ time -p sudo tarsnap -c -f t-2022-05-11-9 --cachedir /usr/local/tarsnap-cache-2 --keyfile /root/tarsnap-2.key c
tarsnap: An archive already exists with the name "t-2022-05-11-9"
tarsnap: Error creating new archive
tarsnap: Error exit delayed from previous errors.
real 3,60
user 0,01
sys 0,02
user@comp:/tmp$ time -p sudo tarsnap -c -f t-2022-05-11-10 --cachedir /usr/local/tarsnap-cache-2 --keyfile /root/tarsnap-2.key c
                                       Total size  Compressed size
All archives                             92264085         83734204
  (unique data)                          50157877         41490716
This archive                              8395732          8436153
New data                                      516             1108
real 10,53
user 0,16
sys 0,01
user@comp:/tmp$ dd if=/dev/urandom of=c bs=8M count=1
1+0 records in
1+0 records out
8388608 bytes (8,4 MB, 8,0 MiB) copied, 0,274159 s, 30,6 MB/s
user@comp:/tmp$ touch --reference=b c
user@comp:/tmp$ time -p sudo tarsnap -c -f t-2022-05-11-11 --cachedir /usr/local/tarsnap-cache-2 --keyfile /root/tarsnap-2.key c
                                       Total size  Compressed size
All archives                            100659817         92170357
  (unique data)                          50158393         41491824
This archive                              8395732          8436153
New data                                      516             1108
real 10,11
user 0,04
sys 0,01
user@comp:/tmp$ mkdir cq
user@comp:/tmp$ cd cq
user@comp:/tmp/cq$ sudo tarsnap -x -f t-2022-05-11-11 --cachedir /usr/local/tarsnap-cache-2 --keyfile /root/tarsnap-2.key
user@comp:/tmp/cq$ ls
c
user@comp:/tmp/cq$ md5sum /tmp/cq/c
8a7b571bdcee199bf1a4c5636d8a96cc  /tmp/cq/c
user@comp:/tmp/cq$ md5sum /tmp/cq/c /tmp/c
8a7b571bdcee199bf1a4c5636d8a96cc  /tmp/cq/c
7c95ce7a821a197afc0942d63f9c7407  /tmp/c
user@comp:/tmp/cq$ cd ..
user@comp:/tmp$ time -p sudo tarsnap -c -f t-2022-05-11-12 --cachedir /usr/local/tarsnap-cache-2 --keyfile /root/tarsnap-2.key c
[sudo] password for user: 
tarsnap: Cannot start write transaction: Account balance is not positive.
tarsnap: Please add more money to your tarsnap account
tarsnap: Error creating new archive
tarsnap: Error exit delayed from previous errors.
real 8,88
user 0,03
sys 0,00
user@comp:/tmp$ time -p sudo tarsnap -c -f t-2022-05-11-12 --cachedir /usr/local/tarsnap-cache-2 --keyfile /root/tarsnap-2.key c
                                       Total size  Compressed size
All archives                            109055549        100606510
  (unique data)                          50158909         41492932
This archive                              8395732          8436153
New data                                      516             1108
real 9,71
user 0,03
sys 0,01
user@comp:/tmp$ mkdir cq2
user@comp:/tmp$ cd cq2
user@comp:/tmp/cq2$ sudo tarsnap -x -f t-2022-05-11-12 --cachedir /usr/local/tarsnap-cache-2 --keyfile /root/tarsnap-2.key
user@comp:/tmp/cq2$ md5sum /tmp/cq2/c /tmp/c
8a7b571bdcee199bf1a4c5636d8a96cc  /tmp/cq2/c
7c95ce7a821a197afc0942d63f9c7407  /tmp/c

I use tarsnap 1.0.40.

So, it seems any future tarsnap invocations will not backup new c version.

This breaks my workflow, because I actually sometimes use command touch -r. Also I think it is possible some broken utils may create files with wrong metadata. And I want my backup software to be absolutely reliable in such cases.

So, please always checksum files or add some option to always force checksumming. rsync has such option, it is named --checksum

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions