diff --git a/docs/router_backup.1 b/docs/router_backup.1 index 1370c67..e74fcb7 100644 --- a/docs/router_backup.1 +++ b/docs/router_backup.1 @@ -4,7 +4,7 @@ router_backup \- SSH Router Backup Tool .SH SYNOPSIS .B router_backup .RI --config " CONFIG_FILE" -.RI [ --git-repo " DIRECTORY" ] +.RI [ --output-dir " DIRECTORY" ] .RI [ --password " PASSWORD" ] .RI [ --key-file " KEYFILE" ] .RI [ --port " PORT" ] @@ -18,8 +18,8 @@ The tool supports multiple device types with predefined command sets, SSH agent .BR --config " \fICONFIG_FILE\fR" YAML configuration file path (required) .TP -.BR --git-repo " \fIDIRECTORY\fR" -Git repository directory for command output files (default: /tmp) +.BR --output-dir " \fIDIRECTORY\fR" +Output directory for command output files (default: /tmp) .TP .BR --password " \fIPASSWORD\fR" SSH password for authentication @@ -74,7 +74,7 @@ router_backup --config /etc/router-backup/config.yaml .TP Custom output directory: .EX -router_backup --config config.yaml --git-repo /home/user/backups +router_backup --config config.yaml --output-dir /home/user/backups .EE .TP Using password authentication: diff --git a/src/router_backup.go b/src/router_backup.go index 45f3b76..300294f 100644 --- a/src/router_backup.go +++ b/src/router_backup.go @@ -124,13 +124,13 @@ func (rb *RouterBackup) RunCommand(command string) (string, error) { } // BackupCommands runs multiple commands and saves outputs to files -func (rb *RouterBackup) BackupCommands(commands []string, gitRepo string) error { - if err := os.MkdirAll(gitRepo, 0755); err != nil { - return fmt.Errorf("failed to create directory %s: %v", gitRepo, err) +func (rb *RouterBackup) BackupCommands(commands []string, outputDir string) error { + if err := os.MkdirAll(outputDir, 0755); err != nil { + return fmt.Errorf("failed to create directory %s: %v", outputDir, err) } filename := fmt.Sprintf("%s.txt", rb.hostname) - filepath := filepath.Join(gitRepo, filename) + filepath := filepath.Join(outputDir, filename) // Truncate file at start file, err := os.Create(filepath) @@ -220,7 +220,7 @@ func main() { var password string var keyFile string var port int - var gitRepo string + var outputDir string var rootCmd = &cobra.Command{ Use: "router_backup", @@ -286,7 +286,7 @@ func main() { continue } - err = backup.BackupCommands(commands, gitRepo) + err = backup.BackupCommands(commands, outputDir) backup.Disconnect() if err != nil { @@ -305,7 +305,7 @@ func main() { rootCmd.Flags().StringVar(&password, "password", "", "SSH password") rootCmd.Flags().StringVar(&keyFile, "key-file", "", "SSH private key file path") rootCmd.Flags().IntVar(&port, "port", 22, "SSH port") - rootCmd.Flags().StringVar(&gitRepo, "git-repo", "/tmp", "Git repository directory for command output files") + rootCmd.Flags().StringVar(&outputDir, "output-dir", "/tmp", "Output directory for command output files") rootCmd.MarkFlagRequired("config")