when one is happy with the setup of a linux system (config and scripts) one might want to backup those settings and restore it on a different machine or if things go haywire restore on the current machine.


cat /scripts/backup/config_scripts.sh

#!/bin/bash
# tested on:

# hostnamectl 
#  Static hostname: DebianLaptop
#         Icon name: computer-laptop
#           Chassis: laptop
#  Operating System: Debian GNU/Linux 9 (stretch)
#            Kernel: Linux 4.9.0-9-amd64
#      Architecture: x86-64

# modify this
VERSION=v3

# backup config of a linux machine

# create backup directories
mkdir -p /home/user/backup/$(date +%Y-%m)/scripts
mkdir -p /home/user/backup/$(date +%Y-%m)/config

# this will preserve the paths the config files were stored
# to replace on unpack, one will have to copy the .tar.gz into root /
# and unpack from there

# backup config
tar fcvz /home/user/backup/$(date +%Y-%m)/config/config_$VERSION.tar.gz /etc

# scripts
tar fcvz /home/user/backup/$(date +%Y-%m)/scripts/scripts_$VERSION.tar.gz /scripts/

admin