Compare commits

..

No commits in common. "bbb1c85cadae6403a430bdc1b8860d3ef4de0c07" and "b5604b8b9ffc8136df7edf95b0a87e3e9322d872" have entirely different histories.

3 changed files with 21 additions and 24 deletions

View File

@ -1,4 +1,4 @@
FROM golang:1.22-alpine as builder
FROM golang:1.21-alpine as builder
WORKDIR /app
COPY go.* .
@ -7,7 +7,7 @@ COPY . .
RUN go build
FROM restic/restic:0.16.4
RUN apk add --no-cache rclone bash curl docker-cli
RUN apk add --no-cache rclone bash curl
COPY --from=builder /app/autorestic /usr/bin/autorestic
ENTRYPOINT []
CMD [ "autorestic" ]

View File

@ -143,7 +143,6 @@ func (b Backend) Exec(args []string) error {
return err
}
options := ExecuteOptions{Envs: env}
args = append(args, combineBackendOptions("exec", b)...)
_, out, err := ExecuteResticCommand(options, args...)
if err != nil {
colors.Error.Println(out)

View File

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path"
@ -36,7 +37,7 @@ func dlJSON(url string) (GithubRelease, error) {
return parsed, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return parsed, err
@ -72,10 +73,9 @@ func downloadAndInstallAsset(body GithubRelease, name string) error {
// Uncompress
bz := bzip2.NewReader(resp.Body)
// Save to tmp file in the same directory as the install directory
// Linux does not support overwriting the file that is currently being running
// But it can be delete the old one and a new one moved in its place.
tmp, err := os.CreateTemp(INSTALL_PATH, "autorestic-")
// Save to tmp
// Linux does not support overwriting the file that is currently being overwritten, but it can be deleted and a new one moved in its place.
tmp, err := ioutil.TempFile(os.TempDir(), "autorestic-")
if err != nil {
return err
}
@ -89,25 +89,23 @@ func downloadAndInstallAsset(body GithubRelease, name string) error {
to := path.Join(INSTALL_PATH, name)
defer os.Remove(tmp.Name()) // Cleanup temporary file after thread exits
mode := os.FileMode(0755)
if originalBin, err := os.Lstat(to); err == nil {
mode = originalBin.Mode()
err := os.Remove(to)
if err != nil {
if err := os.Rename(tmp.Name(), to); err != nil {
colors.Error.Printf("os.Rename() failed (%v), retrying with io.Copy()\n", err.Error())
var src *os.File
var dst *os.File
if src, err = os.Open(tmp.Name()); err != nil {
return err
}
}
err = os.Rename(tmp.Name(), to)
if err != nil {
if dst, err = os.Create(to); err != nil {
return err
}
err = os.Chmod(to, mode)
if err != nil {
if _, err := io.Copy(dst, src); err != nil {
return err
}
if err := os.Chmod(to, 0755); err != nil {
return err
}
}
colors.Success.Printf("Successfully installed '%s' under %s\n", name, INSTALL_PATH)
return nil