accept -tmp
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"gitea.inhome.blapointe.com/local/storage"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@@ -14,6 +13,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gitea.inhome.blapointe.com/local/storage"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ type Config struct {
|
|||||||
StoreUser string
|
StoreUser string
|
||||||
StorePass string
|
StorePass string
|
||||||
Cmd string
|
Cmd string
|
||||||
|
Tmp string
|
||||||
}
|
}
|
||||||
|
|
||||||
type LastN struct {
|
type LastN struct {
|
||||||
@@ -63,13 +65,20 @@ func (lastN *LastN) Push() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
archive := path.Join(
|
archive := path.Join(
|
||||||
os.TempDir(),
|
lastN.conf.Tmp,
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"%s.%s.tar",
|
"%s.%s.tar",
|
||||||
time.Now().Format("2006.01.02.15.04.05"),
|
time.Now().Format("2006.01.02.15.04.05"),
|
||||||
uuid.New().String(),
|
uuid.New().String(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
defer func() {
|
||||||
|
err := recover()
|
||||||
|
os.Remove(archive)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
"tar",
|
"tar",
|
||||||
"-czf",
|
"-czf",
|
||||||
|
|||||||
7
main.go
7
main.go
@@ -2,12 +2,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"gitea.inhome.blapointe.com/local/args"
|
|
||||||
"gitea.inhome.blapointe.com/local/lastn/lastn"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"gitea.inhome.blapointe.com/local/args"
|
||||||
|
"gitea.inhome.blapointe.com/local/lastn/lastn"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -49,6 +50,7 @@ func config() lastn.Config {
|
|||||||
as.Append(args.STRING, "ns", "ns for backups", path.Join("lastn", "dev"))
|
as.Append(args.STRING, "ns", "ns for backups", path.Join("lastn", "dev"))
|
||||||
as.Append(args.STRING, "rclone-conf", "path to rclone conf", path.Join(os.Getenv("HOME"), "/.config/rclone/rclone.conf"))
|
as.Append(args.STRING, "rclone-conf", "path to rclone conf", path.Join(os.Getenv("HOME"), "/.config/rclone/rclone.conf"))
|
||||||
as.Append(args.STRING, "rclone-alias", "rclone backend name", "blapointe-drive-enc")
|
as.Append(args.STRING, "rclone-alias", "rclone backend name", "blapointe-drive-enc")
|
||||||
|
as.Append(args.STRING, "tmp", "tmp dir", os.TempDir())
|
||||||
if err := as.Parse(); err != nil {
|
if err := as.Parse(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -67,5 +69,6 @@ func config() lastn.Config {
|
|||||||
StoreUser: as.Get("storeuser").GetString(),
|
StoreUser: as.Get("storeuser").GetString(),
|
||||||
StorePass: as.Get("storepass").GetString(),
|
StorePass: as.Get("storepass").GetString(),
|
||||||
Cmd: as.Get("cmd").GetString(),
|
Cmd: as.Get("cmd").GetString(),
|
||||||
|
Tmp: as.GetString("tmp"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user