rclone: Rclone mount will incorrectly handle data when used with borgbackup

What is the problem you are having with rclone?

borgbackup will fail when writing files to rclone mount’d filesystem

What is your rclone version (output from rclone version)

v1.49.5-236-g2e505430-beta

Which OS you are using and how many bits (eg Windows 7, 64 bit)

FreeBSD 12.0-STABLE amd64

Which cloud storage system are you using? (eg Google Drive)

Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone -vv --config /home/cubox/.rclone.conf --vfs-cache-mode full --cache-dir /tmp/rclone mount Gdrive:Onyx/Borg /gdrive | tee output.log

For borg:

<root@Onyx>-<~> λ borg init /gdrive -e repokey-blake2
Failed to securely erase old repository config file (hardlinks not supported>). Old repokey data, if any, might persist on physical storage.

By default repositories initialized with this version will produce security
errors if written to with an older version (up to and including Borg 1.0.8).

If you want to use these older versions, you can disable the check by running:
borg upgrade --disable-tam /gdrive

See https://borgbackup.readthedocs.io/en/stable/changes.html#pre-1-0-9-manifest-spoofing-vulnerability for details about the security implications.

IMPORTANT: you will need both KEY AND PASSPHRASE to access this repo!
Use "borg key export" to export the key, optionally in printable format.
Write down the passphrase. Store both at safe place(s).
<root@Onyx>-<~> λ borg create -p -e /root/.cache -C zlib,6 -v /gdrive::Onyx-2019-10-19T00:53 /usr/home /etc /root /www/cubox /www/fbh /usr/local/etc
Creating archive at "/gdrive::Onyx-2019-10-19T00:53"
Local Exceptionents   0%
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/borg/archiver.py", line 4501, in main
    exit_code = archiver.run(args)
  File "/usr/local/lib/python3.7/site-packages/borg/archiver.py", line 4433, in run
    return set_ec(func(args))
  File "/usr/local/lib/python3.7/site-packages/borg/archiver.py", line 166, in wrapper
    return method(self, args, repository=repository, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/borg/archiver.py", line 573, in do_create
    create_inner(archive, cache)
  File "/usr/local/lib/python3.7/site-packages/borg/archiver.py", line 538, in create_inner
    archive.save(comment=args.comment, timestamp=args.timestamp)
  File "/usr/local/lib/python3.7/site-packages/borg/archive.py", line 515, in save
    self.repository.commit()
  File "/usr/local/lib/python3.7/site-packages/borg/repository.py", line 442, in commit
    self.compact_segments()
  File "/usr/local/lib/python3.7/site-packages/borg/repository.py", line 789, in compact_segments
    assert segments[segment] == 0, 'Corrupted segment reference count - corrupted index or hints'
AssertionError: Corrupted segment reference count - corrupted index or hints

Platform: FreeBSD Onyx 12.0-STABLE FreeBSD 12.0-STABLE r347964 GENERIC amd64
Borg: 1.1.10  Python: CPython 3.7.4 msgpack: 0.5.6
PID: 67820  CWD: /root
sys.argv: ['/usr/local/bin/borg', 'create', '-p', '-e', '/root/.cache', '-C', 'zlib,6', '-v', '/gdrive::Onyx-2019-10-19T00:53', '/usr/home', '/etc', '/root', '/www/cubox', '/www/fbh', '/usr/local/etc']
SSH_ORIGINAL_COMMAND: None

A log from the command with the -vv flag (eg output from rclone -vv copy /tmp remote:tmp)

output.log

The log is quite big, but I hope this helps

Issue opened with borgbackup https://github.com/borgbackup/borg/issues/4795

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 35 (25 by maintainers)

Most upvoted comments

@Cubox- I am using https://beta.rclone.org/v1.51.0-327-g4006345c-beta/ on amd64 on a 5.4 kernel. Borg 1.1.11.

My remote is a google drive or a wasabi S3 bucket (tested both).

> rclone mount -v --dir-cache-time 5m --vfs-read-chunk-size 8M --vfs-read-chunk-size 100M --vfs-cache-mode writes --vfs-cache-max-size 4G --vfs-cache-max-age 6h drive-1:backup /mnt/temp
> # (different shell)

> borg init -e repokey /mnt/temp/test.borg
Enter new passphrase: 
Enter same passphrase again: 
Do you want your passphrase to be displayed for verification? [yN]: 
Failed to securely erase old repository config file (hardlinks not supported>). Old repokey data, if any, might persist on physical storage.

By default repositories initialized with this version will produce security
errors if written to with an older version (up to and including Borg 1.0.8).

If you want to use these older versions, you can disable the check by running:
borg upgrade --disable-tam /mnt/temp/test.borg

See https://borgbackup.readthedocs.io/en/stable/changes.html#pre-1-0-9-manifest-spoofing-vulnerability for details about the security implications.

IMPORTANT: you will need both KEY AND PASSPHRASE to access this repo!
Use "borg key export" to export the key, optionally in printable format.
Write down the passphrase. Store both at safe place(s).

# Recuding the segment size from 512mb to 100mb. Improves the 'reaction time' of borg when saving or trying to cancel a backup.
# My educated guess for a recommodation to not skrew things up:  `32MB <= (100MB per expected TB total repo size) <= 512MB`
# If you have fast upload (>=50Mbit), the segment size can be left larger
> sed -i "s/max_segment_size = 524288000/max_segment_size = 104857600/" /mnt/temp/test.borg/config

> borg create --progress --stats -C zstd /mnt/temp/test.borg::test1 /usr/src
Enter passphrase for key /mnt/temp/test.borg:
…
------------------------------------------------------------------------------                                                                                                     
Archive name: test1
Archive fingerprint: beeaaa3993ba8ba4e1bfd423941a2aafd4ee3fd6d8f511b1003aaaa05dda2b3c
Time (start): Sun, 2020-05-17 19:26:10
Time (end):   Sun, 2020-05-17 19:28:06
Duration: 1 minutes 55.85 seconds
Number of files: 137000
Utilization of max. archive size: 0%
------------------------------------------------------------------------------
                       Original size      Compressed size    Deduplicated size
This archive:                1.81 GB            431.30 MB            231.50 MB
All archives:                1.81 GB            431.30 MB            231.50 MB

                       Unique chunks         Total chunks
Chunk index:                   66626               131642
------------------------------------------------------------------------------

Unmounted, mounted again and tried an extract, worked without issues. Extracting took ~50 seconds.

Maybe you could post your versions and also try running rclone mount with -vv and post the output you get when trying borg init.

All my tests work fine so far!

Just chiming in to see what the latest is on this issue before I start a borg + rclone mount with vfs cache mode full backup strategy

I’m doing that, I have on my unraid rclone running with mount to Google Drive, I use this rclone mount for my borg backup repository. I found this thread looking for other people’s config, same as this one from borgbackup. In my case, it is working perfectly, no problems so far, I have rclone mount with this config: rclone mount --cache-dir /mnt/disks/ud1/RClone_Caching_Folder/ --vfs-cache-mode full --max-read-ahead 1024k --allow-other encrypted: /mnt/disks/secure & and then I point my borg repository inside the /mnt/disks/secure folder, so far running borg create works with no issues. This is what I run if it helps borg create --compression none --one-file-system --read-special --files-cache mtime,size --debug --show-rc --progress /ua_nvme1/testrepo::testrepo-{now} /mnt/user/repo1

rclone v1.55.0 borg 1.1.15

What @dragetd explains about reducing the segment size of borgbackup is something I need to try, that way the download from the cloud (in this case with rclone mount) would not take so long, because that’s exactly what it is happening to me, and I’m backing up about 500GB.

The work from RClone developers and Borg developers is amazing, I definitely need to donate something to those guys!

Great work and thank you @ncw!

@anaxonda add --allow-other to your rclone mount command. (Check it is allowed in /etc/fuse.conf first)

@segator This option is already available with the VFS rewrite from version 1.53 onwards, specifically the --vfs-write-back option