This repository has been archived on 2024-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
vyos-config/scripts/custom-config-backup.sh

27 lines
747 B
Bash
Raw Normal View History

2023-03-29 13:30:45 -05:00
#!/bin/bash
#
# Description: Backup config directory and configuration commands to a USB device
#
dest=/media/usb-backup
# Only backup if $dest is a mount
if mountpoint -q $dest; then
# Backup # VyOS /config
backup_dest="$dest/vyos"
if [ ! -d "$backup_dest" ]; then
mkdir "$backup_dest"
fi
tar --exclude="overlay*" --exclude="unifi*" -zvcf "$backup_dest/config.$(date +%Y%m%d%H%M%S).tar.gz" /config
# Unifi backups
backup_dest="$dest/unifi"
if [ ! -d "$backup_dest" ]; then
mkdir "$backup_dest"
fi
tar -zvcf "$backup_dest/unifi-backup.$(date +%Y%m%d%H%M%S).tar.gz" /config/containers/unifi/data/backup
# Delete backups older than 1 month
find $dest -type f -mtime +30 -delete
fi