Last active
December 10, 2015 21:48
-
-
Save mtarbit/4497947 to your computer and use it in GitHub Desktop.
Ubuntu backup script
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 | |
curr_date="$(date +%Y%m%d)" | |
base_path="/mnt/Elements/backup.$curr_date" | |
tgz_path="$base_path.tgz" | |
out_path="$base_path.out.log" | |
err_path="$base_path.err.log" | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root." 1>&2 | |
exit 1 | |
fi | |
echo "Backing up system in $tgz_path" | |
echo "Output redirected to $out_path" | |
echo "Errors redirected to $err_path" | |
nohup tar -cvpzf \ | |
"$tgz_path" \ | |
--one-file-system \ | |
--exclude=/dev \ | |
--exclude=/home/*/.gvfs \ | |
--exclude=/lost+found \ | |
--exclude=/proc \ | |
--exclude=/sys \ | |
--exclude=/var/run \ | |
/ 1> "$out_path" 2> "$err_path" & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment