From cf5ce398434e19708bfa989eef020e0d69ff490e Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 8 Jan 2010 21:14:46 -0500 Subject: Add parsing and skeleton for query dispatcher --- squashfu | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'squashfu') diff --git a/squashfu b/squashfu index 3c14197..b37c341 100755 --- a/squashfu +++ b/squashfu @@ -134,6 +134,7 @@ query_usage () { bin_size=$(du -s ${BKUP_ROOT}/bins 2>/dev/null | awk '{print $1}') sfs_size=$(stat -c %s $SEED 2>/dev/null) + # Basic query info "Usage report (in mb):\n" printf "%30s %10.2f\n" "Seed size:" "`echo "scale=2;$sfs_size / 1024 / 1024" | bc`" printf "%30s %10.2f\n" "Total incremental size:" "`echo "scale=2;$bin_size / 1024 / 1024" | bc`" @@ -142,7 +143,10 @@ query_usage () { info "Your incrementals are larger than your seed! You might consider resquashing your backup with $0 --resquash" fi - #unmount_all + # Full query + [[ $1 == "full" ]] && { + debug "There should be stuff here about individual bin size"; + } } run_rsync() { @@ -193,7 +197,9 @@ OPERATIONS otherwise specified with the -c option. -Q - Displays the size of the seed, the incrementals, and the actual backup. + Displays the size of the seed, the incrementals, and the actual backup. If + you provide no additional options, a basic report will be given. Specifying + "full" will give more detail about individual bins. -R [mount] Rollback to the day described by the following argument. 'day' needs to be @@ -237,9 +243,14 @@ dispatch_backup () { } dispatch_query () { - # Don't check anything, just run the query. - # TODO: Add levels of querying - query_usage + # If no arg supplied, no need to parse + [[ -z $1 ]] && query_usage + + # Check for valid arg + case $1 in + "full") query_usage full ;; + *) die "Invalid query option"; usage ;; + esac } dispatch_rollback () { @@ -273,7 +284,7 @@ dispatch_rollback () { while [[ $# -gt 0 ]]; do case $1 in "-B") shift; dispatch_backup $* ;; - "-Q") shift; dispatch_query ;; + "-Q") shift; dispatch_query $1 ;; "-R") shift; dispatch_rollback $* ;; *) usage ;; esac -- cgit v1.2.3