mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-11-05 13:14:48 +01:00
Make a copy of config before overriding it
This commit is contained in:
parent
27758a03fa
commit
65ba1f6ac1
@ -259,7 +259,7 @@ func (c *Config) SaveConfig() error {
|
|||||||
if err := CopyFile(file, file+".old"); err != nil {
|
if err := CopyFile(file, file+".old"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
colors.Secondary.Println("Saved a backup copy of your file next the the original.")
|
colors.Secondary.Println("Saved a backup copy of your file next to the original.")
|
||||||
|
|
||||||
viper.Set("backends", c.Backends)
|
viper.Set("backends", c.Backends)
|
||||||
viper.Set("locations", c.Locations)
|
viper.Set("locations", c.Locations)
|
||||||
|
@ -60,13 +60,13 @@ func ExecuteResticCommand(options ExecuteOptions, args ...string) (string, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CopyFile(from, to string) error {
|
func CopyFile(from, to string) error {
|
||||||
original, err := os.Open("original.txt")
|
original, err := os.Open(from)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
defer original.Close()
|
defer original.Close()
|
||||||
|
|
||||||
new, err := os.Create("new.txt")
|
new, err := os.Create(to)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user