Saturday, 7 April 2007

Backup Script

Since I'd got my hands dirty with the portage script already, I decided to automate my backups, which are conveniently small scaled. This Perl script is but a serial execution of widely available shell tools, namely rsync, rm, mv and tar. What it does is it synchronizes the folder you feed in with another one hardcoded into the script (I will change that obviously), in the way such that feeding in /etc will result in $HARDCODEDFOLDER/etc, and an _etc.tar.bz2 in this folder. the tarballs are named with their names, slashes ('/') translated into underscores ('_'). Every time the script is run, first it tries to extract the tarball to $HARDCODEDFOLDER (so that it is extracted as the proper subdirectory), then rsync synchronizes the destination folder to the source folder. It skips identical files, so yay. Finally, it compresses the synchronized version into a tarball and kicks it to its folder.

Download it here.

No comments: