Thursday, 13 January 2011

Simple backup of a directory on Ubuntu Server

So I set up an Ubuntu Server instance but need to backup my development folder on a regular basis. I've got SSH access so can access it via PuTTY and FileZilla. In PuTTY I use tar -cvf [YYYYMMDD].tar [directory]/, when it's done I use gzip [YYYYMMDD].tar and then use FileZilla to copy across the resulting [YYYYMMDD].tar.gz file.

Now I just need to remember to do this at the beginning and end of each day!


# declare DATE variable
theDATE=$(date +%Y%m%d)
tar -cvf $theDATE.tar www/
gzip $theDATE.tar