Created
September 28, 2014 01:24
-
-
Save CromFr/84c2a2c3383ee77834fd to your computer and use it in GitHub Desktop.
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 | |
export DISPLAY=:0 | |
if [[ $CONFIRMED == "" ]] ; then | |
#Ask user | |
if zenity --question --text="Hey dude ! I want to do a backup! \nIs everything OK?" --icon-name="emblem-downloads" --default-cancel | |
then | |
export CONFIRMED="1" | |
gnome-terminal -e "/opt/backup.sh" | |
fi | |
exit 0 | |
else | |
#Backing up | |
if [[ `whoami` != "root" ]] ; then | |
echo "You need root privileges" | |
exit -1 | |
fi | |
mkdir /tmp/backup | |
mount /dev/sda2 /tmp/backup | |
echo "Starting sync..." | |
echo "/home/crom" | |
rsync -a --info=progress2 /home/crom /tmp/backup/backup | |
echo "/opt" | |
rsync -a --info=progress2 /opt /tmp/backup/backup | |
echo "/perm" | |
rsync -a --info=progress2 /perm /tmp/backup/backup | |
umount /tmp/backup && rm -rf /tmp/backup | |
notify-send -u critical -i /usr/share/icons/HighContrast/scalable/emblems/emblem-downloads.svg "Backup done" | |
echo "Backup done ! " | |
sleep 30 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment