#!/bin/bash

if [ ! -d "/backups" ]; then
  mkdir /backups
fi

for file in $(find /backups -name "backup-*" -type f | sort -r | tail -n +5);
do
        rm -rf $file;
done;

tar cJf /backups/backup-$(date "+%Y%m%d%H%M-%N").tar.xz --exclude /home/nobackup /etc /home 2>&-
