Last active
January 9, 2016 12:09
-
-
Save funivan/4444386 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# | |
# Ivan Scherbak <funivan.com> | |
if [ -z "$1" ]; then | |
echo "set argument"; | |
exit; | |
elif [ $1 = "--backup" ] | |
then | |
BACKUP_FLAG=0; | |
elif [ $1 = "--restore" ]; then | |
BACKUP_FLAG=1; | |
else | |
echo "First argument shud be: --backup or --restore "; | |
echo "You type: $1"; | |
exit | |
fi | |
function B { | |
return $BACKUP_FLAG; | |
} | |
DIR="/home/ivan/backup-u"; | |
if B; then | |
rm -rf $DIR; | |
mkdir $DIR; | |
fi | |
if [ ! -d "$DIR" ]; then | |
echo "Directory not exist $DIR" | |
exit; | |
fi | |
# starat actions | |
# gnome settings | |
if B ; then | |
gconftool-2 --dump / > $DIR/gconf.xml; | |
else | |
gconftool-2 --load $DIR/gconf.xml; | |
fi | |
# packages | |
if B ; then | |
dpkg --get-selections > $DIR/Package.list | |
sudo cp /etc/apt/sources.list $DIR/sources.list | |
sudo apt-key exportall > $DIR/Repo.keys | |
else | |
echo "" | |
#~ sudo apt-key add $DIR/Repo.keys | |
#~ sudo cp $DIR/sources.list /etc/apt/sources.list | |
#~ sudo apt-get install dselect | |
#~ sudo dpkg --set-selections < $DIR/Package.list | |
#~ sudo apt-get dselect-upgrade -y | |
fi | |
# config directories | |
if B ; then | |
tarExclude=" | |
--exclude cache | |
--exclude */google-chrome | |
--exclude */chromium | |
--exclude .gvfs | |
--exclude .thumbnails | |
--exclude .thunderbird | |
--exclude .pdepend | |
--exclude .teamviewer | |
--exclude *Trash* | |
--exclude */logs/* | |
--exclude */log/* | |
--exclude *firefox*icons | |
--exclude *firefox*Cache | |
--exclude *firefox*thumbnails | |
--exclude *opera*icons | |
--exclude *opera*cache | |
--exclude *opera*thumbnails | |
--exclude *opera*pstorage | |
--exclude *opera*vps | |
--exclude *netbeans*log | |
--exclude *netbeans*filehistory | |
--exclude *nbi*tmp | |
--exclude *\.goutputstream* | |
--exclude .xsession-* | |
--exclude .nv/ | |
--exclude .nv/GLCache | |
" | |
tar cvpzf $DIR/backup-configs.tgz ~/.[a-z][A-Z]* $tarExclude | |
else | |
tar -zxvf $DIR/backup-configs.tgz | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment