A PHP Error was encountered
Severity: 8192
Message: Function create_function() is deprecated
Filename: geshi/geshi.php
Line Number: 4698
Backtrace:
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4646
Function: _optimize_regexp_list_tokens_to_string
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 624
Function: getPaste
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/system/core/Exceptions.php:271)
Filename: view/download.php
Line Number: 2
Backtrace:
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/themes/geocities/views/view/download.php
Line: 2
Function: header
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 173
Function: include
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 43
Function: _ci_load
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 625
Function: view
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/system/core/Exceptions.php:271)
Filename: view/download.php
Line Number: 3
Backtrace:
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/themes/geocities/views/view/download.php
Line: 3
Function: header
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 173
Function: include
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 43
Function: _ci_load
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 625
Function: view
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once
diff --git a/.todo b/.todo
index 78cca06..0a46199 100644
--- a/.todo
+++ b/.todo
@@ -419,9 +419,12 @@
Implemented
-
+
backup for config file and database
-
+
+ Implemented
+
+
configuration item for backup directory
diff --git a/debian/control b/debian/control
index 1d63d1b..0422bdf 100644
--- a/debian/control
+++ b/debian/control
@@ -7,7 +7,7 @@ Standards-Version: 3.9.1
Package: eta
Architecture: all
-Depends: ${misc:Depends}, bc
+Depends: ${misc:Depends}, bc, tar, bzip2
Description: Embelin Time Assistant, a nifty working hour management utility
ETA is a small but clever script for maintaining your working hours. It can
count over midnight and produce basic reports.
diff --git a/eta b/eta
index c72cc24..f6a8b6a 100755
--- a/eta
+++ b/eta
@@ -21,7 +21,7 @@
shortusage()
{
echo "usage: `basename $0` [ | -a \"\" ]"
- echo " `basename $0` [ -c | -d \"\" | -e | -f | -F | -h | -m | -o | -p | -r | -R | -s | -y ]"
+ echo " `basename $0` [ -b | -c | -d \"\" | -e | -f | -F | -h | -m | -o | -p | -r | -R | -s | -y ]"
echo " `basename $0` [ --version ]"
echo " `basename $0` [ --help ]"
}
@@ -34,6 +34,7 @@ usage()
echo " -a \"\" Add a time row (e.g. \"2011-07-04 11:30 - 12:00 Script tuning\")."
echo " Note that if you have worked over midnight, you can add different"
echo " end date to the event."
+ echo " -b Backup event database and user configuration file."
echo " -c Continue/start new time tracking event from the time previous ends,"
echo " use previous description."
echo " -d \"\" Change latest description. If used with \"-s\" or \"-c\","
@@ -1125,6 +1126,10 @@ readconfig()
WMLEN[$WMYEAR]="$WMMONTHS"
;;
+ "backuppath")
+ BUPATH="$PARAM"
+ ;;
+
*)
echo -e "\nUnknown configuration command [$CMD] in $1\n"
;;
@@ -1161,7 +1166,7 @@ REMOVELASTEVENT=""
FILTERINCLUDE=""
FILTEREXCLUDE=""
ASSUMEYES=""
-
+BACKUP=""
#
# Check the global configuration file
@@ -1178,6 +1183,8 @@ then
fi
+#
+# If default behaviour is configured, handle it here.
if [[ "$1" == "" ]] && [[ "$DEFBEHAVIOUR" == "" ]];
then
version
@@ -1251,10 +1258,11 @@ fi
# Parse single command line parameters
-while getopts 'a:cd:ef:F:hmop:r:Rsyv' opt;
+while getopts 'a:bcd:ef:F:hmop:r:Rsyv' opt;
do
case $opt in
a) ADDTIMEROW="$OPTARG";;
+ b) BACKUP="y";;
c) STARTEVENT="y"; STARTFROMPREVTIME="y";;
d) NEWDESCRIPTION="$OPTARG";;
e) STOPEVENT="y";;
@@ -1515,6 +1523,52 @@ then
fi
fi
+if [[ "$BACKUP" == "y" ]];
+then
+ if [[ "$BUPATH" != "" ]];
+ then
+ BUDIROK=""
+
+ # Files to backup: $TIMEDB, $MYRC
+ BUFILE="`date +%Y-%m-%d_%H%M%S`.tar.bz2"
+
+ # Trick to replace ~ with $HOME
+ ESCHOME=`echo $HOME | sed 's/\//#/g'`
+ BUPATH=`echo $BUPATH | sed "s/\~/$ESCHOME/" | sed 's/#/\//g'`
+
+ # Check the backup path existance and try to create it if needed.
+ if [ ! -d "$BUPATH" ];
+ then
+ echo "no $BUPATH, creating..."
+ mkdir -p "$BUPATH"
+
+ if [[ "$?" == "0" ]];
+ then
+ BUDIROK="y"
+ else
+ BUDIROK=""
+ fi
+ else
+ BUDIROK="y"
+ fi
+
+ # If backup path is ok, try to create the backup.
+ if [[ "$BUDIROK" == "y" ]];
+ then
+ tar -jcC $HOME -f $BUPATH$BUFILE `basename $TIMEDB` `basename $MYRC`
+
+ if [[ "$?" == "0" ]];
+ then
+ echo "backup file $BUFILE created."
+ else
+ echo "backup failed, check $BUPATH!"
+ fi
+ fi
+ else
+ echo "backup directory setting missing, backup was not created."
+ fi
+fi
+
# If only -r parameter is given, display current time rounded up and down.
# But if rounding comes from config file, don't display anything
diff --git a/eta.1 b/eta.1
index 09fbf64..d556118 100644
--- a/eta.1
+++ b/eta.1
@@ -22,7 +22,7 @@
[ | \fB\-a\fR "" ]
.br
.B eta
-[ \fB\-c\fR | \fB\-d\fR "" | \fB\-e\fR | \fB\-f\fR | \fB\-F\fR | \fB\-h\fR | \fB\-m\fR | \fB\-o\fR | \fB\-p\fR | \fB\-r\fR | \fB\-R\fR | \fB\-s\fR | \fB\-y\fR ]
+[ \fB\-b\fR | \fB\-c\fR | \fB\-d\fR "" | \fB\-e\fR | \fB\-f\fR | \fB\-F\fR | \fB\-h\fR | \fB\-m\fR | \fB\-o\fR | \fB\-p\fR | \fB\-r\fR | \fB\-R\fR | \fB\-s\fR | \fB\-y\fR ]
.br
.B eta
[ \fB\-\-version\fR ]
@@ -53,6 +53,9 @@ end date to the event.
Also note: There is a special purpose syntax "yyyy-mm-dd desc" which you can use for "patching" a workday up to configured working day length with a given description. This is handy for example when reporting sickdays and holidays.
.TP
+\fB\-b\fR
+Backup event database and user configuration file. Backup location can be set in configuration file.
+.TP
\fB\-c\fR
Continue/start new time tracking event from the time previous ends,
use previous description.
@@ -227,6 +230,9 @@ Set the default working week lenght in workdays, usually 5 in Finland.
.TP
\fBworkingmonthlength\fR
Set the amount of expected working days for each month and year. This configuration option can be set for several years at the same time, see /etc/etarc for syntax and example.
+.TP
+\fBbackuppath\fR
+Set a path to directory where backup files are copied. Note that final "/" needs to be included.
.SH COPYRIGHT
Copyright \(co 2011 Mika Tapojärvi
.PP
diff --git a/etarc b/etarc
index fa5d9ef..64bc364 100644
--- a/etarc
+++ b/etarc
@@ -50,3 +50,8 @@ workingweeklength 5
# yyyy Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
workingmonthlength 2010 20 20 23 19 22 20 21 23 22 21 22 20
workingmonthlength 2011 19 20 23 20 20 21 22 22 22 21 22 21
+
+# Backup path
+backuppath ~/.eta_backup/
+