Thursday, May 23, 2013

My Scripts: Backup your configuration files


File name: configbackup

#!/bin/bash

tmpdate=$(date +%D | sed "s/\//-/g");


tar zcvf ~/config_backup$tmpdate.tar.gz ~/.vimrc ~/.zshrc ~/.config/awesome/rc.lua  ~/.vimperatorrc /usr/local/sbin/*



Explanation:

Save the date as 05-23-2013 for example, the sed is substituting the the '/' in date with '-'.
tmpdate=$(date +%D | sed "s/\//-/g"); 


Create a compressed tar archive in home dir, called config_backup05-23-2013, where the date in the name changes acording to the date when you executed the scrip.

The files to be included are some configuration files which are important to me, but you should change them to your preferred ones, just write all of them with space between each one, all on the same line.
tar zcvf ~/config_backup$tmpdate.tar.gz ~/.vimrc ~/.zshrc ~/.config/awesome/rc.lua  ~/.vimperatorrc /usr/local/sbin/*








I save all my scripts in /usr/local/sbin/, which is included in $PATH, that way I can
launch them just by issuing their name from every directory.

I chose this dir because it was empty to begin with, a perfect place for all my scripts.


This is part one of a four part mini series where I will post small scripts I've written, along some documentation and explanation.

No comments:

Post a Comment