#!/usr/bin/python
# -*- encoding: iso-8859-15 -*-
### under GPL
### (c) chaos - www.true-binary.com
#####################################

import os
import sys
import time

datum=time.strftime('%d-%m-%Y_%H-%M')

def makemeclear():
	os.system("clear")
makemeclear()


a=raw_input('type in the full path [example: /var/www/mysite/]: ')
b=raw_input('name of the backup-file: ')

####################
#make a tar.gz file:
####################
def makebackuptar(datum,a,b):
	print ""
	print "please stand by while creating the backup ..."
	print ""
	os.system('tar -czvf '+b+'_'+datum+'.tar.gz '+a)
	print ""
	print "backup done whiteout any problems!"
	print ""
	sys.exit(0)

#################
#make a zip file:
#################
def makebackupzip(datum,a,b):
	print ""
	print "please stand by while creating the backup ..."
	print ""
	os.system('zip -9 '+b+'_'+datum+'.zip '+a+'*')
	print ""
        print "backup done whiteout any problems!"
        print ""
        sys.exit(0)

#####################
#ask for compression:
#####################
def askcomp1(datum,a,b):
	c=raw_input('type "1" for TAR-GZ or "2" for ZIP: ')
	for i in c:
	        if c == "1":
	                makebackuptar(datum,a,b)
			pass
	        if c == "2":
	                makebackupzip(datum,a,b)
			pass
	        else:
			print ""
			print "uuups, just type in 1 or 2 ... please try again ... [or type CTRL+C to exit]"
			print ""
			askcomp1(datum,a,b)

askcomp1(datum,a,b)

