VyOS – Backup Configurations

On Backup Server

Step 1: create a new ssh key on your local computer

$ ssh-keygen -t rsa

Step 2: copy your public key to your remote server

$ ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]_machine_vyos

Step 3: create bash scripts

$ sudo vi /etc/scripts/backup_vyos.sh
#!/bin/bash

timestamp=$(date +"%y%m%d_%H%M")
BACKUP_DST="/home/backup/conf/vyos"

# Router & Firewall VyOS
ssh -p 4321 [email protected] "cp /config/config.boot /home/agink/"
ssh -p 4321 [email protected] "cat /home/agink/config.boot" > $BACKUP_DST/ROFW_VyOS_$timestamp.txt

echo "remove old backup files"
find $BACKUP_DST/ -name "*.txt" -type f -mtime +7 -exec rm -f {} \;
echo ""

# End of Backup
$ sudo chmod +x /etc/scripts/backup_vyos.sh