11 November 2012

automate home folder backup and software install script

unix user is notorous for oftenly changing Operating System (OS) or distro hopping. since new/increment version are realeased more frequently. it become significant / necessary to update to a newer release.

installing and configuring is time consuming if you have lots of software to install, say 30 or more. even more if you spend time playing solitaire or 0AD (no i had not played 0AD yet).

the saving grace in this situation is to create a script that will automate this work. first backup/copy your home folder (along with hidden folder).

below is the script (bash) to automate install of software after fresh install of new OS (Operating system).
the script for backing up setting from home folder is given below.



#add the name of software you want to install here seperated by [space].
cd $HOME
app_list="firefox gcolor2 gimp vlc";

for app in $app_list; do
if [[ `which $app` == "" ]]; then
echo "installing $app.....";
apt-get -y install $app; #install the app
else
echo "$app is already installed (skipping)."; #app is already
installed
fi;
done;


#script for backing up setting (from home folder).
cd $HOME ;
folder=backup ;
mkdir $folder ;
dir=$HOME/$folder/ ;

for i in `ls -A`; do
if [[ $i == .* ]]; then
if ( [[ $i == .thumbnails ]] || [[ $i == .cache ]]
|| [[ $i == .gvfs ]] || [[ $i == .local ]]
) ; #add more folder name that you don't want to backup then echo "Not copied $i";
else
echo "Copying $i";
cp -r $i $dir$i ;
fi;
fi;
done;

tar -cf backup.tar ./$folder ;
rm -r ./$folder ;




ps- sorry for my bad english. i'm still new in scripting. this is my first post.