Add Debian package
This commit is contained in:
10
.gitignore
vendored
10
.gitignore
vendored
@ -1 +1,11 @@
|
|||||||
router_backup
|
router_backup
|
||||||
|
|
||||||
|
# Debian packaging artifacts
|
||||||
|
debian/.debhelper/
|
||||||
|
debian/.gocache/
|
||||||
|
debian/go/
|
||||||
|
debian/router-backup/
|
||||||
|
debian/*.substvars
|
||||||
|
debian/debhelper-build-stamp
|
||||||
|
debian/*.debhelper
|
||||||
|
|
||||||
|
24
Makefile
24
Makefile
@ -36,12 +36,26 @@ fmt:
|
|||||||
@echo "Formatting Go code..."
|
@echo "Formatting Go code..."
|
||||||
cd $(SOURCE_DIR) && go fmt ./...
|
cd $(SOURCE_DIR) && go fmt ./...
|
||||||
|
|
||||||
|
# Build Debian package
|
||||||
|
.PHONY: pkg-deb
|
||||||
|
pkg-deb:
|
||||||
|
fakeroot dpkg-buildpackage -us -uc -b
|
||||||
|
|
||||||
|
# Clean package artifacts
|
||||||
|
.PHONY: clean-pkg
|
||||||
|
clean-pkg:
|
||||||
|
@echo "Cleaning package artifacts..."
|
||||||
|
@rm -f *.deb
|
||||||
|
@echo "Package cleanup complete"
|
||||||
|
|
||||||
# Show help
|
# Show help
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help:
|
help:
|
||||||
@echo "Available targets:"
|
@echo "Available targets:"
|
||||||
@echo " build - Build the router_backup binary"
|
@echo " build - Build the router_backup binary"
|
||||||
@echo " clean - Remove build artifacts"
|
@echo " clean - Remove build artifacts"
|
||||||
@echo " test - Run tests"
|
@echo " test - Run tests"
|
||||||
@echo " fmt - Format Go code"
|
@echo " fmt - Format Go code"
|
||||||
@echo " help - Show this help message"
|
@echo " pkg-deb - Create Debian package"
|
||||||
|
@echo " clean-pkg - Remove package artifacts"
|
||||||
|
@echo " help - Show this help message"
|
||||||
|
10
debian/changelog
vendored
Normal file
10
debian/changelog
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
router-backup (1.0.0) stable; urgency=low
|
||||||
|
|
||||||
|
* Initial release
|
||||||
|
* SSH Router Backup Tool with YAML configuration
|
||||||
|
* Support for multiple device types (srlinux, eos)
|
||||||
|
* SSH agent authentication support
|
||||||
|
* Command output concatenation with headers
|
||||||
|
* Go implementation for better performance
|
||||||
|
|
||||||
|
-- Pim van Pelt <pim@ipng.ch> Sat, 05 Jul 2025 23:55:00 +0100
|
13
debian/control
vendored
Normal file
13
debian/control
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Source: router-backup
|
||||||
|
Section: net
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: Pim van Pelt <pim@ipng.ch>
|
||||||
|
Build-Depends: debhelper-compat (= 12), golang-go
|
||||||
|
Standards-Version: 4.5.0
|
||||||
|
|
||||||
|
Package: router-backup
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}, openssh-client
|
||||||
|
Description: SSH Router Backup Tool
|
||||||
|
A tool for backing up router configurations via SSH.
|
||||||
|
Supports multiple device types and YAML configuration.
|
1
debian/debhelper-build-stamp
vendored
Normal file
1
debian/debhelper-build-stamp
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
router-backup
|
2
debian/files
vendored
Normal file
2
debian/files
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
router-backup_1.0.0_amd64.buildinfo net optional
|
||||||
|
router-backup_1.0.0_amd64.deb net optional
|
3
debian/postinst
vendored
Executable file
3
debian/postinst
vendored
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo 'Router Backup installed successfully.'
|
||||||
|
echo 'Example config at /etc/router-backup/config.yaml.example'
|
25
debian/rules
vendored
Executable file
25
debian/rules
vendored
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@
|
||||||
|
|
||||||
|
override_dh_auto_build:
|
||||||
|
cd src && go build -o ../router_backup router_backup.go
|
||||||
|
|
||||||
|
override_dh_auto_install:
|
||||||
|
mkdir -p debian/router-backup/usr/bin
|
||||||
|
mkdir -p debian/router-backup/etc/router-backup
|
||||||
|
mkdir -p debian/router-backup/usr/share/man/man1
|
||||||
|
cp router_backup debian/router-backup/usr/bin/
|
||||||
|
cp config.yaml debian/router-backup/etc/router-backup/config.yaml.example
|
||||||
|
cp docs/router_backup.1 debian/router-backup/usr/share/man/man1/
|
||||||
|
gzip debian/router-backup/usr/share/man/man1/router_backup.1
|
||||||
|
|
||||||
|
override_dh_auto_clean:
|
||||||
|
rm -f router_backup
|
||||||
|
|
||||||
|
override_dh_auto_test:
|
||||||
|
# Skip tests for now
|
||||||
|
|
||||||
|
override_dh_dwz:
|
||||||
|
# Skip dwz compression due to Go binary format
|
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
3.0 (native)
|
102
docs/router_backup.1
Normal file
102
docs/router_backup.1
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
.TH ROUTER_BACKUP 1 "July 2025" "router-backup 1.0.0" "User Commands"
|
||||||
|
.SH NAME
|
||||||
|
router_backup \- SSH Router Backup Tool
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B router_backup
|
||||||
|
.RI --config " CONFIG_FILE"
|
||||||
|
.RI [ --git-repo " DIRECTORY" ]
|
||||||
|
.RI [ --password " PASSWORD" ]
|
||||||
|
.RI [ --key-file " KEYFILE" ]
|
||||||
|
.RI [ --port " PORT" ]
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B router_backup
|
||||||
|
is a tool for backing up router configurations via SSH. It connects to multiple routers defined in a YAML configuration file and executes commands, saving the output to files.
|
||||||
|
.PP
|
||||||
|
The tool supports multiple device types with predefined command sets, SSH agent authentication, and automatic file organization.
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.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)
|
||||||
|
.TP
|
||||||
|
.BR --password " \fIPASSWORD\fR"
|
||||||
|
SSH password for authentication
|
||||||
|
.TP
|
||||||
|
.BR --key-file " \fIKEYFILE\fR"
|
||||||
|
SSH private key file path
|
||||||
|
.TP
|
||||||
|
.BR --port " \fIPORT\fR"
|
||||||
|
SSH port number (default: 22)
|
||||||
|
.TP
|
||||||
|
.BR --help
|
||||||
|
Show help message
|
||||||
|
.SH CONFIGURATION
|
||||||
|
The configuration file uses YAML format with two main sections:
|
||||||
|
.SS types
|
||||||
|
Define device types with their command sets:
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
types:
|
||||||
|
srlinux:
|
||||||
|
commands:
|
||||||
|
- show version
|
||||||
|
- show platform linecard
|
||||||
|
.EE
|
||||||
|
.SS devices
|
||||||
|
Define individual devices:
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
devices:
|
||||||
|
router1:
|
||||||
|
user: admin
|
||||||
|
type: srlinux
|
||||||
|
.EE
|
||||||
|
.SH AUTHENTICATION
|
||||||
|
Authentication is attempted in the following order:
|
||||||
|
.IP 1.
|
||||||
|
SSH agent (if SSH_AUTH_SOCK environment variable is set)
|
||||||
|
.IP 2.
|
||||||
|
Specified key file (--key-file option)
|
||||||
|
.IP 3.
|
||||||
|
Default SSH keys (~/.ssh/id_rsa, ~/.ssh/id_ed25519, ~/.ssh/id_ecdsa)
|
||||||
|
.IP 4.
|
||||||
|
Password authentication (--password option)
|
||||||
|
.SH OUTPUT
|
||||||
|
For each device, a text file named after the hostname is created in the specified directory. Each command output is prefixed with "## COMMAND: <command_name>" for easy identification.
|
||||||
|
.SH EXAMPLES
|
||||||
|
.TP
|
||||||
|
Basic usage:
|
||||||
|
.EX
|
||||||
|
router_backup --config /etc/router-backup/config.yaml
|
||||||
|
.EE
|
||||||
|
.TP
|
||||||
|
Custom output directory:
|
||||||
|
.EX
|
||||||
|
router_backup --config config.yaml --git-repo /home/user/backups
|
||||||
|
.EE
|
||||||
|
.TP
|
||||||
|
Using password authentication:
|
||||||
|
.EX
|
||||||
|
router_backup --config config.yaml --password mysecretpass
|
||||||
|
.EE
|
||||||
|
.SH FILES
|
||||||
|
.TP
|
||||||
|
.I /etc/router-backup/config.yaml.example
|
||||||
|
Example configuration file
|
||||||
|
.SH EXIT STATUS
|
||||||
|
.TP
|
||||||
|
.B 0
|
||||||
|
Success
|
||||||
|
.TP
|
||||||
|
.B 1
|
||||||
|
General error (configuration file not found, authentication failure, etc.)
|
||||||
|
.SH AUTHOR
|
||||||
|
Written by Pim van Pelt.
|
||||||
|
.SH REPORTING BUGS
|
||||||
|
Report bugs to <pim@ipng.ch>
|
||||||
|
.SH SEE ALSO
|
||||||
|
.BR ssh (1),
|
||||||
|
.BR ssh-agent (1),
|
||||||
|
.BR dpkg (1)
|
Reference in New Issue
Block a user