Last active
May 29, 2019 17:59
-
-
Save elhenro/e4b1cb942396bb077ad3368f1282d766 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rootcheck () { | |
if [ $(id -u) != "0" ] | |
then | |
echo "warning: auto appending sudo.." | |
sudo "$0" "$@" | |
exit $? | |
fi | |
} | |
rootcheck | |
backup_files="{dirs to backup}" | |
dest="/data/backups" | |
now=$(date +%Y-%m-%d_%H:%M) | |
hostname=$(hostname) | |
archive_file="$hostname-$now-bak.tar.gz" | |
echo "backup of $backup_files => $dest/$archive_file" | |
tar cvzf $dest/$archive_file $backup_files | |
echo "backup done. size:" | |
du -sh $dest/$archive_file | |
ls -lh $dest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment