mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2026-04-02 11:55:23 +00:00
Merge pull request #2 from cseitz-forks/1-disabling-config-overwriting-encryption-key-generation
feat(Keygen&Config): Disabled encryption key generation and prevented…
This commit is contained in:
@@ -23,6 +23,10 @@
|
|||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
### Modifications by cseitz
|
||||||
|
|
||||||
|
- Disabled functionality to overwrite config files. You will need to specifiy restic repo keys manually.
|
||||||
|
|
||||||
### 💭 Why / What?
|
### 💭 Why / What?
|
||||||
|
|
||||||
Autorestic is a wrapper around the amazing [restic](https://restic.net/). While being amazing the restic cli can be a bit overwhelming and difficult to manage if you have many different locations that you want to backup to multiple locations. This utility is aimed at making this easier 🙂.
|
Autorestic is a wrapper around the amazing [restic](https://restic.net/). While being amazing the restic cli can be a bit overwhelming and difficult to manage if you have many different locations that you want to backup to multiple locations. This utility is aimed at making this easier 🙂.
|
||||||
|
|||||||
@@ -104,16 +104,17 @@ func (b Backend) validate() error {
|
|||||||
// Check if key is set in environment
|
// Check if key is set in environment
|
||||||
env, _ := b.getEnv()
|
env, _ := b.getEnv()
|
||||||
if _, found := env["RESTIC_PASSWORD"]; !found {
|
if _, found := env["RESTIC_PASSWORD"]; !found {
|
||||||
|
return fmt.Errorf(`Backend "%s" has no encryption key. The encryption key is required!"`, b.name)
|
||||||
// No key set in config file or env => generate random key and save file
|
// No key set in config file or env => generate random key and save file
|
||||||
key := generateRandomKey()
|
// key := generateRandomKey()
|
||||||
b.Key = key
|
// b.Key = key
|
||||||
c := GetConfig()
|
// c := GetConfig()
|
||||||
tmp := c.Backends[b.name]
|
// tmp := c.Backends[b.name]
|
||||||
tmp.Key = key
|
// tmp.Key = key
|
||||||
c.Backends[b.name] = tmp
|
// c.Backends[b.name] = tmp
|
||||||
if err := c.SaveConfig(); err != nil {
|
// if err := c.SaveConfig(); err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
env, err := b.getEnv()
|
env, err := b.getEnv()
|
||||||
|
|||||||
@@ -263,16 +263,17 @@ func AddFlagsToCommand(cmd *cobra.Command, backend bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) SaveConfig() error {
|
func (c *Config) SaveConfig() error {
|
||||||
file := viper.ConfigFileUsed()
|
return fmt.Errorf(`Not overwriting config; throwing error`);
|
||||||
if err := CopyFile(file, file+".old"); err != nil {
|
// file := viper.ConfigFileUsed()
|
||||||
return err
|
// if err := CopyFile(file, file+".old"); err != nil {
|
||||||
}
|
// return err
|
||||||
colors.Secondary.Println("Saved a backup copy of your file next to 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)
|
||||||
|
|
||||||
return viper.WriteConfig()
|
// return viper.WriteConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
func optionToString(option string) string {
|
func optionToString(option string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user