MCPcopy Create free account
hub / github.com/Mister-leo/fssh / backupSSHConfig

Function backupSSHConfig

internal/sshconfig/writer.go:171–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

169}
170
171func backupSSHConfig() (string, error) {
172 configPath := sshConfigPath()
173
174 // Check if config exists
175 if _, err := os.Stat(configPath); os.IsNotExist(err) {
176 // No config file, no backup needed
177 return "", nil
178 }
179
180 // Create timestamped backup
181 timestamp := time.Now().Unix()
182 backupPath := fmt.Sprintf("%s.bak.%d", configPath, timestamp)
183
184 // Copy file
185 if err := copyFile(configPath, backupPath); err != nil {
186 return "", fmt.Errorf("failed to create backup: %w", err)
187 }
188
189 return backupPath, nil
190}
191
192func readSSHConfigLines() ([]string, error) {
193 configPath := sshConfigPath()

Callers 3

WriteGlobalConfigFunction · 0.85
WriteHostConfigFunction · 0.85
DeleteHostConfigFunction · 0.85

Calls 2

sshConfigPathFunction · 0.85
copyFileFunction · 0.70

Tested by

no test coverage detected