#!/usr/bin/python

# File: backup.py
# Author: m.lipson@unsw.edu.au
# Description: 
# This is a script run once a day to backup observations
# It is run through crontab, editable with:
# 	crontab -e

import os
import time

# set path for local or server
if (os.getenv('HOME') == '/home/ubuntu'):
	fullpath = '/srv/isithotrightnow'
else:
	fullpath = '.'

# set day
today = time.strftime("%y%m%d")

# create directory if not existing
if not os.path.exists("%s/databackup" %(fullpath)):
	os.makedirs("%s/databackup" %(fullpath))

# make backup with todays date
os.system('cp %s/data/latest/latest-all.csv %s/databackup/%s-all.csv' %(fullpath,fullpath,today))

@@ -518,16 +518,108 @@
 llpath))
+%0Aif not os.path.exists(%22%25s/imgbackup%22 %25(fullpath)):%0A%09os.makedirs(%22%25s/imgbackup%22 %25(fullpath))
 %0A%0A# make
@@ -741,8 +741,244 @@
 today))%0A
+%0A# make backup of timeseries%0Afor site in %5B'009021','014015','015590','023090','040842','066062','067105','070351','087031','094029'%5D:%0A%09os.system('cp %25s/www/output/ts_plot.png %25s/imgbackup/%25s-ts-%25s.png' %25(fullpath,fullpath,site,today))%0A%0A

update backup to include timeseries