Skip to content

Instantly share code, notes, and snippets.

@elhenro
Last active May 29, 2019 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elhenro/e4b1cb942396bb077ad3368f1282d766 to your computer and use it in GitHub Desktop.
Save elhenro/e4b1cb942396bb077ad3368f1282d766 to your computer and use it in GitHub Desktop.
#!/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