Welkom op LIRONICS DOCs'

Updated: 29-03-2020

backup.sh

#!/bin/bash

shopt -s -o nounset

user="root"
password="paxoRvd(18)"
host="localhost"
db_name="vtg"

backup_path="/home/rvd/Documenten/BU"
backup_to_path="/home/rvd/Documenten/BU_archive"
date=$(date +"%d-%m-%Y")

declare -A FILES=(
[fstab]=/etc/fstab
[bashrc]=~/.bashrc
[nanorc]=~/.nanorc
[smb.conf]=/etc/samba/smb.conf
)

umask 077

sudo apt-get update -y && sudo apt-get dist-upgrade -y && sudo apt-get clean && sudo apt-get autoremove ;

stat /var/cache/apt/pkgcache.bin >> /home/rvd/Documenten/bin/update.log

mysqldump --user=$user --password=$password --host=$host $db_name > $backup_path/$date-$db_name.sql ;

cp -R /home/rvd/.atom $backup_path/$date-atom ;
cp -R /home/rvd/.config $backup_path/$date-config ;

for i in "${!FILES[@]}";
do
cp ${FILES[$i]} $backup_path/$date-$i ;
done

tar -czvf $backup_to_path/$date-paxoLap.tar.gz $backup_path ;

find $backup_path/* -exec rm -rf {} ;

exit 0