Bash script to backup my configs (dotfiles)

I needed some script to take care of my config files and put them in a single directory. So here it is.

#!/bin/bash
 
# Display All Hidden Dot Files In a Directory
# ls -a | egrep "^\." > backup_dotfiles.sh
 
DESTINATION="/storage/dotfiles"  # do not use a trailing slash (/)
 
# Colors
blue="\e[0;34m"
green="\e[1;32m"
red="\e[0;31m"
bold="\e[1;30m"
reset="\e[0m"
 
# file list (use trailing slash for directories)
FILES="
.bash_aliases
.bash_logout
.bash_profile
.bashrc
.colours/
.config/openbox/
.config/terminator/
.config/tint2/
.config/zathura/
.devilspie/
.fehbg
.fonts.conf
.gtk-bookmarks
.gtkrc-2.0
.gtkrc-2.0.mine
.inputrc
.mplayer/
.nanorc
.rtorrent.rc
.screenrc
.synergy.conf
.vim/colors/
.vimrc
.xbindkeysrc
.Xdefaults
.xinitrc
.xmod
.Xmodmap
.xsession
.xxkb/
.xxkbrc
"
for file in $FILES
do
   if [ -d $file ]; then
      mkdir -p $DESTINATION/$file
      cp -f $HOME/$file* $DESTINATION/$file
   elif [ -f $file ]; then
      cp -f $HOME/$file $DESTINATION
   else
      echo -e "$red:: $file is not a file/directory! $reset"
   fi     
done
 
echo -e "$green:: Done! $reset"
exit 0

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close