autorestic
autorestic copied to clipboard
Upgrade fails if `tmp` is on different filesystem
Describe the bug
autorestic upgrade
fails with errors like:
-
os.Rename() failed (rename /tmp/autorestic-1252517049 /usr/local/bin/autorestic: invalid cross-device link), retrying with io.Copy()
-
Error: open /usr/local/bin/autorestic: text file busy
.
Se detailed output below.
Expected behavior autorestic should upgrade itself.
Environment
- OS: Fedora
- Version: 35
Additional context
❯ autorestic upgrade --verbose
Using config paths: . /root /root/.config/autorestic
restic already installed
> Executing: /usr/bin/restic self-update
writing restic to /usr/bin/restic
find latest release of restic at GitHub
restic is up to date
Downloading: https://github.com/cupcakearmy/autorestic/releases/download/v1.7.1/autorestic_1.7.1_linux_amd64.bz2
os.Rename() failed (rename /tmp/autorestic-1252517049 /usr/local/bin/autorestic: invalid cross-device link), retrying with io.Copy()
Error: open /usr/local/bin/autorestic: text file busy
cannot lock before reading config location
Can you reproduce it? Seemed fine to me on macos and linux
You probably have /tmp
on a different file system I suppose?
https://stackoverflow.com/a/42400063/2425183
Not sure how to know. My fstab only contains an ext4 partition mounted at / and a swap partition.
It might be on snorher file system. Both Fedora and Arch use tmpfs.
https://wiki.archlinux.org/title/tmpfs#Usage
"Arch uses a tmpfs /run directory, with /var/run and /var/lock simply existing as symlinks for compatibility. It is also used for /tmp by the default systemd setup and does not require an entry in fstab unless a specific configuration is needed."
Not sure how to check if this is true for me but after some googling I found out that Fedora has been using tmpfs since version 18.
Just ran autorestic upgrade on my Manjaro machine and it said upgrade was successful but it basically just deleted itself. Trying to run the command again returns: command not found
That sounds bad, definitely need to look at the upgrade function.
Been playing around with datadog the last couple of days and discovered that Fedora is indeed using tmpfs so that is probably the issue☺️
Hello, i faced to this issue today when i tried to upgrade autorestic to 1.7.2 version Is there any news on this issue ?
edit : 22/10/22
i write a little bash script it's not perfect but it do the job as a workaround until this is fixed
#!/bin/bash
currentBin="/usr/local/bin/autorestic"
# get latest tag release name
latest_vtag=$(curl --silent "https://api.github.com/repos/cupcakearmy/autorestic/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
latest_tag=${latest_vtag:1}
binUrl="https://github.com/cupcakearmy/autorestic/releases/download/v$latest_tag/autorestic_${latest_tag}_linux_amd64.bz2"
sha256SumsUrl="https://github.com/cupcakearmy/autorestic/releases/download/v$latest_tag/SHA256SUMS"
wget $binUrl --directory-prefix /tmp/
wget $sha256SumsUrl --directory-prefix /tmp/
cd /tmp || exit
sha256sum -c /tmp/SHA256SUMS --ignore-missing
if [ "$?" == 0 ]; then
bzip2 -d ./autorestic_${latest_tag}_linux_amd64.bz2
mv $currentBin /tmp/autorestic_old
cp autorestic_${latest_tag}_linux_amd64 $currentBin
chmod 755 /usr/local/bin/autorestic
fi
printf "autorestic successfully updated"
autorestic --version
exit 0
TLDR; we need to copy and delete instead of renaming, otherwise it fails over different filesystems https://stackoverflow.com/a/42400063/2425183
Hit this error today... is there any built-in workaround?