Backup Script

Categories: Scripts

A quick and simple backup script. The source of this is from Voorburg here: https://voorburg.home.xs4all.nl/backup.html

#!/bin/bash

DATA="/home /root /var/www/html /opt"
CONFIG="/etc /var/lib /var/named"
LIST="/tmp/backlist_$$.txt"

mount /mnt/backup
set $(date)

if test "$1" = "Fri" ; then
        tar cfz "/mnt/backup/data/data_full_$6-$2-$3.tgz" $DATA
        rm -f /mnt/backup/data/data_diff*
        tar cfz "/mnt/backup/config/config_full_$6-$2-$3.tgz" $CONFIG
        rm -f /mnt/backup/config/config_diff*
else
        find $DATA -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
        tar cfzT "/mnt/backup/data/data_diff_$6-$2-$3.tgz" "$LIST"
        rm -f "$LIST"
        find $CONFIG -depth -type f  \( -ctime -1 -o -mtime -1 \) -print > $LIST
        tar cfzT "/mnt/backup/config/config_diff_$6-$2-$3.tgz" "$LIST"
        rm -f "$LIST"
fi

umount /mnt/backup
«
»