Backups! Yep, that thing you’re ought to do regularly. Today’s the day for me to do it. As being not quite content with the available solutions out there I tend to do it all by hand. This involves some tedious repetitions like packing directories. So here’s a little script that might be handy:

# Create a packed tarball of a directory or file in the
# current working directory with an optional filename prefix.
DATE=`date +%Y%m%d-%H%M%S`
case “$#” in
NAME=`echo $1-$DATE | sed “{s/ /_/g;s/\/$//}”`
NAME=`echo $2-$1-$DATE | sed “{s/ /_/g;s/\/$//}”`
* )
echo “Usage: pack FILE [PREFIX]”
echo “Create a packed tarball of FILE with an optional filename PREFIX.”
exit 1
tar -cf “$NAME.tar” “$1” && bzip2 “$NAME.tar”

Just paste that into for example /usr/local/bin/pack and set the executable bit. Afterwards, if you want to pack a directory test you can do a simple pack test or provide a prefix to the resulting file with a more complex pack test $HOST-$USER which results in something like festor-saschpe-test- 20091120-122101.tar.bz2 on my machine. And don’t forget to listen to classy music like this while backing up your stuff:

That’s it, have a nice weekend.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.